Hi,

Your code correctly finds a solution for the input "3 4", but incorrectly 
reports that "4 3" is impossible. Since the problem is symmetrical, either both 
cases are solvable, or neither.

Your approach is actually a greedy algorithm, not brute-force. A brute-force 
approach would be to try all possible sequences until either you find one that 
works, or you determine that no solution exists. Your algorithm attempts to 
construct _one_ solution, by repeatedly choosing the first valid option from 
the "roundtrip" list. If that attempt fails, you print "IMPOSSIBLE". But that 
still leaves open the possibility that making a different sequence of jumps in 
the beginning would have led to a valid solution.

-- David

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/137fa18d-74c2-48ba-942f-d6725c67eb23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to