Maths Olympiad Prep

Library / /31 of 31

Combinatorics Difficulty 7.6 National Olympiad, round 2 Prove it Italy

Problem:

In the land of Cockaigne the following solitaire game is played. One starts from a finite string of zeros and ones, and the following moves are allowed:
(i) delete two consecutive ones;
(ii) delete three consecutive zeros;
(iii) if inside the string there is the substring 01, this substring may be replaced by 100.
Moves (i), (ii) and (iii) must be performed one at a time and in succession. One wins if one manages to reduce the string to one made up of two digits or fewer.
(For example, starting from 0101 one can win by first using move (iii) on the final two digits, obtaining 01100, then playing move (i) on the two ones of this, and finally move (ii) on the three remaining zeros: in this way one obtains the empty string.)
How many, among all the 1024 possible strings of ten digits, are those starting from which it is not possible to win the solitaire?

Solutions — 2

Solution 1

Solution:

I show that the only string of ten digits starting from which it is not possible to win the solitaire is 1111100000 (five ones followed by five zeros).
Given a string I consider these two quantities:
- the number of ones,
- the total weight of the zeros, where a zero to the right of which there appear ii ones weighs 2i2^{i}. (For example each of the zeros of the string 001 weighs 2.)
Move (iii) leaves both quantities unaltered, because it does not change the number of ones and replaces one zero with two that weigh, each, half as much. To each string I therefore assign a type represented by a pair of numbers: the first is the remainder of the division by 2 of the number of ones, the second is the remainder of the division by 3 of the weight of the zeros. None of the moves, as we have already seen for move (iii), alters the type of the string. Move (ii), in fact, removes three zeros of the same weight, hence decreases the weight by a multiple of 3, and does not touch the ones. Move (i) removes a multiple of 2 of ones, however it alters the weight of the zeros to their left. Nevertheless, calling pp the weight of these zeros after the move, the weight before was 4p4p, that is, it decreased by 3p3p, a multiple of 3.
I now show that starting from a string of type (a,b)(a, b) different from (1,2)(1,2) it is possible to win. I begin by playing move (iii) as long as I can. This step must terminate because with each application of move (iii) a zero is added, yet the number of zeros cannot exceed their total weight, which remains constant. When I can no longer play move (iii), the string must be made up of 2n+a2n+a ones followed by 3m+b3m+b zeros. At this point I play move (i) nn times on the ones and move (ii) mm times on the zeros, obtaining a string of aa ones followed by bb zeros. Since the type (a,b)(a, b) is different from (1,2)(1,2) the sum a+ba+b must be less than three, hence I have won.
I call ugly the strings made up of 2n+12n+1 consecutive ones followed by 3m+23m+2 consecutive zeros: it is clear that an ugly string cannot be reduced except to an ugly string, and 100 is the shortest possible ugly string. Hence starting from an ugly string one cannot win. I will show in what follows a strategy for winning starting from strings of type (1,2)(1,2) that are not ugly. It follows that the only strings starting from which it is not possible to win are the ugly ones.
First of all, if the string - which from now on we suppose to be of type (1,2)(1,2), but not ugly - ends with three or more zeros, I apply to these move (ii) until they are reduced to fewer than three. The string so obtained will fall into one of these forms:
A - X1X1 with XX of type (0,1)(0,1)
B - X10X10 with XX of type (0,2)(0,2)
C - X100X100 with XX of type (0,0)(0,0).
I examine them separately.
In case A, I play the solitaire on XX (where I know how to win). I thus reduce XX to the string 0. In this way I have reduced my initial string to 01, and I have won.
Similarly, in case B, I reduce XX to 00, so I have brought the string to 0010. Now I win by means of the moves 001001000010010 \rightarrow 01000 \rightarrow 01 (for clarity, I write in bold the digits on which a move is played).
Case C is slightly more complicated. I observe that XX is not made up of only ones, because otherwise the starting string would have been ugly. Hence in XX I have at least one zero. Either this zero is the last digit of XX, or, by dint of moves (iii), I can modify XX so as to obtain a string with a zero at the bottom. At this point I have reduced X100X100 to the form Y0100Y0100. The type of YY must be (0,2)(0,2). As before, I play the solitaire on YY reducing it to 00. I have thus reduced my initial string to 000100. Now I win by doing 0001000010000010000000100001000100 \rightarrow 0010000 \rightarrow 01000000 \rightarrow 01000 \rightarrow 01.
Observing, now, that 1111100000 is the only ugly string of ten digits I have the claim.

Solution 2

Solution:

I claim that the only string of ten digits starting from which it is not possible to win the solitaire is 1111100000 (five ones followed by five zeros).
Step 1 I intend to show that every string can be reduced to one of the following: ,0,1,00,10,100\perp, 0, 1, 00, 10, 100 (I denote by \perp the empty string).
Given a string ss, I consider the shortest string ss' that can be obtained starting from it. Clearly ss' contains no pair of adjacent ones, so, if a one appears in it, this is found at the beginning, at the end, or in a substring 010. The third case, however, is absurd, because ss' could be shortened by means of the moves 01010001\mathbf{010} \rightarrow \mathbf{1000} \rightarrow 1 (I write in bold the digits on which a move is played). Hence ss' contains at most two ones, and one uninterrupted sequence of zeros. This, on the other hand, cannot contain more than two zeros. Hence the string ss' is one of the strings indicated above, or:
11101110000100110100110000000000110000101001000010 \begin{aligned} \mathbf{11} & \rightarrow \perp \\ 101 & \rightarrow \mathbf{1100} \rightarrow 00 \\ 1001 & \rightarrow 10100 \rightarrow \mathbf{110000} \rightarrow \mathbf{0000} \rightarrow 0 \\ \mathbf{01} & \rightarrow 100 \\ 0\mathbf{01} & \rightarrow \mathbf{0100} \rightarrow \mathbf{10000} \rightarrow 10 \end{aligned}
Step 2 I show that starting from a string ss that begins with a zero it is possible to win.
The string ss is of type 0X0X. Making use of step 1 I reduce XX to one of the listed strings. At this point I have obtained one of the following strings: 0,00,01,000,01010, 00, 01, \mathbf{000} \rightarrow \perp, 010 \rightarrow 1 (as above), 01001000010\mathbf{0100} \rightarrow 10000 \rightarrow 10.
Step 3 Starting from a string that begins with 1 one can win provided that it is not 1111100000.
I consider the case in which the string is made up of 2n+a2n+a ones followed by 3m+b3m+b zeros, with a=0,1a=0,1 and b=0,1,2b=0,1,2. Then move (iii) cannot be played, and moves (i) and (ii) have respectively the effect of decreasing nn and mm by one. I deduce that the shortest string that can be obtained is made up of aa ones followed by bb zeros. The only case in which this does not have length greater than two is with a=1a=1 and b=2b=2, which, for strings of length 10 is possible only in the case 1111100000.
There remains the case in which the string begins with nn ones, followed by mm zeros, followed in turn by a one. If nn is even, using move (i) I reduce myself to the case of step 2. If, however, nn is odd, I can make use of move (iii) to move the one to the right of the zeros toward the left, so as to reduce myself to the case in which the ones are even.
I do this as follows: I consider the substring made up of mm zeros followed by the one. Applying move (iii) to the substring 01 that is found at the bottom of this I obtain a new string that begins with m1m-1 zeros followed by a one (and then two zeros). Repeating the procedure another m1m-1 times I will have a string that begins with 10, which is what I need.

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement translated into English from it; metadata (topic, difficulty) added by this project.