Three test tubes contain numbered balls. The first and last of the tubes can contain three balls each, but the middle tube can hold only two. They start out in the configuration shown at left, and your task is to move one ball at a time from one tube to another without exceeding the tube's capacity, until the numbered balls are in the configuration on the right.
What's the minimum number of moves of individual balls and what's the sequence of moves?
| | |2| | | | |
| | | | |4| ====> |2| | | |4|
|1| |5| |3| |5| |1| |3|
= = = = = =
From Daily Brain Games calendar 2019, by HAPPYneuron, Andrews McMeel Publishing, Kansas City, MO. Puzzle for November 23.
Being disinclined to hard thinking, I wrote a code that made random legal moves. After a lot of tries it did it in 7 moves:
============ index= 0 move= 0 (initial state)
| | |2|
| | | | |4|
|1| |5| |3|
============ index= 1 move= 3 (column 1 gets from 2)
| | |2|
|5| | | |4|
|1| | | |3|
============ index= 2 move= 6 (column 2 gets from 3)
| | | |
|5| | | |4|
|1| |2| |3|
============ index= 3 move= 1 (column 2 gets from 1)
| | | |
| | |5| |4|
|1| |2| |3|
============ index= 4 move= 2 (column 3 gets from 1)
| | |1|
| | |5| |4|
| | |2| |3|
============ index= 5 move= 3 (column 1 gets from 2)
| | |1|
| | | | |4|
|5| |2| |3|
============ index= 6 move= 3 (column 1 gets from 2)
| | |1|
|2| | | |4|
|5| | | |3|
============ index= 7 move= 6 (column 2 gets from 3)
| | | |
|2| | | |4|
|5| |1| |3|
imin = 7
(it is interesting that 3 and 4 are to be ignored completely)
Edited on January 7, 2020, 8:43 am