in reply to Solving riddles with Perl

If you stretch your imagination enough (and Perl is good at letting that happen) you can solve these puzzles using Genetic algorithms.
You could assign each character in a string a task:
5 - fill 5 gallon bucket
3 - fill 3 gallon bucket
P - pour 5 into 3
p - pour 3 into 5
E - empty 5
e - empty 3

I don't think I'm missing anything. Your population would be strings of different lengths, maybe 3-10? I'm guessing here.

Then your fitness function takes the string, and just follows the instructions like a recipie. This does mean that some semi-impossible things could happen, empty an empty bucket, fill a full bucket etc.

Crossing is just taking random points in the string and swapping them.

Once you have a good GA engine it is easy to replace the fitness function and the population generation functions, and in a few cases the crossing function (mutation too!).

If I get bored sometime today maybe I'll code up an example.

Doing a search on "Genetic Algorithms" turns up a few really good nodes.
Helter