We will solve this problem by finding the winning and losing positions. Recall that the position is called a losing position for a player, if after his move he instantly loses, or puts the game in a winning position for another player. Position is a winning one, if the player makes a move and immediately wins, or can put the game in a losing position for another player.
It is clear that the game is being played in the range l,l+1,…,m, where numbers l,m are blue and the rest are yellow. The values of these numbers are not significant, what is important is the amount of numbers in the interval. We will evaluate positions by the amount of yellow numbers. It is clear that the position containing 1 yellow number is a winning one, so the position a1=2 is a losing one. Then positions 3,4,5 are winning ones, because from each of them a player can put the opponent in a losing position a1=2. Hence, position a2=6 is a losing one.
Let us show by Mathematical Induction that all losing positions satisfy the condition: an+1=2an+2. Base of induction was tested. Let all positions from an−1+1 to an−1 be winning, and an−1 and an be losing ones. Consider the position b between an+1 and an+1−1=2an+1. Then the next player repaints blue the number that splits the interval of the length b into an and b−an−1. We have that
an≥b−an−1⇔b≤2an+1,
hence the opponent turns out to be in a losing position an.
If the player is in position an+1=2an+2, then after the division this interval into two parts the larger of them will surely be not less than an+1, i.e. is a winning one.
What is left is to find the explicit form of losing positions. Having calculated the first few members, it is not hard to guess and then prove by Mathematical Induction that an=2n+1−2 (or simply by solving a linear recursive equation).