Amir J.

asked • 08/07/20

Programming about coding

Amira and Bahiya are playing a game using a bunch of coins. The players pick several coins out of the bunch in turn. Each time a player is allowed to pick 1, 2 or 4 coins, and the player that gets the last coin is the winner. Assume that both players are very smart and she will try her best to work out a strategy to win the game. For example, if there are 2 coins and Amira is the first player to pick, she will definitely pick 2 coins and win. If there are 3 coins and Amira is still the first player to pick, no matter she picks 1 or 2 coins, Bahiya will get the last coin and win the game. Given the number of coins and the order of players (which means the first and the second players to pick the coins), you groups are required to write a program to calculate the winner of the game, and calculate how many different strategies there are for she to win the game. You should use recursion to solve the problem, and the parameters are read from the command line. You can assume that there are no more than 30 coins.




1. This task need to complete in group


2. Report must have


- programming need use C++ language


- you need to explain how to solve this problem may be use algorithm/ pseudo code / flowchart


- the formula must be clear


- output


please help me

1 Expert Answer

By:

Patrick B. answered • 08/07/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.