Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python The rule is that which list contains more H, that is winner what kind of problem description missingwhat do you need exactly? Strategy 1.

image text in transcribed
image text in transcribed
image text in transcribed
python
The rule is that which list contains more "H", that is winner
what kind of problem description missingwhat do you need exactly?
image text in transcribed
Strategy 1. Functions a. Define a function to read the input. One possibility is to have the function return a list of two lists. The first list would contain the five coin position characters for Player 1. The second list would contain the five coin position characters for Player 2. The function will either read the position from the input, or randomly generate a position. b. Define a function to play out the game. It should take the position as an argument, and return either 15, 2 or 0 as described in the assignment. 1. The function will have to manipulate the players' lists. Each player has both an army list and a prisoners list The prisoners list starts empty. 11. A while loop can be used to run rounds of the game until it is over 111 Inside the while loop, there will be an if with two or three cases. It might be worth defining a separate function for a round that is not a tie, to avoid duplicating code. 2. Call the functions, print the result. random Sample input requesting a game from a given position: position THHTT TTHTH The program should print the starting position, then (silently) play out the game according to the Coin War rules, It should then print 1 if Player 1 wins, 2 if Player 2 wins, or if there is a tie. Sample Program Run Assume file game1.txt contains this text: position THHTT TTHTH Then run the program: >>> python3 coinwar.py >> python3 coinwar.py

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

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

What is the payback period? Find the paybacks for Projects L and S.

Answered: 1 week ago

Question

Persuasive Speaking Organizing Patterns in Persuasive Speaking?

Answered: 1 week ago