There are 100 people standing in a line from left to right. Half of them are randomly chosen to face right (with all possible choices being equally likely), and the others face left. Then, while there is a pair of people who are facing each other and have no one between them, the leftmost such pair leaves the line. Compute the expected number of people remaining once this process terminates.
Solution
Notice that the order in which the people leave the line is irrelevant. Give each right-facing person a weight of 1, and each left-facing person a weight of -1. We claim the answer for some arrangement of these people is -2 times the minimum prefix sum. For instance: Proof. The final configuration is always of the form and the minimum prefix sum is invariant. As the final configuration has minimum prefix sum is , we are done. So, we want to find the expected value of the minimum prefix sum across all such strings of 1s and -1s. To find this, we will instead compute the equivalent value Consider the th term of this sum, and the corresponding walk from to with L corresponding to a step of and R corresponding to a step of . Consider the point at with minimal -coordinate, and reflect the remainder of the walk across . This gives a path that ends at . Noting that this is a bijection between walks from to and walks that reach , we have Adjusting for the factor of 2 we saved at the beginning, our final answer for is .