Question

Task 1 Draw a flowchart that presents the steps of the algorithm required to perform the task spe...

Task 1 Draw a flowchart that presents the steps of the algorithm required to perform the task specified. You can draw the flowcharts with a pen/pencil on a piece of paper and scan it for submission. Please ensure that the scanned file and your handwriting are clear and legible. However, it is preferable to draw flowcharts using a drawing software. Here are links to some free drawing tools https://www.draw.io/ www.lucidchart.com http://dia-installer.de/ https://pencil.evolus.vn/

---------------------------------DON'T NEED THE PYTHON CODE... JUST THE ALGORITHM AND FLOW CHART ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

design a game of Nim in Python. In this game “Two players take turns removing objects from distinct heaps or piles. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap/pile. The goal of the game is to avoid taking the last object.” (Wikipedia) In your implementation of the game, there will be 3 piles of objects. At the start of the game, each of the three piles will be initialized by a random number of objects. Random number should be between 5 and 15. The players will take turn picking up objects from the piles. A player can even pick up all items from a single pile. The player that picks up last object (across all piles) loses. You should use functions in the program. Functions must follow a good programming style, that is, any well-defined task which needs to be executed often, can be moved into its own function. Following is a sample run of the program. You should follow same display style. You have to handle invalid inputs as well, as demonstrated by several examples in the sample run. IN the given example, initially the game starts with randomly chosen number of objects (7,13,9). The program prompts both players to select a pile and choose how many objects to remove. =====

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Output

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

==== Welcome to Nim Game =====

Here are the three piles
A: *******
B: *************
C: *********
(7, 13, 9)

Player 1, choose your pile (A, B, C): C
Choose how many objects to remove: 5
OK

A: *******
B: *************
C: ****
(7, 13, 4)

Player 2, choose your pile (A, B, C): krypton
ERR: Sorry, that is not a valid pile.
Player 2, choose your pile (A, B, C): A
Choose how many objects to remove: 7
OK
A:
B: *************
C: ****
(0, 13, 4)

Player 1, choose your pile (A, B, C): B
Choose how many objects to remove: alpha
ERR: Sorry, that is not a valid number.
Choose how many objects to remove: 10
OK

A:
B: ***
C: ****
(0, 3, 4)

Player 2, choose your pile (A, B, C): C
Choose how many objects to remove: 8
ERR: Sorry, there is not enough objects to remove in this pile.
Choose how many objects to remove: 4
OK

A:
B: ***
C:
(0, 3, 0)

Player 1, choose your pile (A, B, C): C
ERR: Sorry, this pile is already empty.
Player 1, choose your pile (A, B, C): B
Choose how many objects to remove: 1
OK

A:
B: **
C:
(0, 2, 0)

Player 2, choose your pile (A, B, C): B
Choose how many objects to remove: 2
OK

A:
B:
C:
(0, 0, 0)

Player 2 picked up the last object. <<< Player 1 >>> is the WINNER.

Thanks for playing. Goodbye.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

FlowChart:

Start Assign A,B,C with random values Assign Playe with 1 False print contents of player as he won player number ile Either A

Hope your problem solved.

Feel free to comment doubts in comment section.

Add a comment
Know the answer?
Add Answer to:
Task 1 Draw a flowchart that presents the steps of the algorithm required to perform the task spe...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT