7 comments

[ 2.8 ms ] story [ 14.8 ms ] thread
You can solve this problem faster using the extended Euclidean algorithm.
Does the algorithm yield the exact path to the target volume?
It will be nice to have a list with all steps at the end
Thought it is real water pouring simulation..
Intuitively, to be possible I think the target amount has to be divisible by the gcf of the two jugs.