Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create the following script in Python: The Game of Stones In this game, two players sit in front of a pile of n stones. For

Create the following script in Python:

The Game of Stones

In this game, two players sit in front of a pile of n stones. For this assignment, let us choose 100 stones but this could be randomly generated. Players take turns removing between 1 and 5 stones, this assuming there are at least 5 stones left in the pile. The person who is able to remove the last of stones or single stone wins.

Your assignment is to write a function to play this game. You may need to use nested while loops, which is one while loop inside another. In the outermost loop, we want to keep playing until we are out of stones. Inside that loop, we want to keep alternating players. Keep the following mind:

i. Is the user's input valid (meaning is it a number?)?

ii. Is the user input a valid number (1-5)?

iii. Are there enough stones in the pile to take off the user's input amount?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

Define human resource ethics.

Answered: 1 week ago