Cross river problem is relatedly old and amazing to know when i was a kid. The problem consist of 4 components : Boatman, sheep, cabbage and wolf. All of them is at one side of the river. The goal is to travel to the next side of the river. But there is some regulations.
1, Wolf will eat sheep when boat man is not at the same side. 2, Sheep will eat cabbage when wolf and boatman are not at the same side. 3, Each travel require boatman to use the boat. 4, Each time have only maximum 2 objects can use the boat.
This is the first problem i solved with python, which is a cabbage, sheep and wolf cross river game. There is 2 methodology. One of them is the original flow that i will consider the boatman at each stage to make decision. Another is to not consider about the stage of the boat man and make the correct decision base on the cabbage, sheep and wolf only. When execute, it will print out the path and the flow of the game.