Let be an integer.
We consider chips, of which are red and of which are blue. A sequence of those chips can be transformed into another sequence by a so-called move, consisting of interchanging a number (possibly one) of consecutive red chips with an equal number of consecutive blue chips. For example, we can move from to where denotes a red chip and denotes a blue chip.
Determine the smallest number (as a function of ) such that starting from any initial sequence of the chips, we need at most moves to reach the state in which the first chips are red.
Problem 2122
Official solution
Solution:
The answer is .
We will first show that . Let us count the number of times a red chip is directly to the right of a blue chip. In the final position this number equals . In the position this number equals . We claim that any move reduces this number by at most . Denote by the group of red chips and by the group of blue chips that are interchanged. Any reduction in must involve a red chip getting rid of its blue left neighbour or a blue chip getting rid of its red right neighbour. This can only happen with the leftmost chip of (if its left neighbour is blue) and the rightmost chip of (if its right neighbour is red), but not with the rightmost chip of (and its right neighbour) or the leftmost chip of (and its left neighbour). Hence is reduced by at most in any move. Therefore the number of moves necessary to change into the final position is at least .
We will now show that , i.e. that it is always possible to perform at most moves in order to reach the state in which the first chips are red. Consider the first chips. If at most of these chips are blue, we can perform one move for each chip, switching it with one of the red chips of the last chips. So then we are done in at most moves. Now suppose that of the first chips, at least are blue. Then at most chips are red. Hence it is possible to perform at most moves to reach the situation in which the last chips are red. We then perform one final move, switching the first chips and the last chips, ending in the situation in which the first chips are red. Thus, it is always possible to reach the situation in which the first chips are red in at most steps, hence .
We have now shown that and , hence as claimed.