Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
LESSON 6: GAMES I. Games with two alternately playing players, with no ties Each of the games below is played by two players. They move alternately. The game starts from a given configuration and finishes when a certain configuration is obtained or when one of the players can not move. The question is always: which of the two players has a winning strategy, in other words, if both players play correctly, who will win? Sometimes the question is to find the set of initial configurations for which the first player can win. Finding invariants or semi-invariants can help answering these questions. 1. Consider a row of n ≥ 3 chairs and suppose that two children are sitting in the two chairs situated at the two ends of the row. Alternately, the two children move either one, or three places towards the other child, until one of them can not move anymore, the two children occupying neighboring chairs. The one that can not move, loses. Which of the two children has a winning strategy? Solution: Between the two kids we have n − 2 chairs. After each move, the number of chairs between them decreases with either one or three. We can see that the game will certainly end and that we’ll have a winner. The key idea is that after each step, the parity of the number of the chairs between the children changes. The game ends when there are 0 chairs between the two children - an even number. If n is even, after each move of the first player there will remain an odd number of chairs and after each move of the second player there will be an even number of chairs. Therefore, for n even, each time the second player is at move, he will always have an empty chair near him to move on, so he can never lose. By the same argument, when n is odd, the first player will always be able to move at least one chair closer to his partner. Hence, when n is even, the second player wins, and when n is odd, the first player wins. 2. Two children break, alternately, an 6 × 8 piece of chocolate into smaller pieces without breaking any of the 1 × 1 pieces that constitute the chocolate piece. The child that can not move, loses. Which child is losing? Solution: After each move, the number of pieces the chocolate is broken into increases by 1. That is, after the first move, we’ll have 2 pieces of some dimensions. After the second move, we’ll have 3 pieces, and so on. Since the maximum number of pieces the chocolate can be broken into is 48 = 6 × 8 (because we cannot break a 1 × 1 chocolate piece), the game will finish after the 47-th move. Now let’s see which of the players makes the last move. After player A does his first move, the chocolate breaks into 2, after player B, it breaks into 3, after player A, it breaks into 4, and so on. Therefore, after each move of the first player, the chocolate is 1 split into an even number of pieces, so he will do the last move. Hence, player A wins the game, regardless of the strategies of the two players. Exploiting symmetry. An idea that could sometimes be useful is to write the set of all possible moves as a union of pairs. If player A selects one of the moves from a pair (m1 , m2 ) of moves, player B will select the other one. For example: 3. There are two piles of coins, each containing 2011 pieces. Two players A and B play a game taking turns (A plays first). At each turn, the player on play has to take one or more coins from one pile. Whoever takes the last coin is the winner. Which player will win if they both play in the best possible way? What if the number of coins in the two piles is n and m, respectively? Who has the winning strategy then? Solution: Player B can win no matter how A is going to play, by the following strategy: if A takes x coins from a pile, B is going to take x coins from the other pile. By this, after B makes his move, there will be the same amount of coins in both piles. Since there is a finite number of coins, at some moment A is going to finish one of the piles, and then B will finish the other one and the game will end. As above, for n = m, player B has the winning strategy. If n 6= m, player A has the winning strategy: he takes | n − m | coins from the bigger pile to even the two piles up. From there we are in the case of the equal piles with B on move, and in this case, we already know, the second player, in this case player A, has the winning strategy. 4. Given a square table n × n, two players A and B are playing the following game: At the beginning all cells of the table are empty, and the players alternate playing with coins. Player A has the first move, and in each of the moves a player will put a coin on one of the cells that doesn’t contain a coin and is not adjacent to any cell that already contains a coin. The player who makes the last move is the winner. Which player has a winning strategy, and what is the strategy? Remark. Cells are adjacent if they share an edge. Solution: If n is even, then the second player has a winning strategy: he places a coin symmetrically with respect to the center from the last coin placed by the first player. By this, if A has a free square in which he can place a coin, then B also has a free cell, symmetrical by the center of the n × n square. If n is odd, the center of the table will be a 1 × 1 square, and the winning player will be A. He places the first coin in the middle of the table, and then repeats B’s moves, symmetrically with respect to the central cell. By this, whenever B has a free cell, A also has one, symmetrical with respect to the central 1 × 1 square. Therefore, when n is even, player B wins, and when n is odd, player A wins the game. 2 Backtracking. Games where strategy does not play any role (as those from 1. and 2.) are easy to handle. For the other ones, the difficulty resides usually in finding a winning strategy for one of the players. It is hard to see from the start what the first move should be. It is much better to start the analysis from the end of the game. Find out what the last move of the winner could be, then find the winning positions. Go back one step and find all the positions from which, whatever he moves, the loser is bound to leave a winning position to the winner. Continue the process of defining each position as a winning or a losing one until you obtain the verdict on the initial position, hence the answer to the question ”who has the winning strategy?”. 5. A matchbox contains 300 matches. A move consists of removing at most half of the existing matches from the box. Two players move alternately. The one who can not move loses. Which player has a winning strategy and what is this strategy? Solution: Player A is the winner. Let’s observe that the winning positions for him are the ones in which, after the move, there are 2n − 1 matches in the box. For example, when there are 3 matches left in the box, player B can take only 1, then player A can take 1 of the two remaining, and then we have only one match left, so player B loses. When we have 7 = 23 − 1 matches left, no matter how many matches player B would choose, player A can reach to 3 matches, which is a winning position. By doing this repeatedly, we get that player A can win if after he moves, in the box remain 2n − 1 matches. Therefore, his first move will be taking 45 matches, leaving 255 = 28 − 1 in the box and then no matter how many matches B takes, A can reach another number of the form 2n − 1. 6. A rook is placed on the square situated in the bottom-left corner of a chessboard. Each move consists of moving the rook any number of squares, either to the right or upwards. Two players move alternately. The one who can not move loses. Which player has a winning strategy and what is this strategy? What if the game is played on an m × n rectangular board in stead of a chessboard? Russian Olympiad Solution: The winner is player B, the second player. Let’s observe that for him, position h8 is a winning position, and any other cell from the top row or the right column is a losing position, since from there player A can reach h8. By the same argument, all the squares from the diagonal a1 − h8 are winning positions for B and all the other ones are losing positions. We can see that B can always place the rook on the diagonal after A moves, and therefore forces A to move it outside the diagonal. Since the square we need to bring the rook, h8, is on this diagonal, player B will win the game. If the game is played on a rectangular board m × n with m 6= n, the winning positions are the squares situated at an equal distance from the last column and the 3 top row (situated on the angle bisector of the top right vertex of the rectangle). If the board is not square (in which case the first player is already on this bisector), the first player can move to such a position and win the game. 7. There are two piles of coins, each containing 2010 pieces. Two players A and B play a game taking turns (A plays first). At each turn, the player on play has to take one or more coins from one pile or exactly one coin from each pile. Whoever takes the last coin is the winner. Which player will win if they both play in the best possible way? Solution: B wins. In fact, we will show that A will lose if the total number of coins is a multiple of 3 and the two piles differ by not more than one coin (call this a balanced position). To this end, notice that it is not possible to move from one balanced position to another. The winning strategy for B consists in returning A to a balanced position (notice that the initial position is a balanced position). There are two types of balanced positions; for each of them consider the moves of A and the replies of B. If the number in each pile is a multiple of 3 and there is at least one coin: - if A takes 3n coins from one pile, then B takes 3n coins from the other one. - if A takes 3n + 1 coins from one pile, then B takes 3n + 2 coins from the other one. - if A takes 3n + 2 coins from one pile, then B takes 3n + 1 coins from the other one. - if A takes a coin from each pile, then B takes one coin from one pile. If the numbers are not multiples of 3, then we have 3m + 1 coins in one pile and 3m + 2 in the other one. Hence: - if A takes 3n coins from one pile, then B takes 3n coins from the other one. - if A takes 3n + 1 coins from the first pile (n ≤ m), then B takes 3n + 2 coins from the second one. - if A takes 3n + 2 coins from the second pile (n ≤ m), then B takes 3n + 1 coins from the first one. - if A takes 3n + 2 coins from the first pile (n ≤ m − 1), then B takes 3n + 4 coins from the second one. - if A takes 3n + 1 coins from the second pile (n ≤ m), then B takes 3n − 1 coins from the first one. This is impossible if A has taken only one coin from the second pile; in this case B takes one coin from each pile. - if A takes a coin from each pile, then B takes one coin from the second pile. In all these cases, the position after B’s move is again a balanced position. Since the number of coins decreases and (0;0) is a balanced position, after a finite number of moves, there will be no coins left after B’s move. Thus, B wins. 8. There are piles of coins with 2, 3, 4, and 7 coins, respectively. You choose a 4 pile and take some number of coins from it; then, your opponent does the same. The game continues this way, with the player who takes the last coin winning the game. Find, with justification, all first moves that will guarantee your victory. Solution: This is a particular case of the famous Nim game. In general, the Nim game has n ≥ 2 piles containing a1 , a2 , ..., an coins respectively. Here the winning strategy is very difficult to guess and that is what made the game such a success. We will describe the sets of the winning and losing positions for our problem, the general case being similar. - Represent the number of coins in each pile in base 2. You obtain 10, 11, 100 and 111 respectively. - Write them one beneath the other as you do when you sum numbers: 1 1 1 0 1 1 0 1 0 1 - Instead of summing them in base 2, we compute their so-called ”nim-sum”: the sum (in binary) neglecting all carries from one digit to another. This operation is also known as ”exclusive or” (xor). Each digit of the nim-sum is 0 if above it there is an even number of 1-s, and is 1 if on its column there is an odd number of 1-s. 1 0 1 1 0 0 1 1 1 0 positions are those for which the nim-sum 1 1 0 - For the player on move, the winning is nonzero, while the losing positions are those with the nim-sum equal to 0. Therefore, if the initial configuration has nim-sum 0 than the second player has the winning strategy, while if the nim-sum is initially non-zero, it’s the first player that has a winning strategy. This strategy (in both cases) consists in leaving to the opponent a position with nimsum 0. Since the nim-sum is 010 and the first player must make it 000, the first player has to change a 1 from the second column into a 0. This means subtracting 2 5 from the first pile (thus emptying it), from the second pile or from the forth pile. Having received a position with nim-sum = 0, the second player can make no move to leave, at his turn, a nim-sum = 0. This would mean changing two digits on the same column, i.e. removing chips from two piles, which is forbidden by the rules of the game. He will leave a nim-sum 6= 0, which means the first player can again make it 0. It is easy to prove that he has always at least one available move to do that. Here’s an example of how the game could go on. The moves of the second player do not follow any rule; he can do nothing to prevent the loss of the game. Let A, B, C, D be the number of coins in the four piles. A 2 0 0 0 0 0 0 B 3 3 3 3 3 0 0 C 4 4 2 2 1 1 0 D Nim − sum 7 0102 = 210 7 0002 = 010 7 1102 = 610 1 0002 = 010 1 0112 = 310 1 0002 = 010 1 0012 = 110 Comments I take 2 from A, leaving a sum of 000, so I will win. You take 2 from C I take 6 from D You take 1 from C I take 3 from B You take 1 from C I take the last chip and win! From the example above one might think that the first player always subtracts the nim-sum from one pile. This is not true, as it can be seen from the following scenario of the same game: A 2 2 2 1 B 3 1 1 1 C 4 4 4 4 D Nim − sum 7 0102 = 210 7 0002 = 010 4 0112 = 310 4 0002 = 010 Comments I take 2 from B, You take 3 from I take 1 from A! You take 1 from leaving a sum of 000, so I will win. D Not 3! C From here the game continues by symmetry, with me as the second player repeating your move and leaving pairs of equal piles. Notice that although the nim-sum was 3, I couldn’t take 3 from any pile: the first two piles do not contain so many chips, while removing 3 from one of the last two piles would uneven the first digit of the dim-sum (in base 2). Winning strategy for such games. In conclusion, the goal is to identify disjoint subsets L and W (the subset of the losing and winning positions, respectively) of the set of all the positions such that: (1) The final position belongs to L; (2) From any position belonging to W there is a move that takes you into a position belonging to L; (If you are in a winning position then you can choose a move that leaves your opponent in a losing position.) 6 (3) Any move made from a position belonging to L takes you into a position belonging to W . (The fact that someone is in a losing position means that, whichever move he chooses, his opponent will be able to win.) These sets, once determined, allow you to decide who has the winning strategy: if the initial position is in W then the first player has the winning strategy. If the initial position is in L then the second player has the winning strategy. II. Games with ties 9. Black and White are playing double move chess, which is like chess where each player takes turns moving twice. White is the first to move. Prove that if White is smart, he cannot lose. Solution: Suppose B has a winning strategy. In this case, on his first move, White moves one of his knights to any of the two possible squares, then, on his second move, he moves it back to its initial position. Now all the pieces are in their initial position, but White has become the second player, hence he must have a winning strategy, contradiction! 10. A game is played on a 23 × 23 board. The first player controls two white chips which start in bottom-left an the top-right corners. The second player controls two black ones which start in the bottom-right and the top-left corners. The players move alternately. In each move a player can move one of the chips under control to a vacant square which shares a common side with its current location. The first player wins if the two white chips are located on two squares sharing a common side. Can the second player prevent the first player from winning? Solution: Initially, the four chips determine a rectangle, with chips of the same color at opposite corners. After a move by the first player from such a position, there is no victory since the two white chips are in different rows and different columns. Moreover, the four chips will no longer determine a rectangle. However, the second player can restore this position in his move. Thus there is no victory for the first player. Practice problems 1. In a row there are 2010 bags containing money. Two thieves steal alternately one of the bags situated at the two ends of the row. Suppose that both thieves know the amount of money to be found in each bag. Prove that the first thief can insure for himself at least half of the total sum contained in the bags. Solution: Color the bags alternately in black and white. The first player can 7 compute the sum of the money to be found in the black bags, call it ”the black money” (!), and the sum of money to be found in the white bags (”white money”). He can decide to take the black money or the white money, whichever amount is larger. Here is the strategy that allows him to do that. Suppose he decided to take home the white bags. Whenever he is on turn, the first thief has the choice between two bags that are situated at the two end of a row containing an even number of bags. Therefore he has to choose between a black and a white bag. He always takes the white one. The second thief has the choice between two black bags. Whichever he chooses now, eventually he will take home the other one as well. The second thief never has access to any of the white bags. 2. The numbers 1 through 20 are written on a circle. Two players erase, alternately, 3 numbers each. If the last two numbers are neighboring ones then the first player loses. If they are not, he wins. Find the winning strategy of the second player. Solution: The two players move on three turns each. Let us pair up the numbers as follows: (1,2), (3,4), ... , (19,20). If at his first turn, the first player erases three numbers from three different pairs, the second player will erase their pairs, leaving 7 complete pairs. If the first player completely erases a pair and erases one more number from a second pair, then the second player erases the pair of the erased number and completely erases another pair, leaving 7 complete pairs. The second player proceeds similarly at his second turn, preserving 4 complete pairs, and again at his last turn, insuring a complete pair remains unerased. 3. A coin is placed in a lower-left corner of a chessboard. Players A and B play the following game: A starts the game, and on their turn a player moves the coin to a position that is immediately to the top, right, top-right, top-left, or down-right of the position where the coin is currently placed. The player who makes the last move wins. Who has the winning strategy, and what is the strategy? Solution: Say the rows of the chessboard are, from bottom to top, 1,2,...,8, and the columns, from left to right, are a,b,...,h. The last move is moving to the upperright corner (h8). Being on move when the coin is there is clearly a losing position. Then g7, g8 and h7 are winning positions (because from there one can move to h8). Then f8 and h6 are losing (one has to move to one of positions g7, g8, h7 which are winning positions for the opponent). If follows that e8, e7, f7, g6, g5 and h5 are winning (one can move to f8 or h6 which are losing positions to the opponent). Then d8, f6 and h5 are losing positions as one can only move to winning positions. Continuing in this way, we decide for each of the 64 squares of the chessboard, whether it is a winning or a losing position. For this game, we find that the losing positions are the squares that have both an even row number and an even column number (columns b,d,f,h). Since this does not include the initial 8 position, the player with the winning strategy is player A. His first move should be on b2. 4. Two piles of candies contain 20 and 21 candies, respectively. A move consists of eating all the candies from a pile and dividing the other pile into two non-empty piles, not necessarily equal ones. Two children move alternately. The one who can not move loses. Who wins? Solution: Let’s start from the end of the game and identify the winning and the losing positions. We shall designate by (a, b) the situation in which the player on turn finds a candies in one pile and b in the other. (b, a) means the same. Clearly (1,1) is a losing position. Then (n, 2), are winning positions (can eat the n and divide the 2). (3,1) is also losing (must eat the 1, which leads to (1,2) which is winning (for the opponent)). Continuing in this manner, it is easy to guess that the set of the losing positions is the set of pairs of odd positive integers. Let us prove that. We shall check the three properties the losing set has to fulfill: (1) the final position is a losing position (Indeed, (1,1) has both its coordinates odd.) (2) from any winning position you can move into a losing position. Indeed, a winning position has at least one even coordinate. Eat the candies from the other pile, then divide the pile containing an even number of candies into two piles with an odd number of candies each. (3) from a losing position one can only move to winning positions. Indeed, it is impossible to move from one losing position to another: whichever pile one eats up, the remaining pile has an odd number of candies and can not be divided into two piles with an odd number of candies each. Since the initial position, (20,21), is a winning one, the first player has a winning strategy: he always eats the candies from the odd pile, and divides the even pile into two piles containing an odd number of candies each. 5. The game starts with the number 60. At each move one subtracts from the current number one of its positive divisors. Two players move alternately. The one who obtains 0 loses. Which player has a winning strategy and what is this strategy? Solution: The winner is the player who obtains number 1. We’ll show that player A can always win and that the winning positions are those with odd numbers. Whenever A has to subtract a divisor of an even number, he can subtract 1, and leave B with an odd number. Because A starts from an even number, 60, B will have to subtract from an odd number, whose divisors are only odd numbers, so he’ll leave A with an even number. By repeating this procedure, A will always be left with an even number, so he can always obtain an odd number. Finally, the last number he will leave to B is 1, so A will win. 9 6. The game starts with the number 60. At each move one subtracts from the current number one of the positive divisors of 60 that is less than the current number. Two players move alternately. The one who obtains 0 wins. Which player has a winning strategy and what is this strategy? Solution: The losing positions are the multiples of 7. Indeed, inheriting 0 means I have just lost, so the final position is a losing position. From a multiple of 7 one cannot get to another multiple of 7 by subtracting a divisor of 60 because the difference of two multiples of 7 is a multiple of 7 which cannot be a divisor of 60. Therefore from losing positions one can only move to winning positions. From a winning position (a number that is not a multiple of 7) one can always get to a multiple of 7 by subtracting its non-zero remainder at the division by 7. Indeed, all the possible non-zero remainders are divisors of 60. Thus the conditions (1), (2), (3) of the set of the losing position are satisfied. Since 60 is not a multiple of 7, the first player has a winning strategy which consists always to leave his opponent with a multiple of 7 (his first move is to subtract 4, thus leaving 56 to his opponent.) 7. Start with several piles of chips. Two players move alternately. A move consists in splitting every pile with more than one chip into two piles. The one who makes the last move wins. For what initial condition does the first player win and what is his winning strategy? Solution: It all depends on the largest pile. The losing positions are those in which the player on turn finds the largest pile to have 2n − 1 chips for some positive integer n. Indeed, the final position is a losing position: it is the one with all the piles containing one chip. From a losing position, a move cannot get you to another losing position. Indeed, when splitting the pile with 2n − 1 we obtain a pile with more than 2n−1 − 1 chips, so the largest pile obtained cannot have 2k − 1 chips for any integer k. Finally, from any winning position there is a move bringing the opponent to a losing position. Indeed, if the largest pile does not have 2n − 1 chips, it will have between 2m and 2m+1 − 2 for some m. Then I divide each of the piles having between 2m and 2m+1 − 2 into a pile of 2m − 1 and another (smaller or equally small) pile. Every other pile can be divided such that the pile with 2m − 1 remains the largest. Therefore the conditions (1), (2), (3) that the set of the losing position must satisfy are met, so the initial condition for the first player to win is that the largest pile does not have a number of chips that is 2n − 1. His strategy: always leave to the opponent the largest pile to have 2n − 1 chips for some n. 8. 2002 cards with the numbers 1,2,3,...,2002 written on them are put on a table face up. Two players in turns pick up a card from the table until all cards are gone. The player who gets the last digit of the sum of all numbers on his cards larger then his opponent wins. Who has a winning strategy and how one should play to win? (Tournament of the Towns, 2002) 10 Solution: The First Player (FP) wins. Let us pair all the cards (numbers): we pair k with 1000 + k, k = 1, ..., 1000. Also we pair 2001 with 2002. So, in each pair save the last one both cards have the same last digit. FP starts and picks up 2002. From this moment his strategy is to pick up the other half of the pair chosen by the Second Player (SP). So, eventually SP is forced to pick up 2001. If cards are not gone, then FP takes any card, leaving for SP to pick up the other half of the pair. At the end FP has the sum ≡ 2 (modulo 10) and SP has the sum ≡ 1 (modulo 10). 9. Alice and Bob play the following game with a 2011 × 2011 table: for each of her moves, Alice paints a previously unpainted 2 × 2 square (i.e. 4 unit squares) green; for each of his moves, Bob paints a single unit square that is not previously painted red. In the beginning no squares are painted. Alice starts the game and the players alternate turns. Once Alice is not capable of making another move, Bob paints all the remaining squares red. If the number of green squares is greater than the number of red squares, the winner is Alice. Otherwise the winner is Bob. Is it possible for Bob to win the game, no matter how Alice plays? Solution: Bob has a winning strategy in this game: Let us paint in black all squares whose both coordinates are even. There are 1005 · 1005 black squares. In each of his moves Bob needs to choose one black square and paint it in red. Alice will always have to paint exactly one of the black squares, and with this strategy of Bob, the game will last exactly 1005 · 1005 moves. The number of squares painted 1005 · 1005 + 1 = 2010 · 1005 + 2 which is strictly smaller than in green will be 4 · 2 2011 · 2011 . This guarantees Bob a victory. 2 10. Players A and B alternately move a knight on a 2010 × 2010 chessboard. Player A makes only horizontal moves, i.e. such that the knight is moved to a neighboring row, while B makes only vertical moves. Initially player A places the knight on an arbitrary square and makes the first move. The knight cannot be moved to a square that was already visited during the game. A player who cannot make a move loses. Prove that the player A has a winning strategy. Solution: Let us denote the columns by 1, 2, . . . , 2010 and the rows by 1, 2, . . . , 2010. Each cell is characterized by its two coordinates, the row number and the column number, i.e. X(# row, # column). We place arrows on the board in the following way: look at the first two rows and place an arrow that starts from (2, 3) and ends on (1, 1), one that starts from (2, 5) and ends on (1, 3), one that starts from (2, 7) and ends on (1, 5), . . . , one that starts from (2, 2k + 1) and ends on (1, 2k − 1) and so on until we finish the rows. For the next two rows, we place an arrow that starts from (3, 2) and ends on (4, 4), one that starts from (3, 4) and ends on (4, 6), 11 . . . , one that starts from (3, 2k) and ends on (4, 2k + 2) and so on until we finish the rows. Then, we repeat the pattern on the first four rows to complete the rest of the table. But since 2010 is not a multiple of four, the pattern of the last two rows will be the one from the first two rows. Now, player A starts by placing his knight on a cell from which an arrow starts and moving in in the direction of the arrow, so it will end on the head of an arrow. Then player B can only move to the start of another arrow, and A moves to the end of that arrow. By repeating this procedure, whenever B is able to make a move, then so will be A, since each end of the arrow is unique, and cannot be reached in more than one way. Thus, whenever B can make a move, so can A, and since the game is finite (because the board is finite), player A will make the last move, so he will be the winner. 11. Action and Bonjwa are playing a game on a convex 19-gon. Each player takes turns drawing a diagonal, such that he cannot draw a diagonal that crosses a diagonal that has already been drawn. The player who cannot draw a diagonal loses. Which player has the winning strategy? Solution: Any convex n-gon can be decomposed into n − 2 triangles by drawing n−3 of its diagonals. Hence, this game will take 16 moves to finish, and the second player, the one who draws the 16-th diagonal, wins. 12. A positive integer n is written on a blackboard. Alternately, two players diminish the number written on the blackboard by subtracting a perfect square not exceeding the number written on the blackboard. The first player to obtain 0 wins. Prove that there are infinitely many values of n for which the second player has a winning strategy. Solution: Proof by contradiction. Suppose there is only a finite number of n’s for which B has a winning strategy. That is, the set of n’s for which player B can win is a finite set. Denote this set by S. Since S is finite, it has a maximal element, denoted by M . Therefore, all numbers that are greater than M do not belong to S, since M is the greatest element from S. By this, for all n > M , the player who starts has a winning strategy. If for all n > M this property is true, then it is also true for a particular value of n, larger than M . Let’s take n = M 2 + 2M . This n is larger than M , so it doesn’t belong to S. Player A will subtract an x2 from n, leaving B with n − x2 . Since n = M 2 + 2M < (M + 1)2 , we have that x ≤ M . Thus, n − x2 ≥ 2M > M , so n − x2 does not belong to S either. We know that for the values of n that do not belong to S the player who starts will win the game, and since player B is left with the number n − x2 , he will be the winner. But this contradicts our assumption, since we started with a number not contained in S, a number for which player A should have been the winner. 12 13. The game begins with the number 0. A move consists of adding to the existing number any of the numbers 1, 2, 3, ..., 8 or 9. Two players move alternately. The first to obtain 100 wins. Which player has a winning strategy and what is this strategy? Solution: Let’s analyze the losing positions. We can see that if a player has reached the number 90 and he is on move, he will lose, since no matter what number he will add, his partner will be able to reach 100. If a player has reached the number 80, no matter what he will add, his partner will be able to reach number 90, leaving him in a losing position. By the same argument, all the numbers 90, 80, . . . , 10 are losing positions. Since player one starts the game, no matter what number he will add to 0, player B will be able to reach number 10, leaving A in a losing position. Therefore, player B is the winner. 14. The game begins with the number 0. A move consists of adding to the existing number any of the numbers 2, 3, ..., 8 or 9. Two players move alternately. The first to obtain at least 1000 wins. Which player has a winning strategy and what is this strategy? What if the game begins with the number 1? Solution: This problem is similar to the previous one, regarding the method of identifying the losing positions. Let’s observe that if a player reaches the number 990 or 989, then no matter how much his opponent is going to add, he is going to win, because here we cannot use the number 1. By the same argument as before, all the numbers 990, 989, 979, 978, 968, 967, ..., 11, 10 (the multiples of 11 and multiples of 11 minus 1), are losing positions for the player who is on move. Therefore, no matter what number the player A adds, B can reach a losing position for A, so B is the winner. For the second part of the problem, the first player adds 9 at the first time, and leaves B at a losing position, and repeats leaving him in a losing position until he wins. 15. The game begins with the number 2. A move consists of adding to the existing number any positive integer smaller then the existing one. Two players move alternately. The first to obtain 1000 wins. Which player has a winning strategy and what is this strategy? Solution: Let’s find the losing positions. If a player reaches the number 500, then his partner, who is on move, will lose, because no matter which number he will add, his partner will be able to reach 1000. If a player reaches the number 250, then no matter what number his partner adds, he will be able to reach 500, and therefore leave his partner in a losing position. By the same argument, the numbers 500, 250, 125, 62, 31, 15, 7, 3 are losing positions for the player who is on move, since no matter what he adds, his partner is able to bring him to the next losing 13 position. Moreover, one cannot reach a losing position from a losing position by only one move. Therefore, the first player adds 1 at his first move, and then brings his partner to the next losing position in each move. So player A is the winner. 16. The game begins with 1000. Alternately, two players diminish the number written on the blackboard by subtracting a power of 2 not exceeding the number written on the blackboard. The first player to obtain 0 wins. Who wins? Solution: Let’s see what the losing positions for the player on move are. 0 is a losing position. 1 and 2, any any other powers of 2, are obviously winning positions. 3 is losing (we cannot bring the opponent to another losing position). 5 is winning (we can bring the opponent to 3 which is losing). 6 is losing (can’t bring opponent to 0 or 3), and so on. We can already guess that the losing positions are the multiples of 3. Let us prove that the set of the multiples of 3 satisfies the 3 conditions the set of the losing positions must fulfill: (1) The final position is a losing position. Indeed, the final position, 0, is a multiple of 3. (2) From a winning position there is always a move that leaves the opponent with a losing position. Indeed, from a non-multiple of 3 we can always subtract the remainder, 1 or 2, of the division of the number by 3. (1 and 2 are powers of 2, so these moves are available). This leaves the opponent with a multiple of 3, that is with a losing position. (3) From a losing position one can get only to a winning position (for the opponent). Indeed, from a multiple of 3 we cannot get to another multiple of 3 because this would mean that we have subtracted a multiple of 3, and that is clearly nor a power of 2. In conclusion, the set of the multiples of 3 is the set of the losing positions. Since the initial position, 1000, is not a multiple of 3, it is a winning position, therefore the first player has the winning strategy, which consists in always leaving a multiple of 3 to his opponent. 17. Consider 9 points on a circle. Alternately, two players draw a segment (that had not been previously drawn) between two of these points. The first player to draw a segment from the last point that had not yet been used is the winner. Find the winning strategy of the first player. Solution: Whoever touches the last 3 points loses: indeed, when only 3 points from which no segment has been drawn remain, drawing a segment from one these 3 points allows the opponent to use up all the remaining points. This is true in both possible cases: when the first segment drawn from the last 3 points uses up one, or two of the 3 remaining points. The first player can insure that the player who will be the first to draw a segment from one of the 3 last points is the second player. 14 Indeed, The OTHER available moves consist in drawing segments between the 6 6×5 other points. There are = 15 such segments. (Each of the 6 points is joined 2 with the 5 others, but each segment is counted twice, once for each of its ends). Since 15 is odd, the last player to draw such a segment is player 1, so player two is the one who must attack the remaining 3 points. 18. Consider a 3 × 10 rectangle. Two players play the following game. They move alternately. One move consists in painting any 1 × 1, 2 × 2 or 3 × 3 square. It is not allowed to paint unit squares that have already been painted before. The player that can not move, loses. Which of the two players can insure his victory? Solution: The first player can insure his victory by placing a 2×2 square in columns 5 and 6. From now on he can repeat symmetrically the moves of the second player. 19. Two players alternately move a king on an m × n chessboard. The first to move on a square that had already been visited before by one of the players, loses. Which of the two players has a winning strategy? Solution: If m or n is even, the first player wins. He considers a paving of the board with dominoes and starts by moving the king to the other square of the domino. Later on, whenever his opponent moves on one square of a domino, he moves on the other square. Thus the first player always has moves as long as the second one can move. If m and n are both odd, the second player wins with a similar strategy. He considers a paving with dominoes of the surface obtained by removing the initial square of the king from the rectangle. Again, he can match each of the moves of his opponent: it is his opponent who ”begins” the new dominoes; the second player can always move to the other square of the same domino. 20. Given an 1 × n table (n ≥ 2), two players alternate the moves in which they write the signs + and − in the cells of the table. The first player always writes +, while the second always writes −. It is not allowed for two equal signs to appear in adjacent cells. The player who cant make a move loses the game. Which of the players has a winning strategy if: a) n is divisible by 2 b) n is not divisible by 2? (TST Bosnia, 2009) 21. 100 heaps of stones lie on a table. Two players make moves in turn. At each move, a player can remove any non-zero number of stones from the table, so that at least one heap is left untouched. (Empty heaps are still considered as heaps). The player that cannot move loses. Determine, for each initial position, which of the players, the first or the second, has a winning strategy. 15 K. Kokhas, Tuymaada International Olympiad, 2013, problem 1., junior’s section 16