Question: Write a program for river crossing puzzle. Accept the following five one-character strings as valid commands: f , g , c , n , or

Write a program for river crossing puzzle.

Accept the following five one-character strings as valid commands: f, g, c, n, or q. After receiving a valid command from the user, the game should:

    • f, g, or c: move the fox, goose, or corn, if available, to the opposite shore along with the boat.
    • n: move the boat to the opposite shore without any item.
    • q: quite the game.

break down your program into functions with reasonable length.

use functions and/or lists to reduce redundancy.

The sample output is shown in the picture
Write a program for river crossing puzzle. Accept the following five one-character
strings as valid commands: f, g, c, n, or q. After receiving
a valid command from the user, the game should: f, g, or

10 Sample Session 1 Welcome. You have to bring the fox, the goose, and the cron across the river. Boat A Fox Goose Corn You are now at the near shore, what do you want to take? Goose Boat Fox Corn You are now at the far shore, what do you want to take? ne Goose Boat Fox Corn You are now at the near shore, what do you want to take? f@ Goose Fox Boat Corn You are now at the far shore, what do you want to take? ga Fox Boat Goose Corn You are now at the near shore, what do you want to take? de Fox Corn Boat Goose You are now at the far shore, what do you want to take? Boat Fox Goose Corn You are now at the near shore, what do you want to take? Fox Goose Corn Boat Congratulations! You have brought all itens across the river. 11 Sample Session 2 Welcome. You have to bring the fox, the goose, and the cron across the river. Boat Fox Goose You are now at the near shore, what do you want to take? foxa You have entered an invalid command. Boat Fox Goose Corn You are now at the near shore, what do you want to take? fa Fox Boat Goose Corn You have failed. The goose has eaten the cron

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!