Place or Take
Problem
You are playing a one-player game with two opaque boxes. At each turn, you can choose to either "place" or "take". "Place" places $1 from a third party into one box randomly. "Take" empties out one box randomly and that money is yours. This game consists of 100 turns where you must either place or take. Assuming optimal play, what is the expected payoff of this game? Note that you do not know how much money you have taken until the end of the game.
Original Problem Link: https://www.quantguide.io/questions/place-or-take
Solution
Before touching any algebra, note that the boxes are opaque and we learn nothing until the game ends. So there is no information to adapt to — a strategy is just a fixed sequence of 100 moves, decided in advance. All we have to do is find the best sequence.
Step 1: What does the optimal sequence look like?
First, let us convince ourselves of the shape of the answer: all the places come first, then all the takes.
Consider the case where we are allowed at most one take. It obviously has to be at the very end. Any place made after the take does nothing for us — it adds to a box that is never emptied again, so that dollar can never become ours. Money placed before the take, on the other hand, is money the take can sweep.
Now build up by induction. Say we want to add one more take. Ignore the take we have already committed to the last turn, and look at the remaining turns as a fresh instance of the same problem. By the same reasoning as above, the new take belongs at the end of that block — i.e. immediately before the take we set aside.
Repeating this, all the takes get pushed to the back and all the places to the front. So the optimal strategy is
and the only thing left to choose is , the number of takes.
Step 2: Expected value of each take
Let be the number of takes, so we make places first.
After the placing phase, box holds dollars and box holds .
First take. We empty a uniformly random box, so
Note what happens to the boxes: whichever box we emptied is now zero, and no more money is ever placed. So from here on the state is always "one box holds everything that is left, the other is empty". The expected money still sitting in the boxes is
Second take. We again pick a box at random. With probability we pick the empty one and get nothing, and with probability we pick the one holding the remainder :
The same argument repeats: each take collects half of what is left in expectation, and therefore halves what remains. So
Step 3: Sum the GP
The trade-off is now explicit. More takes means more chances to collect, but every extra take costs us a dollar of principal.
Sanity check. There is a second route to the same formula. Follow a single placed dollar: it sits in its box until that box happens to be swept, and each take picks its box with probability , independently. So a dollar placed before all takes is collected with probability . Summing over the dollars gives directly. This also re-proves Step 1: a dollar's chance of being collected only grows with the number of takes that follow it, so every place belongs before every take.
Step 4: Maximize over
Treat as continuous and differentiate:
Setting this to zero:
Multiplying through by :
This is transcendental, so plot the two sides on Desmos — (a gently falling line) against (an exploding exponential). They cross once, at
Step 5: Round to an integer
has to be a whole number, so check the two candidates on either side of :
(and , for comparison)
So the optimum is : place 94 times, then take 6 times.