This is Problem 1.25 from Tsitsiklis, Bertsekas, Introduction to Probability, 2nd edition.

You are handed two envelopes, and you know that each contains a positive integer dollar amount and that the two amounts are different. The values of these two amounts are modeled as constants that are unknown. Without knowing what the amounts are, you select at random one of the two envelopes, and after looking at the amount inside, you may switch envelopes if you wish. A friend claims that the following strategy will increase above $1/2$ your probability of ending up with the envelope with the larger amount:

Toss a coin repeatedly. Let $X$ be equal to $1/2$ plus the number of tosses required to obtain heads for the first time, and switch if the amount in the envelope you selected is less than the value of $X$ . Is your friend correct?

The answer given in the solution manual claims that this indeed helps, and that the probability of getting the better envelope is given by $$p = \frac{1}{2} + \frac{1}{2} P(B)$$

where $B$ is the event that $a<X<b$, with $a,b$ being the smaller and larger amount of dollars, respectively.

I do not buy this solution for the following reason: tossing a coin has nothing to do with the contents of the envelopes. You do not gain any information by doing it. You could just as well count the amount of leaves on a nearby tree instead and use that for $X$.

Similarly, opening the first envelope also gives you no useful information about the ordering relation between $a$ and $b$, so surely that's another red herring. Even if you forget the coin tossing, the probability of "winning" is still $1/2$, swap or no swap.

I suppose maybe the catch is in interpreting the following sentence: "The values of these two amounts are modeled as constants that are unknown". I take it to mean that they're just two randomly and independently generated numbers.

Am I out of my mind? Surely the solution manual is wrong.