Quant puzzles, solved step by step
- Puzzles
- 100
- Traced to a firm
- 71
- Topics
- 12
- Hard
- 30
033There are 21 matches on the table. Two players alternate taking 1, 2 or 3 matches, and whoever takes the last match loses. Would you rather go first or second, and what is your strategy?Quant tradingProp trading firms
Try it first
First or second?
Show the worked solution
Go second. The player facing 1, 5, 9, 13, 17 or 21 matches loses against good play, and 21 is on that list. Whatever your opponent takes, take 4 minus that, so every round removes exactly 4. They then face 17, 13, 9, 5 and finally 1, and are forced to take the last match.
How do you find the losing positions?
Start from the end of the game, the way you would plan the last few stops of a journey before the first. With 1 match in front of you, you must take it and lose. With 2, 3 or 4, you take enough to leave exactly 1 and win. With 5, every move leaves 2, 3 or 4, each a winning spot for the other player, so 5 loses. A position is losing when every move from it hands your opponent a winning position, and here that happens every 4 matches: 1, 5, 9, 13, 17, 21.
Counting down from 21, the positions 21, 17, 13, 9, 5 and 1 lose for the player about to move; moving second and answering each take of k with 4 minus k keeps the opponent on those positions until they must take the last match. Why does answering with 4 minus k always work?
Your opponent can take 1, 2 or 3; you can always take 3, 2 or 1 in reply. The pair of moves removes exactly 4 matches whatever they chose, so you control the count at the end of every round. From 21 the rounds end at 17, 13, 9 and 5, and then your opponent faces a single match. The number 4 is the maximum take plus one; that is where the period comes from.
A short check you can say aloud: the game has only 21 positions, and marking each as winning or losing from the bottom up, a position wins if any move reaches a losing one, reproduces the list 1, 5, 9, 13, 17, 21. If the pile had been 20, you would go first and take 3 to leave 17. This type of game has a backward inductionSolving a game by working out the best move at the last step first, then the step before, back to the start. solution, and the interviewer mainly wants to hear you build it from the end.
Where candidates lose it
The usual loss is playing forward: taking a few matches and hoping to spot the pattern mid-game. Under time pressure that becomes guessing. Work back from one match and the period of 4 appears in three steps.
The other slip is copying the rule for the version where taking the last match wins. There the losing spots are multiples of 4, and 21 means you should go first and take 1. Read which way the last match counts before you answer.
What the interviewer asks next
- What if taking the last match wins instead?
- What if each player may take 1 to 4 matches?
- What if there are two piles and you may take any number from one pile?
040Game: roll a fair die and receive its face in rupees; whenever you roll a six you also roll again and add the next result, with no limit on repeats. What is the expected payout of the game?Quant tradingOptions market making
Try it first
What is the game worth?
Show the worked solution
Rs 4.20. Every roll pays its face, averaging 3.5, and with probability 1/6 the game then starts again, worth the same V. So V = 3.5 + V/6, which gives (5/6)V = 3.5 and V = 4.2. A second route agrees: the number of rolls averages 1/(5/6) = 1.2, and each averages 3.5, so 1.2 x 3.5 = 4.2.
Why write the game in terms of itself?
A pass that gets a free renewal each time you use it on a lucky day is worth its first use plus, on lucky days, another pass exactly like it. When a game can repeat with no memory, the value after the repeat is the value of the whole game, so one equation replaces an infinite sum. Here, after a six you are paid 6 and then face precisely the game you started with, worth V.
Faces 1 to 5 end the game, and a six pays 6 and restarts the same game, so V = (5/6) x 3 + (1/6) x (6 + V), which solves to V = 4.2; the number of rolls averages 1.2, and 1.2 x 3.5 gives the same 4.2. How do you set up the equation without slipping?
Condition on the first roll. With probability 5/6 it shows 1 to 5, averaging 3, and you stop. With probability 1/6 it shows 6: you collect 6 and then expect V more. So V = (5/6) x 3 + (1/6) x (6 + V), which simplifies to V = 3.5 + V/6, and V = 3.5 x 6/5 = 4.2. The form 3.5 + V/6 is worth saying: every roll pays 3.5 on average, and one time in six you get another go at the whole game.
The relationshipV expected payout of the game, in rupees 3 average of faces 1 to 5 6 + V payout after a six: the six itself plus a fresh game What it says in wordsThe game's value is one roll's average plus a one-in-six chance of the whole game again.Check by counting rolls. The chance a roll triggers another is 1/6, so the number of rolls averages 1/(1 - 1/6) = 1.2, and each roll averages 3.5 whatever came before, giving 1.2 x 3.5 = 4.2. Summing the series directly, k sixes and then a stop, also lands on 4.2, but the recursion gets there in two lines. The limitation to name if asked to price it: 4.2 is a fair value for one play; the payout has a long right tail, since two sixes in a row, one time in 36, already pay at least 13.
Where candidates lose it
The usual loss is capping the chain: adding one re-roll, 3.5 + 3.5/6 = 4.08, and stopping. The re-roll can be a six too, and the question says there is no limit.
The second is writing V = 3.5 + V without the 1/6, which has no solution, or forgetting the six itself is paid before the restart. Condition on the first roll and write each branch in full.
What the interviewer asks next
- What would you pay to play if a six pays nothing but gives a re-roll?
- What is the probability the payout exceeds 12?
- Now a one ends the game with zero payout. What is the game worth?
046I offer you an even-money bet on either of two events. Which is more likely: at least one six in four rolls of one die, or at least one double six in 24 rolls of a pair of dice? Which side do you take, and what is your edge per rupee?Quant tradingProp trading firms
Try it first
Which event is more likely?
Show the worked solution
At least one six in four rolls is more likely, 51.8% against 49.1%, so take that side. The chance of no six in four rolls is (5/6)^4 = 625/1296, and the chance of no double six in 24 rolls is (35/36)^24. At even money the six earns about 3.5 paise per rupee staked; the double six loses about 1.7 paise and needs 25 rolls to become favourable.
Why does the obvious 2/3 come out the same for both bets?
The old gamblers' shortcut, sometimes called the rule of proportion, says that if one try succeeds with chance p, then n tries succeed with chance n times p. Four rolls at 1/6 gives 4/6, and 24 rolls at 1/36 gives 24/36, the same 2/3. This puzzle is the one the Chevalier de Mere is said to have brought to Pascal, because his winnings disagreed with the shortcut. Adding chances only works for events that cannot happen together, and two sixes in four rolls can. The shortcut counts a hand with two sixes twice, and that is why it breaks down completely after seven rolls, where it would claim 7/6.
A family checking the weather forecast makes the same slip: three days at a 40% chance of rain do not make a 120% chance of a wet weekend. The right question is the chance that it stays dry on all three days, 0.6 cubed, about 22%, so rain on at least one day is about 78%.
At least one six in four rolls of a die happens 51.8% of the time and at least one double six in 24 rolls of two dice happens 49.1% of the time, so the first bet clears even money and the second does not, although the rule of proportion gives two thirds for both. How do you compute each chance in your head?
Go through the complement. At least one success is one minus the chance that every try fails, and independent failures multiply. No six in four rolls is (5/6)^4 = 625/1296, which is just under one half, so the six wins 671/1296, or 0.5177. For the double six, use the approximation that (1 - 1/36)^24 is close to e to the power -24/36, which is e^(-2/3), about 0.513; the exact figure is 0.5086, so the double six comes up only 0.4914 of the time.
The relationship5/6 the chance one roll is not a six 35/36 the chance one roll of two dice is not a double six e^{-24/36} the approximation (1 - 1/n)^m close to e^{-m/n} when 1/n is small What it says in wordsThe chance of at least one success is one minus the chance of failing every time.What edge does each side carry at even money?
At even money you win a rupee with probability p and lose a rupee otherwise, so the expected gain per rupee is p - (1 - p) = 2p - 1. The six gives 2 x 0.5177 - 1 = +0.0355, about 3.5 paise per rupee, while the double six gives -0.0172. That is a thin edge: over 100 bets of Rs 1 the expected profit is about Rs 3.55 with a standard deviation near Rs 10, so it takes thousands of bets before the edge shows reliably. The break-even for the double six is the smallest n with (35/36)^n below one half, which is 25 rolls, giving 0.5055. The limitation: the dice must be fair and independent; any bias in the dice swamps an edge this size.
Where candidates lose it
The common loss is multiplying tries by chance and declaring the two bets equal at 2/3. The interviewer is waiting to see whether you notice that the formula can exceed one, which proves it is wrong, and switch to the complement.
The second is getting the probabilities right and then picking a side without stating the edge. On a trading desk the question is not only which side but how much it is worth: about 3.5 paise per rupee for the six, and a loss of about 1.7 paise for the double six.
What the interviewer asks next
- How many rolls of three dice do you need before at least one triple six is better than even money?
- I offer you 11 to 10 on the double six in 24 rolls. Do you take it?
- How much of your bankroll would you stake per bet on the single six?
049Which is larger, e to the power pi or pi to the power e? Prove it without a calculator.Quant researchQuant trading
Try it first
Which way does it go?
Show the worked solution
e^pi is larger: about 23.14 against 22.46 for pi^e. Take logs of both and divide by e x pi, which turns the question into comparing ln e / e with ln pi / pi. The function ln x / x rises up to x = e and falls after it, so its value at e beats its value at any other number, pi included. Undo the steps and the order holds.
How do you turn two awkward powers into one comparison?
When two people race on different tracks, you compare them by converting to the same distance. Here the base and the exponent both differ, so convert each number into a common form. Take logarithms and divide by e x pi: e^pi against pi^e becomes ln e / e against ln pi / pi, the same function evaluated at two points. Logs and division by a positive number both preserve order, so whichever side wins the new comparison wins the original.
The relationship? the unknown direction of the inequality, the same at every step \ln x / x the function whose largest value settles the question What it says in wordsTaking logs and dividing by e times pi turns the question into one function compared at e and at pi.Why is ln x / x largest at e?
Differentiate: the derivative of ln x / x is (1 - ln x) / x squared. It is positive while ln x is below 1 and negative once ln x passes 1, so the function climbs until x = e and falls after. Its largest value, 1/e, occurs only at x = e, so ln pi / pi must be smaller, and therefore e^pi beats pi^e. Equivalently, x^(1/x) peaks at e with value 1.4447, while pi^(1/pi) is 1.4396.
The curve x to the power 1/x reaches its maximum of 1.4447 at x = e and has already fallen to 1.4396 at x = pi, so raising both values to the power e times pi gives e^pi = 23.14, larger than pi^e = 22.46. There is a second proof that needs no calculus beyond one inequality. For any x other than zero, e^x is greater than 1 + x, because the exponential curve lies above its tangent line at zero. Put x = pi/e - 1, about 0.156: then e^(pi/e - 1) is greater than pi/e, so e^(pi/e) is greater than pi, and raising both to the power e gives e^pi greater than pi^e. Give that one if the interviewer asks for a proof without derivatives.
Notice how close the race is: the two values of x^(1/x) differ by only 0.0050, because pi sits near the flat top of the curve. That is why rough estimation is risky here and a proof is needed: 23.14 and 22.46 differ by about 3%. The same argument settles a whole family: for any two numbers a and b with e at most a, and a less than b, a^b is greater than b^a, which is why 3^4 = 81 beats 4^3 = 64.
Where candidates lose it
The common loss is answering pi^e because pi is the bigger base, or trying to estimate both numbers to a decimal and getting lost in the arithmetic. The gap is only about 3%, so mental estimates can land either way.
The second is proving it backwards: assuming the answer and manipulating until something true appears, without checking each step preserves the inequality. Say out loud that taking logs and dividing by the positive e x pi keep the order.
What the interviewer asks next
- Which is larger, 2^3 or 3^2, and why does the argument not apply to 2 and 4?
- Find all pairs of distinct positive integers with a^b = b^a.
- Which is larger, 99^100 or 100^99?
052You roll a fair die repeatedly until the first six appears. What is the expected sum of all the rolls before the six, not counting the six itself?Quant tradingProp trading firms
Try it first
Pick your answer before working it.
Show the worked solution
15. The first six takes 6 rolls on average, so 5 rolls come before it. Each of those rolls is known not to be a six, so it is uniform on 1 to 5 and averages 3. Expected count times expected size gives 5 x 3 = 15. The check: all rolls including the six average 6 x 3.5 = 21, and taking off the final six leaves 15.
How many rolls come before the six?
Picture waiting at a stop where each minute a bus arrives with chance 1 in 6. On average you wait 6 minutes, and the sixth is the one where it comes. The number of rolls up to and including the first six is geometric with mean 1/p = 6, so the number strictly before it is 5. That is the first factor. Most candidates get this far; the loss comes in the second factor.
A typical game has five non-six rolls before the stopping six, and each of those rolls averages 3 because it is known not to be a six, so the expected sum is 5 x 3 = 15; the full-sum check of 6 x 3.5 less the final 6 also gives 15. Why is each of those rolls worth 3 and not 3.5?
Because you are told something about them. Every roll before the stopping six is, by definition, not a six, so its distribution is the die conditioned on 1 to 5, which averages exactly 3. Using 3.5 gives 17.5, the most common wrong answer. It is the same slip as averaging the income of people who did not win a prize with everyone's income, prize winners included.
The relationshipN the number of rolls before the first six, mean 5 X | X not 6 a roll known not to be a six, uniform on 1 to 5 E the expected sum from any fresh start What it says in wordsExpected count times the expected size of each piece gives 15, and the one-step recursion confirms it.How do you check 15 a second way in the room?
Two checks, both fast. The recursion: with chance 5/6 the next roll is not a six, adds 3 on average and you are back where you started, so E = (5/6)(3 + E), which solves to 15. The full sum: Wald's identityFor a stopping time N that does not look into the future, the expected sum of N independent identical draws equals E[N] times the mean of one draw. applied to every roll including the six gives 6 x 3.5 = 21, and the last roll is always exactly 6, so the rest must average 15. Say both; the second one shows you understand why the conditional mean is 3.
Where candidates lose it
The trap is 17.5: the right count, 5, multiplied by the unconditional mean of a die. The interviewer set the question up so that the rolls you sum are selected, not random, and wants to see whether you notice.
The second trap is multiplying 6 rolls by 3.5 and stopping at 21, which includes the six the question told you to exclude. Say what is counted before you multiply.
What the interviewer asks next
- What is the expected sum if you do count the six?
- What is the expected sum of the rolls before the first time you roll a 1 or a 2?
- What is the expected number of rolls until two sixes in a row?
054With interest rate r and volatility sigma, check which of these satisfy the Black-Scholes equation: V = S, V = K e^(-r(T-t)), and V = S squared. Explain what the ones that pass are as trades, and fix the one that fails.Quant researchOptions market making
Try it first
Which candidates pass?
Show the worked solution
V = S and V = K e^(-r(T-t)) satisfy it; V = S squared does not. The first is the stock itself and the second is a zero-coupon bond paying K at T, both traded assets that must earn r. S squared has gamma 2 and leaves (r + sigma squared) S squared unbalanced. Multiplying by e^((r + sigma squared)(T-t)) fixes it, which is the price of a claim paying S squared at expiry.
What is the equation actually saying?
Think of a household budget rule that any fair arrangement must obey: over one day, what you hold must earn the same as the same money in a savings account, once the risk has been hedged away. The Black-Scholes equation says that for a delta-hedged position, time decay plus the gamma term plus the financing of the hedge equals r times the value. Written in {term('greeks', 'Theta is the change in value with time, delta with the stock price, and gamma is the change in delta with the stock price.')}, it is theta + half sigma squared S squared gamma + r S delta = r V. A candidate price passes only if its greeks balance that line.
The relationshipdV/dt theta, the change in value as time passes d2V/dS2 gamma, how fast delta changes dV/dS delta, the hedge ratio r the interest rate What it says in wordsA hedged position's decay, convexity and financing must add up to exactly the interest the money would earn.Substituting each candidate's theta, delta and gamma, the stock and the zero-coupon bond balance the equation exactly, S squared leaves a surplus of (r + sigma squared) S squared, and S squared times e^((r + sigma squared)(T - t)) balances it again. Why do the two that pass make sense as trades?
Anything that is itself a traded, self-financing asset must satisfy the equation, because the equation is only the statement that no hedged position earns more than r. V = S is just holding the stock: delta 1, no gamma, no decay, and the financing term rS matches rV. V = K e^(-r(T-t)) is a zero-coupon bond: it does not depend on S at all, and its value grows at exactly r as it approaches T. The stock and the bond are also the two pieces of the call price formula, which is why the check is worth a minute.
Why does S squared fail, and how do you repair it?
S squared has gamma 2, so the half sigma squared S squared gamma term adds sigma squared S squared, the delta term adds 2rS squared, and subtracting rV leaves (r + sigma squared) S squared with nothing to cancel it. A convex payoff gains from every move, so a fair price for it has to decay over time to pay for that gain, and S squared on its own has no decay. Try V = S squared times f(t): the equation forces f' = -(r + sigma squared) f, so the price of a claim paying S squared at T is S squared e^((r + sigma squared)(T - t)). At S = 100, r = 5%, sigma = 20% and one year, that is about 10,942, not 10,000, and the extra is the value of volatility.
Where candidates lose it
Candidates often say every function of S and t is a solution, or differentiate correctly and then fail to say what the passing solutions are. The question asks for the trades: the stock and a bond. Naming them turns a calculus check into finance.
The second trap is the sign of theta for the bond. Its value rises as t approaches T, so theta is +rV; getting that sign wrong makes the bond appear to fail.
What the interviewer asks next
- Which power of S, S to the a, satisfies the equation with no time factor?
- What is the price today of a claim paying log S at expiry?
- Why does the drift of the stock not appear anywhere in the equation?
057Z is a standard normal random variable. What is the expected value of max(Z, 0), and what does that number tell you about the price of an at-the-money option?Quant researchQuant trading
Try it first
Roughly what is E[max(Z, 0)]?
Show the worked solution
1/sqrt(2 pi), about 0.399. Only the positive half contributes, and there you integrate z times the normal density. Because the derivative of the density is minus z times the density, the integral is simply the density's height at zero. So an at-the-money call on a normally distributed move is worth about 0.4 standard deviations of that move: roughly 0.4 x S x volatility x the square root of time.
Why is the answer not zero, and not one half?
Think of a shop that keeps the profit on good days and closes, losing nothing, on bad days. Its average day is better than the average of all days, because the bad days have been floored. max(Z, 0) throws away every negative outcome and keeps every positive one at its full size, so its mean is the positive half's contribution alone: the integral of z times the density from zero to infinity. That is not one half, which is only the chance of being positive; the size of each positive draw matters too.
The shaded area under z times the normal density on the positive side is exactly 0.399, the same as the density's peak height, so an at-the-money call on a normal move of one standard deviation is worth about 0.4, which for a Rs 1,000 stock at 20% volatility over three months is about Rs 40. How do you do the integral in one line?
Notice what differentiating the density gives. The derivative of e to the minus z squared over 2 is minus z times itself, so z times the density is the negative derivative of the density, and its integral from 0 to infinity is the density at 0 minus the density at infinity. The density at infinity is zero, and at zero it is 1/sqrt(2 pi). No tables, no substitution: the answer is 0.3989. Doubling it gives E[|Z|], about 0.798, which is the at-the-money straddle.
The relationshipphi(z) the standard normal density, e^(-z^2/2) / sqrt(2 pi) phi(0) the height of the density at its peak What it says in wordsThe expected positive part of a standard normal equals the height of the bell at its centre.What does it say about an at-the-money option?
If the stock's move to expiry is roughly normal with standard deviation S x vol x sqrt(T), an at-the-money call pays the positive part of that move. So its value is about 0.4 x S x vol x sqrt(T), the rule of thumb option traders use to price at-the-money options in their heads. For a Rs 1,000 stock at 20% volatility and three months, sqrt(T) is 0.5 and the call is about 0.399 x 1,000 x 0.2 x 0.5 = Rs 39.9; the Black-Scholes value with zero rates is Rs 39.88. The rule loosens for long maturities and high volatilities, where the lognormal skew matters.
Where candidates lose it
The two fast wrong answers are 0, from averaging Z itself, and 0.5, from confusing the probability of a positive draw with its expected size. Both come from answering before writing down what is being averaged.
The second loss is getting 0.399 and not connecting it to options, which is why the question is asked on a trading desk. Say the 0.4 rule in the same breath.
What the interviewer asks next
- What is E[max(Z, 1)]?
- What is the variance of max(Z, 0)?
- Using the rule, what is an at-the-money straddle worth on a Rs 500 stock at 30% volatility for one month?
058A bet pays 2 to 1 and wins 40% of the time. What fraction of your bankroll does the Kelly criterion stake on each bet, what long-run growth rate does that give, and what happens if you bet twice that fraction?Quant tradingOptions market making
Try it first
At twice the Kelly stake, what happens to long-run growth?
Show the worked solution
Stake 10% of the bankroll; that grows wealth by about 0.97% a bet, and twice Kelly grows it by only about 0.07%. Kelly is edge over odds: (2 x 0.4 - 0.6)/2 = 0.1. The growth rate is 0.4 ln(1.2) + 0.6 ln(0.9). At 20% the losses compound away almost the whole edge, and above about 20.4% the bankroll shrinks in the long run despite a positive expected value.
Why not bet as much as possible on a good bet?
Think of a shopkeeper with a profitable weekly sale who puts the entire shop's stock on it every week. The average week is good, but one bad week ends the business. With repeated bets, wealth multiplies, so what matters is the average of the log of each outcome, not the average outcome, and a big loss costs more in log terms than an equal gain earns. This bet has a clear edge: each rupee staked returns 0.4 x 2 - 0.6 = Rs 0.20 on average. The question is how much of that edge survives compounding at each stake size.
How do you get the Kelly fraction and the growth rate?
Stake a fraction f. A win multiplies wealth by 1 + 2f, a loss by 1 - f, so the growth per bet is g(f) = 0.4 ln(1 + 2f) + 0.6 ln(1 - f). Set the derivative to zero: 0.8/(1 + 2f) = 0.6/(1 - f), giving f = 0.1. The Kelly stake is the edge divided by the odds, (bp - q)/b = 0.2/2 = 10%. Plugging in, g = 0.4 x 0.1823 - 0.6 x 0.1054, about 0.97% a bet, so the typical path doubles its wealth roughly every 71 bets.
Long-run growth peaks at 0.97% a bet at the Kelly stake of 10%; half Kelly keeps 76% of that growth, twice Kelly keeps almost none of it at 0.07%, and any stake above about 20.4% shrinks the bankroll over time. The relationshipb the net odds, 2 to 1 p, q the chances of winning and losing, 0.4 and 0.6 g(f) expected log growth of wealth per bet at stake f What it says in wordsKelly maximises the expected log of wealth, and its stake is the edge divided by the odds.Why is overbetting so much worse than underbetting?
Near the peak the growth curve is close to a parabola, so the cost of a sizing error grows with its square. Half Kelly gives up only about a quarter of the growth, while twice Kelly gives up nearly all of it, and three times Kelly shrinks wealth at about 2.6% a bet. Real edges are estimated, not known, so a trader who thinks the win rate is 40% but faces 35% is already overbetting at the full 10%. That asymmetry is why desks size at a fraction of Kelly.
Where candidates lose it
The first trap is stopping at the positive expected value and saying bet big. The interviewer is testing whether you know that repeated multiplicative bets are judged by log growth, where volatility itself costs money.
The second is misremembering the formula as p - q or as p/b. Derive it from the log growth in two lines; it is faster than recalling and it proves you know where it comes from.
What the interviewer asks next
- What is the Kelly fraction for an even-money bet that wins 55% of the time?
- Why might a trader deliberately stake half Kelly?
- How would you size two independent simultaneous bets like this one?
059We play a coin game. I pick a sequence of three heads or tails, you then pick a different sequence after seeing mine, and we flip a fair coin until one of the two sequences appears; whoever's comes first wins. I pick HHH. What do you pick, and how often do you win?Quant tradingProp trading firms
Try it first
Which reply to HHH is best?
Show the worked solution
Pick THH; you win 7 times in 8. HHH can only win if the first three flips are all heads, which has chance 1/8. In any other run, the first HHH is preceded by a tail, and that tail with the next two heads spells THH, which is completed one flip before HHH. So THH wins every game except the one that opens with three heads.
Why is this not a fair race between two 1/8 sequences?
Think of two runners on the same track where one always starts one step ahead of the other on the only route to the finish. Their speeds are identical but the race is not even. In a race between patterns, what matters is not how often each appears but which one tends to appear first, and that depends on how the patterns overlap. THH is built from HHH's own first two heads with a tail placed in front, so it ambushes HHH whenever HHH has not already won at the start.
HHH wins only when the first three flips are heads, a 1/8 chance; in every other run the first HHH is preceded by a tail, so THH is completed one flip earlier and wins the remaining 7/8 of games. How do you prove 7/8 without a Markov chain?
Look at the first time HHH appears. If it does not start at flip 1, the flip immediately before it must be a tail, because otherwise an earlier HHH would already have appeared. That tail plus the first two heads of the HHH is THH, finished one flip before HHH. So HHH wins only if flips 1 to 3 are heads, chance 1/8, and THH wins otherwise: 7/8. The proof is one sentence, and interviewers want to hear it rather than a transition matrix.
What is the general lesson for the second mover?
This is Penney's gameA coin sequence race in which the second player, choosing after seeing the first, can always pick a sequence that wins more than half the time., and the second player always has an edge because the winning relation among three-flip sequences is not transitive: every sequence has another that beats it. The recipe: take the opponent's first two flips, and put in front of them the opposite of the opponent's second flip. Against HHH that gives THH at 7/8; against HTH it gives HHT at 2/3. In trading terms, a strategy that looks as good as any other in isolation can still lose systematically to one designed around it.
Where candidates lose it
The trap is answering that every sequence has probability 1/8, so the game is fair, or picking TTT because it has nothing in common with HHH. Both treat the race as independent draws of three flips rather than a stream where patterns overlap.
The second trap is reaching for a four-state Markov chain and running out of time. The tail-before-the-run argument settles it in one sentence; set up the chain only if asked about a harder pair.
What the interviewer asks next
- I pick HTH. What do you pick, and how often do you win?
- What is the expected number of flips to see HHH, and to see THH?
- Why can no three-flip sequence be the best first choice?
062A symmetric random walk starts at 0 and moves up or down by one each step with equal probability. What is the expected number of steps until it first reaches +3 or -3?Quant researchQuant trading
Try it first
What is the expected number of steps to hit +3 or -3 from 0?
Show the worked solution
9 steps. Let E(k) be the expected steps left from state k. Each step costs one and lands on a neighbour with equal chance, so E(k) = 1 + (E(k - 1) + E(k + 1))/2, with E(3) = E(-3) = 0. The solution is E(k) = (3 - k)(3 + k): 9 from 0, 8 from plus or minus 1, 5 from plus or minus 2. A symmetric walk needs about the square of the distance to travel it.
Why is the answer not 3?
Think of someone pacing a narrow corridor, choosing left or right at random with every step. They do reach a wall eventually, but they spend most of their time doubling back. A random walk with no drift covers distance like the square root of time, so covering a distance of 3 takes about 3 squared steps, not 3. The answer 3 would only be right if the walk always moved in one direction. The structure to name in the room is a first-step recursion on the state, which turns the question into seven unknowns with simple links between them.
The expected number of steps left is 9 from the centre, 8 one step out, 5 two steps out and 0 at the walls, tracing the parabola 9 - k squared, which is the product of the distances to the two walls. How do you solve the recursion quickly?
Use symmetry first: E(1) = E(-1) and E(2) = E(-2). Then three equations remain. From 2: E(2) = 1 + (E(1) + 0)/2. From 1: E(1) = 1 + (E(0) + E(2))/2. From 0: E(0) = 1 + E(1), because both neighbours are worth E(1). Substituting gives E(1) = 8 and E(0) = 9, and every value matches the product of the distances to the two walls. The second differences of E are all minus 2, which is why the answer is a parabola: each step must remove exactly one unit of expected time.
The relationshipE(k) the expected number of steps left from state k 1 the step just taken E(plus or minus 3) = 0 the walls, where the walk stops What it says in wordsOne step plus the average of the two neighbouring states, solved, gives the product of the distances to the walls.How do you check 9 a second way?
Use a martingaleA process whose expected next value, given everything so far, equals its current value: a fair game.. Squaring the position and subtracting the number of steps gives a fair game, because each step adds exactly 1 to the expected square. At the moment the walk stops its square is exactly 9, so the expected number of steps must also be 9. The same argument handles uneven walls: starting between -a and +b, the expected time is a times b. The cousin result is the hitting probability: from +1, the walk reaches +3 before -3 with probability 2/3, the distance to the far wall over the total width.
Where candidates lose it
The trap answers are 3, from treating the walk as if it marched to a wall, and infinity, from a half-remembered fact that a symmetric walk on the whole line takes infinite expected time to reach a given level. With two walls, escape is certain and fast.
The second loss is setting up seven equations and grinding them. Use symmetry to cut to three, then state the product rule and check it with the squared-position argument.
What the interviewer asks next
- Starting at 0, what is the expected time to hit +2 or -4?
- From +1, what is the probability of reaching +3 before -3?
- With only one wall at +3 and no lower wall, what is the expected time to reach it?
