Question: java recursion Coin game: Alice and Bob are playing a game using a bunch of coins. The players pick several coins out of the bunch

java recursion

Coin game: Alice and Bob 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. The player that gets the last coin is the winner. Assume that both players are very smart and will try their best to work out a strategy to win the game. For example, if there are 2 coins and Alice is the first player to pick, she will definitely pick 2 coins and win. If there are 3 coins and Alice is still the first player to pick, no matter whether she picks 1 or 2 coins, Bob 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),

write a methodto calculate the winner of the game and calculate how many different strategies there are for them to win the game. Use recursion to solve the problem

. You can assume that there are no more than 30 coins.

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!