This content is not available in your language yet.
Problem 948: Left and Right
Left and Right play a game with a word consisting of L’s and R’s, alternating turns. On Left’s turn, Left can remove any positive number of letters, but not all the letters, from the left side of the word. Right does the same on Right’s turn except that Right removes letters from the right side. The game continues until only one letter remains: if it is an ‘L’ then Left wins; if it is an ‘R’ then Right wins.
Let F(n) be the number of words of length n where the player moving first, whether it’s Left or Right, will win the game if both play optimally.
The most effective way to solve this problem is to count the words where the first player loses and subtract this number from the total number of possible words, which is 2n. A word is a “losing” word for the first player if their opponent has a guaranteed winning strategy.
Through analysis of the game’s optimal strategies, we find that all losing words fall into one of three distinct, non-overlapping categories. To define them, we can “score” a word’s prefixes by starting at 0, adding 1 for each ‘L’, and subtracting 1 for each ‘R’.
L-Dominant Words
These are words where ‘L’s consistently outnumber ‘R’s. The score is always positive for every prefix.
R-Dominant Words
These are words where ‘R’s consistently outnumber ‘L’s when read from right to left. They are the mirror image of L-Dominant words.
Balanced L-Dominant Words
These words have an equal number of ‘L’s and ‘R’s, but the ‘L’s lead at every step until the very end. The score is positive for every proper prefix and zero for the full word. This can only occur when n is even.
To make these abstract rules concrete, we can visualize words as paths on a grid. Imagine starting at the origin (0,0). For each letter, we take one step:
An ‘L’ is a step to the right.
An ‘R’ is a step up.
The main diagonal line, y=x, represents a perfect balance between ‘L’s and ‘R’s. The three types of losing words create distinct visual patterns in relation to this diagonal.
This connection is powerful because counting these paths is a classic problem in combinatorics with well-known formulas.
L-Dominant Words (N1)
The number of paths that stay below the diagonal is given by a central binomial coefficient.
N1=(⌊2n−1⌋n−1)
R-Dominant Words (N2)
By symmetry, the number of these paths is the same.
N2=N1=(⌊2n−1⌋n−1)
Balanced L-Dominant Words (N3)
The number of these Dyck paths for a word of length n=2k is the (k−1)-th Catalan number.
N3={0C2n−1if n is oddif n is even
The Catalan numbers are defined by Cm=m+11(m2m).