Heads Up Dan Baczkowski Sarah Brown Rose Kneen Alison Reichert Sponsor: Professor J. Neuzil Kent State University 1. INTRODUCTION In this paper we examine an impartial combinatorial game we call Heads Up. This game is played using a string of coins where two players alternately choose a heads up coin, remove it and flip over any adjacent coins. The game ends when there are not any heads up coins left. We will be using the normal play rule as defined in, Winning Ways for your mathematical plays, [Berlekanp et.al. 2001] “the player that is unable to move loses.” For example, a simplified version of a Heads Up game is played as follows: Let H denote a heads up coin and T denote a coin facing tails up. Given the string of coins THTH: Player one has two moves: Taking the first heads up coin yields the result H + HH. (See Figure 1) 1 (Notice the given string is now divided into two smaller strings. We will denote this break in the string with the addition symbol.) Player two now has three possible moves. Suppose player two chooses the first H. The result is now just HH. Then player one moves say, choosing the first H. The result is now just T. It is now player two’s turn. Since there not any heads up coins remaining and by the normal play rule, player two loses the game. Taking the second heads up coin yields the result THH. (See Figure 1) Player two has two possible moves. Suppose player two chooses the second H. This results in TT. The game is over and player one loses by the normal play rule. Suppose player two chose the first H. This results in H + T. Player one will take the H and win the game by the normal play rule. Figure 1 THTH H + HH 0 + HH T THH H+T 0 H+T TT 0 From this illustration it is now clear that different choices of moves generate different results. Our objective is to calculate the 2 values of strings of coins in an effort to decide upon the best possible move, and ultimately a way to win the game. So, how can you win this game? What are some winning moves? What is the value of a particular string of coins? We develope some theorems to help calculate the answers to these questions for some unique and rather complex strings of coins. These theorems are stated and explained in Sections 3, 4, and 5. This impartial coin game originated from a solitaire coin game called Solitaire on a Circle. This game can be found on the website, www.cut-the-knot.com/SimpleGames/Csolitare.shtml. We took this one player game that is won by removing all coins and manufactured it into a different type of game with different rules and values. We decided to name our new game Heads Up because a play is made on a heads up coin. In addition to Heads Up, we also developed a variation of the Heads Up game. This variation of the game is explained in Section 6. Other coin games can be found on the cut-the-knot website and in the book Fair Game[Guy 1989] on pages 59 to 65. More impartial and take and break games can be found in the book Winning Ways for your mathematical plays on pages 53 through 117. 2. Preliminaries Throughout this paper we will be using some of the basics of impartial games. We would like to briefly explain some of the basics. If you would like to examine these theories further, please refer to Fair Game by Richard K. Guy. All impartial games can be given a value, which is called a NIM value (*n). Let G be an impartial game if the NIM value of G is *n, then n is called the nimber. Note that nimbers are always 3 non-negative integers. It is important to note that for any impartial game which is not equal to *0, there is a winning move for the next player. Bouton’s theorem [Bouton 1901] says that if we have a game G that is equal to the sum of two smaller games G1 and G2 then we can add the NIM values of G1 and G2 to obtain the NIM value of G. We can do NIM addition via a binary method. First we write the nimbers in binary. We then add the place columns modulo 2. The result is the nimber x and the NIM value of G is *x. See the following illustration. *5 + *7 5 in binary: 101 7 in binary: 111 101 + 111 010 2 in binary is 010 so *5 + *7 = *2. It is easy to see that *n + *n = *0 for all n. See chart 1 for a sample of nimber sums. 4 Chart 1: Sum of Nimbers *1 *2 *3 *4 *5 *6 *7 *1 *0 *3 *2 *5 *4 *7 *6 *2 *3 *0 *1 *6 *7 *4 *5 *3 *2 *1 *0 *7 *6 *5 *4 *4 *5 *6 *7 *0 *1 *2 *3 *5 *4 *7 *6 *1 *0 *3 *2 *6 *7 *4 *5 *2 *3 *0 *1 *7 *6 *5 *4 *3 *2 *1 *0 To figure out the NIM value of most games we use the Sprague-Grundy theorem [Grundy 1939, Sprague 1935-36]. First we write down all of the possible plays from the game in set notation. We then find the value of each individual play. Finally, the NIM value of the whole game is the mex of the set, which is the least nimber, which is not in the set. See the following illustration. mex{ *0, *2, *4} = *1 mex{ *1, *2, *4} = *0 Now that we have looked at the basics of game theory, we can now see how they apply to our game, Heads Up. 5 Chart 2: NIM Values for Heads Up GAME POSITION PLAYABLE POSITION(S) MEX T H {} {T} = {*0} *0 *1 HH HT TT {TH} = {*0} {H} = {*1} {} *1 *0 *0 HHH THH HTH THT TTH TTT {TH, T+T} = {*0, *0} {H+T, TT} = {*1, *0} {HH} = {*1} {H+H} = {*0} {TH} = {*0} {} *1 *2 *0 *1 *1 *0 HHHH THHH HTHH TTHH THHT HTTH HTHT HTTT THTT TTTT {THH, T+TH} = {*2, *0} {H+TH, TT+T, THT} = {*0, *0, *1} {HHH, HH+T, HTT} = {*1, *1, *1} {TH+T, TTT} = {*0, *0} {H+TT} = {*1} {HTH} = {*0} {HHT, HH+H} = {*2, *0} {HTT} = {*1} {H+HT} = {*1} {} *1 *2 *0 *1 *0 *1 *1 *0 *0 *0 HHHHH HHHHT HHHTH HHTHH HHHTT HTHTH THTHT HHTHT HHTTT HTTTH HTTHT THHTH THHHT HHTTH HTTTT THTTT THHTT TTHTT HTHTT TTTTT {THHH, T+THH, HT+TH} = {*2, *2, *0} {THHT, T+THT, HT+TT, HHT+H} = {*0, *1, *0, *3} {THTH, T+TTH, HT+HH, HHHH} = {*1, *1, *1, *1} {TTHH, T+HHH} = {*1, *1} {THTT, T+TTT, HT+TH} = {*0, *0, *0} {HHTH, HH+HH} = {*0, *0} {H+HHT} = {*3} {TTHT, T+HHT, HHH+H} = {*0, *2, *0} {TTTT, T+HTT} = {*0, *1} {HTTH} = {*1} {HTHT, HTH+H} = {*1, *1} {H+TTH, TT+HH, THHH} = {*0, *1, *2} {H+THT, TT+TT} = {*0, *0} {TTTH, T+HTH, HHTH} = {*0, *0, *0} {HTTT} = {*0} {H+HTT} = {*0} {H+TTT, TT+HT} = {*1, *0} {TH+HT} = {*0} {HHTT, HH+HT} = {*1, *1} {} *1 *2 *0 *0 *1 *1 *0 *1 *2 *0 *0 *3 *1 *1 *1 *1 *2 *1 *0 *0 6 Theorems of “Lonely” H’s From looking at chart 2 you may wonder if there is are certain types of strings that follow a pattern of values. The easiest strings to find the NIM values of are the ones that have only one H. Consider the following theorem. Theorem 1 The NIM value of each of the following (and the mirror image) is *0 if n is odd and *1 if n is even. a) HTn b) HTnH c) H2TnH d) H2TnH2 in addition, e) Tn = * 0 for all n and f) H2Tn = *1 if n is even and = *2 if n is odd. We will prove (a) by induction. For the base step, notice that the value of HT0=H=*1 and HT1=HT=*0 (see chart 2). For the inductive step assume that the theorem holds for all positive values of n less than k. Notice that the NIM value of HTk is mex{HTk-1}. If k is odd, then k-1 is even, so by the induction assumption HTk-1=*1 and HTk=mex{*1}=*0. If k is even, then k1 is odd, so by the induction assumption HTk-1=*0 and HTk=mex {*0}=*1. Exactly the same proof works for (b) 7 Part (c) is also proved by induction. H2T0H = H3=*1 and H2T1H = H2TH=*0 (see chart 2) For the inductive step assume that the theorem holds for all positive values of n less than k. There are three plays from H2TkH Notice that the NIM value of H2TkH is mex{ Tk+1H, T+HTk-1H, H2Tk-1H } For k even, the first two have value *0 by parts (a) and (b) and the third has value *0 by the induction assumption. Thus the mex is *1. For k odd, All three values are are 1 and the mex is 0. The proof of part (d) is essentially the same as that of (c). For part (f), there are two plays from H2Tn so H2Tn = mex{ Tn+1, T+H Tn+1} =mex{*0,*1} = *2, if n is even and is mex{*0,*0} = *1, if n is odd This completes the proof of theorem 1. Now that we have a theorem for XTnY with X and Y equal to one of H0, H1 or H2 we need to consider what happens when we add more H’s and T’s. We would like to be able to find the value of any string combination of H’s and T’s. Our next theorem generalizes the previous theorem and allows us to find the value for more types of strings. First we need to define what type of strings we are looking at. Definition In a string of H’s and T’s, an H is “lonely” if on both sides of the H there is a T. 8 Our next theorem is about strings in which all the H’s are lonely except possibly, an H or H2 at the beginning and/or the end Theorem 2 Let G be the string XTm1HTm2H Tm3Tmk-1HTmkY where there is at least one lonely H between the X and Y and both X and Y are H0, H1, or H2. If all of the H’s between X and Y are lonely (in other words mi ≥1 for all i), then the NIM value of G is: *0 if the number of T’s in the string is odd and the value of G is *1 if the number of T’s in the string is even. Proof: In this proof we let ∑(G) denote the number of T’s in the string, i.e. ∑(G) = m1 + m2 ++mk The proof is by induction on the total number of symbols in the string. For the base case, the shortest string with at least one lonely H is THT which has vaule *1 (chart 2) and has an even number of T’s. For the inductive step, let G = XTm1HTm2HHTmkY with X and Y both equal to one of H0, H1, or H2. Assume G has at least one lonely H and assume the result is true for strings that have the correct form and are shorter than G. Note that every play from G yields a string shorter than G or a sum of two strings, each of which is shorter than G. However, some plays will increase ∑(G). I. First Case: ∑(G). is odd . It suffices to show all the plays from G have value *1 or *3. ( Then the mex will be *0) A) Playing from X or Y with m1>1. 9 If X = H then G plays to A1 = HTm1-1HTm2HHtmkY. If X = HH then G plays to either A1 = Tm1+1HTm2HHTmkY or A1 =T + HTm1-1HTm2HHTmkY Since m1>1, each possibility for A1 has at least one lonely H and ∑(A1) = ∑(G)1 therefore, by the induction assumption, A1 = *1. Note that this argument still works if X = HH and and the first H is played even if m1=1 B) Playing from X or Y with m1=1. If X = H then G plays to A1 = HHTm2HHTmkY If X = HH and the second H is played the result is T+A1 = T+HHTm2HHTmkY If A1 has a lonely H then then induction assumption implies G = *1, if not then A1 = HHTm2Y with m2 even so G = A1 = *1 by the appropriate case of Theorem 1 C) Playing the first lonely H (or last, by symmetry). In this case G plays to A1 + A2 = m -1 m -1 m m XT 1 H + HT 2 HT 3HHT kY Then ∑(A1)+∑(A2) = ∑(G) - 2 which is odd, so ∑(A1) = m1 –1 .and ∑(A2). Have opposite parity. i) If m1 –1 is odd and ∑(A2).is even then A1 = *0 ( theorem 1) and A2= *1 by the induction 10 assumption if A2 has a lonely H and by theorem 1 if A2 doesn’t. ii) If = m1 –1 is even and ∑(A2).is odd then A1 = *1 (theorem 1) and A2= *0 by the induction assumption if A2 has a lonely H and A2= *0 or *2 if A2. has no lonely H (theorem 1) Therefore A1 + A2 = *1 or *3. This last possibility occurs if m m G = XT 1HTHT 3 which plays to XTm1-1+HHTm3 D) Playing a lonely H which is neither the first nor the last. In this case G plays to A1 + A2 = XTm1HTm2HHTmj –1 H + HTmj+1 –1 HTmkY As above, ∑(A1). + ∑(A2).= ∑(G) - 2, so ∑(A1). and ∑(A2) have opposite parity. If both A1 and A2 have a lonely H the induction hypothesis implies A1 = *0 and A2 = *1, or vice versa. In either case A1 + A2 = *1 If the second lonely H is the play and m2 = 1 then A1 won’t have a lonely H and G plays to m 2 m –1 m A1 + A2= XT 1H + HT 3 HHT kY i) If A2 has a lonely H and X is not empty then, by Theorem 1 for A1 the induction assumption for A2 the parity argument implies A1 + A2 = *0 + *1 (or vice versa) ii) If A2 has a lonely H and X is empty then, A1 + A2 = *1 + *0 = * 1 (m1 even) or A1 + A2 = *2 + *1 = * 3 (m1 odd) 11 iii) If neither A1 nor A2 has a lonely H then G = XTm1HTHTHTm4Y and G plays to A1 + A2 = XTm1H2 + H2 Tm4Y Using Theorem 1 we get that one of A1 or A2 has value *1 and the other is either *0 or *2. Hence the sum is *1 or *3 Second Case: ∑(G). is even It suffices to show all the plays from G have value *0 or *2 and at least one play has value *0 ( Then the mex will be *1) A) Playing from X or Y with m1>1 or B) Playing from X or Y with m1=1 The proofs of these cases are the same as the proofs of (I-A) and (I-B) with “odd” replaced by “even” and the value of A1 is *0. C) Playing the first lonely H (or last, by symmetry). In this case G plays to A1 + A2 = XTm1-1H + HTm2-1HTm3HHTmkY Then ∑(A1)+∑(A2) = ∑(G) - 2 which is even, so ∑(A1) .and ∑(A2). have the same parity. i) If ∑(A1) = m1 –1 and ∑(A2).are both even then A1 = *1 ( theorem 1) and A2= *1 by the induction assumption if A2 has a lonely H and by theorem 1 if A2 doesn’t. ii) If ∑(A1).= m1–1 and ∑(A2).are both odd then A1 = *0 (theorem 1) and A2= *0 by the induction 12 assumption if A2 has a lonely H and A2= *0 or *2 if A2. has no lonely H (theorem 1) Therefore A1 + A2 = *1 or *3. This last possibility occurs XTm1HTHTm3 which plays to XTm1-1+HHTm3 In this case, when the second H is played we get XTm1HH+HTm3-1 which has value *1+*1 = *0. D) Playing a lonely H which is neither the first nor the last. In this case G plays to A1+ A2 = XTm1HTm2HHTmj –1 H + HTmj+1 –1 HTmkY As above, ∑(A1). + ∑(A2).= ∑(G) - 2, so ∑(A1). and ∑(A2) have the same parity. If both A1 and A2 have a lonely H the induction hypothesis implies A1 = A2 and hence A1 + A2 = *0 If the second lonely H is the play and = m2 = 1 then A1 won’t have a lonely H and G plays to A1 + A2= XTm1H2 + HTm3 –1 HHTmkY i) If A2 has a lonely H and X is not empty then, by Theorem 1 for A1 the induction assumption for A2 the parity argument implies A1 and A2 are equal and so A1 + A2 = *0 ii) If A2 has a lonely H and X is empty then, A1 + A2 = *1 + *1 = * 0 (m1 even) or A1 + A2 = *2 + *0 = * 2 (m1 odd). When the value is *2 we must find another play on the string that yields value *0, in order to make the mex 13 if G = come out to be *1. In this case G = Tm1HTH Tm3HTmkY and playing the first H yields Tm1-1H + HH Tm3HTmkY which has value 1 *1 + *1 = *0. (Using the parity) iii) If neither A1 nor A2 has a lonely H then G = XTm1HTHTHTm4Y and G plays to m 2 2 m A1 + A2 = XT 1H + H T 4Y. As above, A1 and A2 have the same parity ansd, by Theorem 1, have the same value and add to *0 unless X is empty and Y is not (or vise versa). If X is empty and Y isn’t, then playing the first H yields A1 + A2 = Tm1-1H+HHTHTm4Y Using Theorem 1 on A1 and the induction assumption on A2, A1 and A2 have the same value and add to *0. This completes the proof of Theorem 2. 4. Theorems About H’s in Blocks Lemma The string of coins THkTn= (a.).*(k mod 2) if n is odd (b.) *(2[(k+1)/3]) if n is even for k≥0 and n≥1. We use [ ] to denote the greatest integer function Note that the case where n=0 is also true and is proven in Theorem 4. Proof: First, notice that we are claiming if n is odd, then the value is always *0 or *1. Also, if n is even, then we claim the values are *(2[(k+1)/3]) which are 0,0,2,2,2,4,4,4,…,2m,2m,2m,… for k≥0. 14 So, if k equals 0 or 1 and n is even, we get 0. Also, every three consecutive values of k after k equals 0 and 1 are the same value. We start by evaluating all of the possible moves of THkTn. So, we get H + T Hk-2Tn by playing the first H, T2 + T Hk-3Tn by playing the second H, THT + T Hk-4Tn by playing the third H, TH2T + THk-5Tn by playing the fourth H, … THpT + THqTn by playing the (p+2)nd H where p+q=k-3, … THk-4T + THTn by playing the (k-2)nd, ie. the third last H, THk-3T + Tn+1 by playing the (k-1)st, ie. the second last H, and THk-2T + HTn-1 by playing the kth, ie. the last H =mex{H + THk-2Tn,…, THpT + THqTn,…, THk-2T + HTn-1} where THpT + THqTn represents all middle plays for p+q=k-3 for p,q≥0. Now, we calculate the values of these different positions and proceed by induction on k. The base case, THTn, was proved in Theorem 2. For the inductive step, we assume the lemma is true for all values less than k and prove that it holds for k. We now calculate the values of the different plays when n is odd and n is even. (I.) So, for n odd, the values are 15 position H + T Hk-2Tn T2 + T Hk-3Tn THT + T Hk-4Tn TH2T + THk-5Tn … THpT + THqTn … THk-4T + THTn THk-3T + Tn+1 THk-2T + HTn-1 mex values assumed inductively *1 + *(k-2) mod 2 *0 + *(k-3) mod 2 *1 + *(k-4) mod 2 *0 + *(k-5) mod 2 *p mod 2 + *q mod 2 *(k-4) mod 2 + *1 *(k-3) mod 2 + *0 *(k-2) mod 2 + *1 if k is odd *1 + *1 *0 + *0 *1 + *1 *0 + *0 if k is even *1 + *0 *0 + *1 *1 + *0 *0 + *1 ? ? *1 + *1 *0 + *0 *1 + *1 *1 *0 + *1 *1 + *0 *0 + *1 *0 Note that when k=2, we only use the first play, THk-2Tn, and the last play, Hk-2T + HTn-1. Note for the positions in the middle, THpT + THqTn where p+q=k-3, that if k is odd, then k-3 is even. This implies that p and q are both odd or both even, in other words, they are *1+*1 or *0+*0 which both equal *0. Now, if k is even, then k-3 is odd. This implies that one of p and q is odd and the other is even, in other words, *1+*0 which equals *1. So, if k is odd, then THpT + THqTn=*0, and if k is even, then THpT + THqTn=*1. So the mex is *0 if k is even and *1 if k is odd. (II.) So, for n even Again, we break up into two cases depending on whether k is even or odd. First, the value of the middle plays, THpT + THqTn, is *p mod 2 + *2[(q+1)/3]. The following chart gives the values for specific p and q. (1.) k is even 16 P 0 1 2 … k-9 k-8 k-7 k-6 k-5 k-4 k-3 Q *p mod 2 k-3 0 k-4 1 k-5 0 … 6 1 5 0 4 1 3 0 2 1 1 0 0 1 *2[(q+1)/3] sum 2[(k-2)/3] 2[(k-2)/3] 2[(k-3)/3] 1 + 2[(k-3)/3] 2[(k-4)/3] 2[(k-4)/3] 4 4 2 2 2 0 0 5 4 3 2 3 0 1 This alternating pattern shows the values for the middle plays. It appears that by the alternating values of *p mod 2 and by the groups of three *2[(q+1)/3] that the sums of the middle plays for k even will be every value starting from 0 to 2[(k-2)/3. Now, consider the plays of taking the first and last H, H + THk-2Tn and THk-2T + HTn-1. These values are *1+*2[(k-1)/3] and *0+*0, respectively. So, the values in the set of possible plays will consist of: *0, *1, *2,…, *2[(k-4)/3], *1+*2[(k-3)/3], *2[(k-2)/3], and *1+*2[(k-1)/3] which is the highest. We will consider the three possible cases for k. (i.) For k=3j, we use the rules for NIM addition to obtain 1+2[(k-1)/3]=1+2[(3j-1)/3]=1+2(j-1)=2j-1. This implies the next integer, 2j, is the mex. We check and see 2[(k+1)/3] =2[(3j+1)/3]=2j, too. (ii.) For k=3j+1, again we use the rules for NIM addition. We note that this is a special case. It is true that 1+2[(k-1)/3] is the highest value in the set of plays, but there are terms only missing between it and the others. We look at the last four values in the set of plays. We have 17 *2[(k-4)/3], *1+*2[(k-3)/3], *2[(k-2)/3], and *1+*2[(k-1)/3]. Note that for this case, k=3j+1, that 2[(k-4)/3]=2[(k-3)/3]=2[(k-2)/3]=2(j-1)=2j-2. Then, we have the values 2j-2, 2j-1, and 2j-2 for *2[(k-4)/3], *1+*2[(k-3)/3], *2[(k-2)/3], respectively. Notice 1+2[(k-1)/3]=2j+1. Then, we are missing the integer 2j in our set of values. Thus, 2j should be our mex, and observe it is by 2[(k+1)/3]= 2[(3j+2)/3]=2j. (iii.) For k=3j+2, using rules for NIM addition, 1+2[(k-1)/3]=1+2[(3j+1)/3]=1+2j. This implies the next integer is 2+2j which is the mex. Note that 2[(k+1)/3]=2j+2. We have just proved that for the case where k is even, the mex is *2[(k+1)/3]. (2.) k is odd p 0 1 2 … k-9 k-8 k-7 k-6 k-5 k-4 k-3 Q *p mod 2 k-3 1 k-4 0 k-5 1 … 6 0 5 1 4 0 3 1 2 0 1 1 0 0 *2[(q+1)/3] Sum 2[(k-2)/3] 1 + 2[(k-2)/3] 2[(k-3)/3] 2[(k-3)/3] 2[(k-4)/3] 1 + 2[(k-4)/3] 4 4 2 2 2 0 0 4 5 2 3 2 1 0 The set of possible plays consists of *0, *1, *2,…, *1+*2[(k-4)/3], *2[(k-3)/3], *1+*2[(k-2)/3], and *1+*2[(k-1)/3]. We will consider the three possible cases for k. 18 (i.) For k=3j, we get 1+2[(k-1)/3]= 1+2[(3j-1)/3]=1+2(j-1)=2j-1. This implies the next integer, 2j, is the mex. So, 2[(k+1)/3]= 2[(3j+1)/3]=2j, too. (ii.) For k=3j+1, again we use the rules for NIM addition. We note that this is a special case. It is true that 1+2[(k-1)/3] is the highest value in the set of plays, but there are terms only missing between it and the others. We look at the last four values in the set of plays. We have *1+*2[(k-4)/3], *2[(k3)/3], *1+*2[(k-2)/3], and *1+*2[(k-1)/3]. Now, 1+2[(k4)/3]= 1+2[(k-2)/3]=2j-1 and 2[(k-3)/3]=2j-2. Then, we have the values 2j-2 and 2j-1. Note that 1+2[(k-1)/3]=2j+1. Then, we are missing the integer 2j in our set of values. Thus 2j should be our mex, and observe it is by 2[(k+1)/3]= 2[(3j+2)/3]=2j. (iii.) For k=3j+2, using rules for NIM addition, 1+2[(k-1)/3]= 1+2[(3j+1)/3]=1+2j. This implies the next integer is 2+2j which is the mex. Note that 2[(k+1)/3]= 2[(3j+3)/3]=2j+2. We have just proved for case (1.) k is even that the mex is *2[(k+1)/3]. Thus, the lemma has been proved. ڤ Theorem 4 The string of coins HkTn= (a.) *0 if k≡0 mod 6 and n≡0 mod 2 (b.) *1 if k≠ mod 6 and n≡0 mod 2 (c.) *2[(k+1)/3] if n is odd where we use [ ] to denote the greatest integer function and for k≥0, n≥1. Proof: We start by evaluating all of the possible moves of HkTn. So, we get THk-2Tn by playing the first H, T + THk-3Tn by playing the second H, 19 HT + T Hk-4Tn by playing the third H, H2T + THk-5Tn by playing the fourth H, … HpT + THqTn by playing the (p+2)nd H where p+q=k-3, … Hk-4T + THTn by playing the (k-2)nd, ie. the third last H, Hk-3T + Tn+1 by playing the (k-1)st, ie. the second last H, and Hk-2T + HTn-1 by playing the kth, ie. the last H =mex{THk-2Tn,…, HpT + THqTn,…, Hk-2T + HTn-1} where HpT + THqTn represents all middle plays for p+q=k-3 and p,q≥0. Now, we calculate the values of these different positions and prove by induction on k. Clearly if k=0, then there are no H’s, therefore a string of T’s equals *0. The base case, HTn, was proven in Theorem 1. For the inductive step, we assume the theorem is true for all values less than k and prove that it holds for k. We now calculate the values of the different plays when n is odd and n is even. (I.) So, for n odd, we look at the case where k is odd. position THk-2Tn T + THk-3Tn HT + THk-4Tn H2T + THk-5Tn H3T + THk-6Tn H4T + THk-7Tn … HpT + THqTn … Hk-7T + TH4Tn values assumed inductively *2[(k-1)/3] *0 + *0 *0 + *1 *2 + *0 *2 + *1 *2 + *0 Sum *2[(k-1)/3] *0 *1 *2 *3 *2 *2[(p+1)/3]+ *q mod 2 … *2[(k-6)/3] + *0 *2[(k-6)/3] 20 Hk-6T + TH3Tn Hk-5T + TH2Tn Hk-4T + THTn Hk-3T + Tn+1 Hk-2T + HTn-1 mex *2[(k-5)/3] + *1 *2[(k-4)/3] + *0 *2[(k-3)/3] + *1 *2[(k-2)/3] + *0 *2[(k-1)/3] + *1 *2[(k-5)/3] + *1 *2[(k-4)/3] *2[(k-3)/3] + *1 *2[(k-2)/3] *2[(k-1)/3] + *1 *2[(k+1)/3] Note that when k=2, we only use the first play, THk-2Tn, and the last play, Hk-2T + HTn-1. We can see by the values of the sums that for k odd, the set of possible plays will consist of *0, *1, *2,…, *2[(k-4)/3]), *2[(k-3)/3]+*1, *2[(k-2)/3], *2[(k-1)/3]+*1 which is the highest. Just as proven in the lemma with three sub cases, we obtain the mex to be *2[(k+1)/3]. This is done similarly for the case when k is even. Furthermore, the proof for HkTn where n is odd is the same for THkTn where n is even. (II.) For n even, position THk-2Tn T + THk-3Tn HT + THk-4Tn H2T + THk-5Tn H3T + THk-6Tn H4T + THk-7Tn … HpT + THqTn … Hk-7T + TH4Tn Hk-6T + TH3Tn Hk-5T + TH2Tn Hk-4T + THTn Hk-3T + Tn+1 Hk-2T + HTn-1 mex How to obtain Take first H Take second H Take third H Take fourth H Take fifth H Take sixth H values assumed inductively 2[(k-1)/3] 0 + 2[(k-2)/3] 0 + 2[(k-3)/3] 2 + 2[(k-4)/3] 2 + 2[(k-5)/3] 2 + 2[(k-6)/3] Take (p+2)nd H 2[(p+1)/3] + 2[(q+1)/3] Take (k-5)th H Take (k-4)th H Take (k-3)rd H Take (k-2)nd H Take (k-1)st H Take last H 2[(k-6)/3] + 2 2[(k-5)/3] + 2 2[(k-4)/3] + 2 2[(k-3)/3] + 0 2[(k-2)/3] + 0 2[(k-1)/3] + 0 ? 21 It appears that for these set of plays, that every value equals *2i + *2j for some nonnegative integers i and j. Recall that in adding nimbers this equals an even nimber or *0 if i=j. So the next question, is it possible to get *2i + *2i = *0? We must look somewhere in the middle of the chart to find if this is possible. Really what we need to observe is the values of HpT + THqTn, *2[(p+1)/3]+*2[(q+1)/3], because the first and last plays will always be the highest values. Looking at the middle plays, we will show what happens for all possible k. (i.) k≡1 mod 6, k≡3 mod 6, k≡5 mod 6 In other words, we are looking at the case where k is odd. When k is odd that implies that k-3=p+q is even. Well, if p+q is even, then there exists a number when p=q. Then, there exists a p and q such that *2[(p+1)/3] = *2[(q+1)/3]. This implies there is a *0 in the set of plays; therefore, the mex of HkTn for n even and k odd is *1. (ii.) k≡2 mod 6 (ie. k=6j+2) and k≡4 mod 6 (ie. k=6j+4) So, let p=(k-2)/2 and let q=(k-2)/2 – 1. Then, we see that *2[(p+1)/3]=2[k/6] and *2[(q+1)/3]=2[(k-2)/6]. Now for k=6j+2 and k=6j+4, *2[(p+1)/3]=2j=*2[(q+1)/3]. So, there always exist some values in the center of the chart that give us *0. Thus we see for k≡2 mod 6 and k≡4 mod 6, the mex of HkTn for n even is *1. (iii.) k≡0 mod 6 (ie. k=6j) Note that if there does exist a *0, then it would occur at the center play or plays depending on whether there is an even or odd number of plays. This is true, because the values of HpT alternate 0,0,2,2,2,4,4,4,… and the values of THqTn alternate the reverse way. Since k is divisible by 6, k is even which implies that p+q is odd. Since p and q are integers, one of them is even and the other 22 is odd. For simplicity, let p be even and again let p=(k-2)/2, and let q=(k-2)/2 – 1 which is odd. Simple induction shows that these choices for p and q are the center values for HpT + THqTn, the middle plays. Now, it is suffice to show that if there does not exist a *0 for these particular p and q, then there does not exist a *0 in the set of possible plays. Our choice of p and q for k=6j tell us that *2[(p+1)/3]=2j and *2[(q+1)/3]=2(j-1). This implies that the two values in the center play are different even nimbers, thus the value equals a non-zero even nimber. Therefore, there is no *0 in the set of We have now proved possible plays which implies that our mex equals *0 for k≡ mod We have now proved the theorem holds for all possible cases. Theorem 4 : The NIM value for the string of coins THTHnT = (a) (b) (c) *0 when n = 0, 1, 2 *2 when n is odd n > 3 *3 when n is even n > 4 We will be using Theorem 3 and the Lemma to prove this theorem. For referencing convenience, these are the values of the two theorems being used and the one to be proved in chart format. Proof: 23 We will prove the theorem for the case when n = 0, 1, and 2 directly. Chart 2: n= 0 1 2 3 4 5 6 7 8 9 10 Theorem 3 HnT *0 *0 *2 *2 *2 *4 *4 *4 *6 *6 *6 Lemma THnT *0 *1 *0 *1 *0 *1 *0 *1 *0 *1 *0 THTHnT *0 *0 *0 *2 *3 *2 *3 *2 *3 *2 *3 Theorem 4 n = 0 THTT H + HT from Chart 2 we get: *1 + *0 = *1 mex = *0 n = 1 THTHT H + HHT from Chart 2 we get: *1 + *2 = *3 mex = *0 n = 2 THTHHT H + HHHT from Chart 2 we get: *1 + *2 = *3 or THH + TT *2 + *0 = *2 or THTT + H *0 + *1 = *1 mex = *0 x We will prove the rest of the values by induction on n. 24 (L) Base step When N=3, the mex of THTHHHT equals *2. MOVES Taking the first H: H + HHHHT Second H: THH + THT Third H: THTT + TT Fourth H: THTHT + H VALUES *1 + *2 = *3 *2 + *1 = *3 *0 + *0 = *0 *0 + *1 = *1 mex { *3, *0, *1 } = *2. When N=4, the mex of THTHHHHT equals *3. MOVES Taking the first H: H + HHHHHT Second H: THH + THHT Third H: THTT + THT Fourth H: THTHT + TT Fifth H: THTHHT + H VALUES *1 + *4 = *5 *2 + *0 = *2 *0 + *1 = *1 *0 + *0 = *0 *0 + *1 = *1 mex { *5, *2, *1, *0 } = *3. 25 (I.) Inductive step Let D(n) stand for the values of the Theorem 3. (See above chart) Let A(P) stand for the values of the conjectured theorem. (See above chart) Assume the theorem holds for all values of n > 3. When n is odd we must show that *0, *1, *3, and nimbers greater than *3 are the only attainable values from the possible moves forcing the mex to be *2. (**Notice that taking an H surrounded by H’s in the middle of the string of coins will create a total loss of three heads up coins from the string. Hence, in line four, P + Q = n – 3.) PLAY 1. Take the first H 2. Second H 3. Last H 4. Any H in the middle RESULT H + Hn+1T VALUE *1 + D(n+1) SOLUTIONS *5, *7, *9… THH + THn-2T THTHn-2T + H THTHPT + THQT *2 + *1 A(n-2) + *1 A(P) + *0 or *1 *3 *3 *0, *1, *3 When n is even, we must show that *0, *1, *2, and nimbers greater than *3 are the only attainable values from the possible moves forcing the mex to be *3. 26 PLAY 1. Take the first H 2. Second H 3. Last H 4. Any H in the middle RESULT H + Hn+1T VALUE *1 + D(n+1) SOLUTIONS *5, *7, *9… THH + THn-2T THTHn-2T + H THTHPT + THQT *2 + *0 *1 + A(n-2) A(P) + *0 or *1 *2 *2 *0, *1, *2, This completes the proof for all possible cases. ڤ Winning Strategies: Given a string of coins that might be seen in a typical game of Heads Up: THTHHHHHHT A winning move would be to take the fourth H and create a zero game. 1. Given THTHHHHHHHHHHHT If the first player takes the fifth H, and assuming both players continue making all their best possible moves, who will win the game? 6 A Variation of Heads Up In this variation of Heads Up, each player must turn over exactly one adjacent coin. For example, in the simple game H, there are no moves since there are no adjacent coins, thus H = *0. In a 27 more complicated example, the possible moves from THTTH are as follows: H + TTH from removing the first H and flipping the first T; T + HTH from removing the first H and flipping the second T; THTH from removing the last H and flipping the last T. The value of this game is *1 (see Chart 3). The following table provides the NIM values for several game positions. Table 6.1 n 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 TH n *0 *1 *1 *2 *3 *1 *1 *4 *3 *2 *4 *3 *4 *5 *2 Hn *0 *0 *1 *2 *0 *3 *1 *0 *3 *3 *2 *4 *0 *5 *6 TH nT *0 *1 *2 *0 *3 *1 *0 *3 *3 *2 *4 *0 *5 *6 *7 Based on the values from the Table 7.1, we can derive the following theorem. Theorem 5 THnT = Hn+1 Proof:We prove by induction on n. (I) Base case, n = 0. TH0T = TT = mex{} = *0 and, H0+1 = H = mex{} = *0 (II) We assume the values are true for all values ≤ n-1 and prove that it holds for n. So, the possible moves from THnT are as follows: H+ THn-1 from removing the first H and flipping the adjacent T; n-2 T+ TH T from removing the first H and flipping the adjacent H; TT + THn-2 from removing the second H and flipping the H on the left; 28 TH + THn-3T from removing the second H and flipping the H on the right; THT + THn-3 from removing the third H and flipping the H on the left; THH+THn-4T from removing the third H and flipping the H on the right; . . . THi + THn-2-iT from removing the ith H for i ≤ n-2. And the possible moves from Hn+1 are as follows: THn-1 T + Hn-1 H+THn-2 HT+Hn-2 HH+THn-2 from removing the first H and flipping the H on the right; from removing the second H and flipping the H on the left; from removing the second H and flipping the H on the right; from removing the third H and flipping the H on the left; from removing the third H and flipping the H on the right; . . . THi + Hn-1-i from removing the ith H for i ≤ n-1. Obviously, THi = THi for all i, and THn-1 = H + THn-1 since H = *0. Further, by the inductive step, Hn-1-i = THn-2-i, since n-1-i > n-2-i. Therefore, T HnT = Hn+1 • 29 References [Berlekanp et.al. 2001] E. R. Berlekamp, J. H. Conway, R. K. Guy Winning Ways for Your Mathematical Plays A. K. Peters, Natick MA, 2001 [Bouton 1901] Charles Bouton, Nim, a game with a complete mathematical theory, Ann. Of Math., Princeton(2),3,p 35-39. [Guy 1989] R. K. Guy, Fair Game: How to Play Impartial Combinatorial Games, COMAP, Arlington, MA, 1989 [Grundy 1939] P. M. Grundy, “Mathematics and Games” Eureka 2 (1939) p 6-8, Reprinted in Eureka 27 (1964) p 9-11 [Sprague 1935-36] R. Sprague, “Uber Mathematische Kampfspeile” , Tohoku Math J. (1935-36) ,p 438-444 30