Similar logic problems are often encountered in the intelligence test questions. A few cups of different capacities will let you pour out much water.
On Android, a game dedicated to playing this question is called Water Logic.
I installed this game to repeat dozens of off-board cartoons. I felt that the level design of this game was very poor, and the difficulty of the level was not increasing progressively. There were a lot of lower-end levels, and lack of difficult levels.
As a programmer, we should be able to play with this type of questions. We can do it easily in 10 or more steps, but it may not be able to easily reach the minimum number of steps.
There are three star obsessive-compulsive gamers and programmers who write such a small program that automatically solves the problem. This problem will no longer be a problem in the future.
Click here to try to solve the problem of cup pouring water automatically
Basic algorithm logic:
Each Cup can be full, empty, or poured into other cups, so the total number of cups * (number of cups-1 + 2)
For three cups, there are 12 types of operations available in each step. If there are two cups, there are 6 types of operations available in each step.
Traverse each operation, record the amount of water in each cup after the operation is completed, and calculate a key for creating a map.
When traversing various reverse operations, if the key already exists and the number of current steps is greater than the number of previously recorded steps, this operation is discarded.
This small program can only solve the problem of pouring water from two or three cups. It is not written into N cups, and the code has a lot of hard code.