How to solve problems that fall in the Finders keepers category in ‘Game Theory’?
Note- Finders keepers game fall into the category of ‘Impartial Games’ in ‘Game Theory’.
What are ‘Impartial Games’?
Let a game is being played between two players ‘A’ and ‘B’. A game between them is said to be ‘Impartial’ if both the players have same set of moves. Which move to choose at a particular moment of the game depends on the state of the game.
FINDERS KEEPERS GAME
Let two players A and B playing a game on a pile of coins. Each player has to remove a minimum of ‘a’ coins or maximum of ‘b’ coins from the pile in his turn until there are less than ‘a’ coins left.
- Finder-Winner -> In this format the player to play the last move wins.
- Keeper-Loser -> In this format the player to play the last move loses.
Note- If there are less than ‘a’ coins available then last player to move must pick all coins.
- FINDER-WINNER: Let ‘A’ be the player to start. For a game of FINDER-WINNER the main strategy is to reduce the present number coins to a multiple (a+b) for ‘A’ to win the game. Else he loses and ‘B’ wins.
- KEEPER-LOSER: Let ‘A’ starts the game. For ‘A’ to win the game the main condition for winning it is to reduce the pile of coins to – (a+b)k + [1, a], i.e. the number of coins can be reduced to more then a multiple of (a+b) by [1 upto a]. If he can do so he wins else ‘B’ wins.
Let A and B play a game of FINDER-WINNER on a set of 20 coins. A player in his move can remove a minimum of 5 coins and a maximum of 7 coins. predict the Winner of the Game If A starts first and if both players play optimally.
Given number of coins = 20.
Minimum coins that can be removed = 5 – Let it be ‘a’.
Maximum coins that can be removed = 7 – Let it be ‘b’.
According to given strategy for FINDER-WINNER:
For A to win: A must remove the number of coins to a multiple of (a + b). Nearest multiple of (a + b) for 20 is 12. So A can deduct either 5 or 6 or 7 coins from the set so he cant reach 12 anyhow. So for B to make a move, he will be left with 15 or 14 or 13 coins. Now for A’s next move corresponding states are (10, 9, 8), (9, 8, 7) and (8, 7, 6). Since B is also playing optimally he will keep the number of coins for A’s move greater than 7 so that A cant win. Hence, he will get at least 1 coin to be removed in the last move and WIN.
Let A and B play a game of Keeper-Loser on a set of 20 coins. A player in his move can remove a minimum of 2 coins and a maximum of 5 coins. Predict the Winner of the Game If A starts first and if both players play optimally.
Given number of coins = 20.
Minimum coins that can be removed = 2 – Let it be ‘a’.
Maximum coins that can be removed = 5 – Let it be ‘b’.
According to given strategy for KEEPER-LOSER :
For A to win: A must remove the number of coins to a multiple of (a + b)k + [1, a]. Here a + b = 7.
Now, for playing optimally lets see what A will do in further rounds. If A reduces the set of coins to lets say 15 which is of the form (2 + 5) * 2 + 1 as it is reachable by removing 5 coins from a set of 20 coins. From here B can take any number of coins from [2, 5] lets name it as c. The main strategy of A now will be to remove 7 – c in his moves.
Why is it so?
Lets say after 15, B reduces the set to 10 by taking away 5 coins. Now optimal strategy for A is to remove 2 coins. If he does so, the set reduces to 8 coins. Now from here B can reduce the set to (6, 5, 4, 3) by removing (2, 3, 4, 5) coins respectively. From here again, the main idea for A is to take away 7 – c coins which will keep 1 coin for B to remove. Hence A wins.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Logarithm tricks for Competitive Programming
- Program to solve the Alligation Problem
- Gaussian Elimination to Solve Linear Equations
- Solve the Linear Equation of Single Variable
- Gill's 4th Order Method to solve Differential Equations
- Runge-Kutta 4th Order Method to Solve Differential Equation
- Runge-Kutta 2nd order method to solve Differential equations
- Problems not solved at the end of Nth day
- Recursive Practice Problems with Solutions
- Interactive Problems in Competitive Programming
- Find GCD of each subtree of a given node in an N-ary Tree for Q queries
- Count of common subarrays in two different permutations of 1 to N
- Add two integers of different base and represent sum in smaller base of the two
- Subsets of size K with product equal to difference of two perfect squares