in reply to Challenge: N Jugs Problem
So, I'd apply Dijkstra's algorithm. Start with a queue containing a single state (X = Y = Z = 0). Now, loop and do the following:
The drawback is that the algorithm will not terminate if there is no solution. Nor is it necessarely efficient.
You can easily change the algorithm to find the solution using the smallest amount of water to keep track of the amount of water used, and keeping the queue partially ordered (a heap will do) on water usage.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Challenge: N Jugs Problem
by ikegami (Patriarch) on Apr 14, 2009 at 20:02 UTC |