<rss version='2.0'>
<channel>
<title>QuestToSolve.com RSS</title>
<link>http://www.questtosolve.com</link>
<description>The last 3 problem solutions from both of us.</description>
<language>en-ca</language>
<copyright>Copyright 2009 QuestToSolve.com</copyright>
<docs>http://www.questtosolve.com/rss</docs>
<item>
<title>|=========================================|</title>
</item>
<item>
<title>Peter's Solutions</title>
</item>
<item>
<title>Problem Number: 10878 (Decode the tape)</title>
<description>Solution: 

Each row on the tape is a binary sequence, that represents the ascii value of a given character.



Ignore the lines | and _ which define the outer perimeter of the tape, and ignore the periods as well.



Take the input in, and remove all the unnecessary characters, then change the spaces to zeros and o's to 1's.



Output the characters corresponding to the given ascii values, but do not print out a new line after the input!!!</description>
<link>http://www.questtosolve.com/browse.php?pid=10878</link>
</item>
<item>
<title>Problem Number: 10922 (2 the 9s)</title>
<description>Solution: 

Literally define a recursive function that takes integers a and b.



If a &lt; 10, return b if a % 9 == 0, and return -1 otherwise.



If a &gt;= 10, sum its digits and return recursivefunction(sum, b+1)



Then, in your normal function, sum the digits of the input right away, and just return recursivefunction(sum, 1).</description>
<link>http://www.questtosolve.com/browse.php?pid=10922</link>
</item>
<item>
<title>Problem Number: 11204 (Musical instruments)</title>
<description>Solution: 

I completely overthought this problem the first time, and the second time.



It's simply a combinatorics solution. Create an instruments array, and increment the elements corresponding to the students' first choices. The other choices are irrelevant.



Now, just go through the array, and multiply all the elements &gt; 1 together. There's your answer!



This is because for each instrument in competition, there are n students that could have it (where n is the number of students with it as a first priority).



From there it's simply the combinations of students for each instrument.



At first I thought this was a DP - although I'm sure you could probably think one up. Then I misread the question, and thought that in addition to the correct solution above, you had to multiply THAT by all the combinations of students who didn't get the instrument they wanted - getting instruments they don't want.</description>
<link>http://www.questtosolve.com/browse.php?pid=11204</link>
</item>
<item>
<title>|=========================================|</title>
</item>
<item>
<title>Wesley's Solutions</title>
</item>
<item>
<title>Problem Number: 1103 (Ancient Messages)</title>
<description>Solution: 

The key thing to notice in this problem is that each of the 6 shapes has a different number of holes. &quot;Was&quot; has no holes, &quot;Ankh&quot; has one, ..., &quot;Djed&quot; has five.



So this problem boils down to finding contiguous sets of black pixels and determining how many holes are inside.



First, look for white pixels on the border of the image. These are definitely background pixels. Floodfill all white pixels from these to find all background pixels.



Now we'll do a double-floodfill. First, scan the image for black pixels. When you find one, floodfill outwards looking for black pixels, and white pixels that aren't part of the background. When you find such a white pixel, floodfill for all white pixels that it's connected to, and mark this as one hole. Then, go back to flooding black pixels.

</description>
<link>http://www.questtosolve.com/browse.php?pid=1103</link>
</item>
<item>
<title>Problem Number: 10618 (Tango Tango Insurrection)</title>
<description>Solution: 

Our DP will be a series of arrays of size [4][4][3][70].



f(l, r, m, k) is the amount of energy it takes to complete the rest of dance given that you've completed k steps so far, your left foot is on square l, your right foot is on square r, and m is a value (0, 1, or 2) that represents which foot (if any) moved in the last step.



The convention I use for l and r is 0 = Up, 1 = Left, 2 = Right, 3 = Down.



For m I use 0 = no foot moved, 1 = Left, 2 = Right.



So, we want to determine f(1, 2, 0, 0), and return the appropriate sequence of actions. At each step, there are two cases:



Case 1: The next step is '.'



In this case, try moving your left foot to all four squares, and then try moving your right foot to all four squares. Nothing is going to be tapped, but you can use this pause in the music to reposition yourself. If you move a foot, make sure to output the foot that moved, even though it didn't tap.



Case 2: The next step is 'U', 'L', 'R' or 'D':



In this case, try moving your left foot to the appropriate square, and try moving your right foot to that square as well.



In both cases, make sure not to allow any illegal moves.



I recommend having three parallel arrays. Each is indexed as mentioned above, by (l, r, m, k). The first array, COST, is the standard DP array that keeps track of how much energy it takes to complete the dance from the given state. The second array, NEXT, keeps track of some integer or object that points to the next state in the path, and the third array, MOVE, keeps track of what move was taken.



For example, consider the input &quot;LUR&quot;. We go through the following transitions to get the output &quot;LRL&quot;:



l r m k



1 2 0 0 (move is &quot;L&quot;)

1 2 1 1 (move is &quot;R&quot;)

1 0 2 2 (move is &quot;L&quot;)

2 0 1 3 (sequence is finished)



And the arrays look like this:



NEXT[1][2][0][0] = (1, 2, 1, 1)

MOVE[1][2][0][0] = 'L'

COST[1][2][0][0] = 3



NEXT[1][2][1][1] = (1, 0, 2, 2)

MOVE[1][2][1][1] = 'R'

COST[1][2][1][1] = 2



NEXT[1][0][2][2] = (2, 0, 1, 3)

MOVE[1][0][2][2] = 'L'

COST[1][0][2][2] = 1



At the end of the DP, use the information in NEXT to traverse through the optimal states, and use the information in MOVE to print out the move sequence.

</description>
<link>http://www.questtosolve.com/browse.php?pid=10618</link>
</item>
<item>
<title>Problem Number: 10262 (Suffidromes)</title>
<description>Solution: 

Try all reversed prefixes of each string as possible suffixes, in order of increasing length, and lexicographic earliness. So, for the input:



andrew

wesley



Try &quot;&quot;, &quot;a&quot;, &quot;w&quot;, &quot;ew&quot;, &quot;na&quot;, &quot;dna&quot;, &quot;sew&quot;, etc.



For each suffix, try appending it to both strings. If it turns only one into a palindrome, then that's your answer.



If at the end you find no solution, there's one more step to try. We may have a case like:



a

&lt;blank line&gt;



In this case, the solution is &quot;b&quot;. Or we might have:



a

aa



In this case, &quot;ba&quot; is the correct suffix.



Let S1 be the smaller string, and S2 be the larger string. If both are the same length, then it doesn't matter which you pick. Try 26 more suffixes, &quot;a&quot;+rev(S1) through &quot;z&quot;+rev(S1), where rev(S1) is S1 reversed.



If there are still no solutions after this step, then print &quot;No solution.&quot;</description>
<link>http://www.questtosolve.com/browse.php?pid=10262</link>
</item>
</channel>
</rss>

