Perl-Sensitive Sunglasses | |
PerlMonks |
Re^5: Golf: Cabbage, Goat, Wolfby hdb (Monsignor) |
on Jan 08, 2014 at 15:13 UTC ( [id://1069818]=note: print w/replies, xml ) | Need Help?? |
The question is where you want to draw the line between finding the solution and providing information about the solution. Based on the encoding of the states of the world used in the code above (represented by $s), the expression
is used to find the next possible moves based on the rules given. It constructs the following implicit tree:
Already, I have excluded states 3, 6, 9 and 12 as in thoses states something gets eaten. Looking at this tree, the problem is to find a path from "0" to "15" which is rather simple. The question is how much of this information is allowed to be input to the script rather being calculated. In the extreme, one could just provide the two solutions and find the shortest script to print them without having to bother moving boats, wolfs, cabbages and goats. But that would be not very interesting... And to clarify: the grep expression is not an obfuscated version of the tree but finds possible moves based upon the rules ($s is where we are, $_ a possible next state):
In Section
Obfuscated Code
|
|