Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Round 2 questions
Author Message
Panphobia

Posted: Wed Nov 28, 2012 7:57 pm   Post subject: Round 2 questions

Could someone please explain what algorithms we needed to use for question 4 and 5 on the dwite contest, that would be nice, I know the rest of it, but my team had trouble with the last two, we knew the logic, just not exactly how to implement it.

Tony

Posted: Wed Nov 28, 2012 10:40 pm   Post subject: RE:Round 2 questions

Question 4 is about maintaining a list of cards that have not yet been used in the answer deck. The note after the sample explains most of it:
Quote:

Notes: for the first case, going backwards from the solution: the first card has value 2, and there is only 1 card with greater value after it (3). Second card has value 1, and there is only 1 card with greater value after it (3). The last card has value of 3, and there are no cards with greater value. So the input of "1 1 0" checks out.

Going the other way:
possible cards (sorted order): [1,2,3]
what we know about the first card: "there is 1 card with greater value than it."
action: move the 2nd last card from possible list into the answer deck.

now the state is:
possible: [1,3]

at this point the steps repeat.
possible: [3]

possible: []

----------

For Q5, a http://en.wikipedia.org/wiki/Greedy_algorithm will produce an optimal result. E.g. you must monitor the first car, so place the first guard as far away as possible, while he can still monitor this car. Remove all of the cars that he can observe from the list. Repeat until the list is empty.
Tony's programming blog. DWITE - a programming contest.
Panphobia

Posted: Wed Nov 28, 2012 11:14 pm   Post subject: RE:Round 2 questions

ohhhhh if only i read it right tony you're a lifesaver
Panphobia

Posted: Wed Nov 28, 2012 11:22 pm   Post subject: RE:Round 2 questions

haha now I have to find out how to use a greedy algorithm, funn :DDDDDDD, I was expecting a grid/maze type question, because that is all i practiced, here comes dwite, NO GRID/MAZE type question lol
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 4 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: