Problem Set 1
Problem Set 1
Mustafa Otyrmay
November 10, 2021
1 Introduction
Here’s the problem set taken from actual quantitative trading interviews or equivalent books. They are
divided into 3 subsections: easy (though some are still tricky), harder and challenging. The problem set is
basically a mix of probability, game theory, brain teaser questions. Here are sources used:
• Brainteasers and math puzzles set by a professor from Stanford
• Detailed description of Jane Street interview process with problems
• Glassdoor interviews
Note: ”guessed right” is defined as guessing a color that is the color of the hat. ”guessed wrong” is
defined as guessing a color that is NOT the color of the hat. It’s neither ”right” nor ”wrong” if ”don’t know”
is guessed.
Problem 2. You have one 10-sided and one 6-sided dice. Both dice are thrown. You play a game where
you need to guess the sum of the numbers on dice. If you guessed correctly, you will get the same amount
in dollars. What is your bet?
1
Problem 3. Two people each bids a number before throwing a 30 faced die. Whoever gets closer to the
number wins and wins the amount of money equal to the number they throw. e.g I bid 15 and you bid 16.
the die lands on 10 then I win 10 from you. What’s the best strategy (will you play first or second) and the
expected payoff.
Note: Second player can’t bid for the same number. Also, in case two players are equally close to the
number on die we would decide the winner by flipping a coin.
Problem 4. How to simulate 15-sided die using a 12-sided die?
Problem 5. You roll a 6-sided die (numbers from 1-6) until the total sum of numbers becomes at least
300. What’s the most likely result of the sum (you can make some reasonable assumptions).
Problem 6. We’re playing a game, and 2 dice are rolled. One of the dice you see, one of the dice I see. If
we don’t know the other person’s dice, but we make a bet on what the sum of the dice are, and the person
closer to the real answer gets the amount (in pips) (if we’re the same distance apart we split the amount),
what’s your optimal strategy to win? Each person knows the other person knows the other dice, and you
reveal your bet at the same time.
Problem 7. You play against a player. Fair coins are flipped until HHT or HTT occurs. Player 1 wins if
it is HHT. Player 2 wins if it is HTT.
(a) Which one is more likely to win?
(b) I choose to bet on HHH. Is there a 3-sequence that ”beat” it ?
Remark: If you are started calculating probabilities, stop now. There’s a much easier approach.
Problem 8. You select a number between 1 and 100 and the one that tells the bigger number has to pay
the lower number to the other player. The player 2 says a random number between 1 and 100. What is
the optimal strategy? A third player comes in the game. Now the bigger number has to pay to the 2 other
players the number that each one has told. We suppose that the third player is smart. How to beat him?
Problem 9. The dice game mentioned above: You roll a 100-sided die. You can choose to accept the value
of this roll for $x, where x is the value showing. You can choose to re-roll the die for $1. What is the strategy
you employ and what is the fair value of the game?
Problem 10. There is some amount of money in a box, determined in the following way: 200 fair coins are
flipped. Let the number of heads that come up be H. The amount of money put in the box is H(100−H)/100.
How much would you pay for the box?
Problem 11. You throw a fair coin one million times. What is the expected number of strings of 6 heads
followed by 6 tails?
2
Problem 15. One hundred people line up to board an airplane. Each has a boarding pass with assigned
seat. However, the first person to board has lost his boarding pass and takes a random seat. After that,
each person takes the assigned seat if it is unoccupied, and one of unoccupied seats at random otherwise.
What is the probability that the last person to board gets to sit in his assigned seat?
Problem 16. N points on the circle. Draw a chord between every pair of points. What is the number of
intersections (suppose each pair of chords intersect at a ”unique” point)?
Problem 17. Let α ∈ [0, 1] be an arbitrary number, rational or irrational. The only randomizing device is
an unfair coin, with probability p ∈ (0, 1) of heads. Design a game between Alice and Bob so that Alice’s
winning probability is exactly α. The game of course has to end in a finite number of tosses with probability
equal to 1.
Problem 18. Person A has a 20-sided dice and person B has three 6-sided dice. They both roll their dice
and whoever gets a bigger number/sum of numbers wins the game. Is it a fair game? Same game with one
more player C who has a 20-sided dice. Is this new game fair? (all dice are fair; a 20-sided dice has number
1,2,. . . , 20 on each of its 20 sides)
Problem 19. Person A and B are going to play a coin toss game. There is an initial score 0, and whenever
a head/tail appears, the score +1/-1. Repeating the coin toss until one wins, that is, when the score reaches
+2/-2, A/B wins the game. There is also an initial stake $1 for the game and person A has the option to
double the stake every time before a coin toss. When one person wins the game, the other player needs to
pay the amount of dollars on the stake to the winner . The question is: if you are person A, what is your
strategy and what is your highest expected payoff of the game?
Problem 20. There are N people in the class playing ”Secret Santa”. Everyone is given a paper with
the name of the person (uniformly at random) they need to give a present (let’s assume that one can get
himself/herself). Call a set of people p1 , p2 , ..., pk group, if p2 is p1 ’s Santa, p3 is p2 ’s Santa, ... p1 is pk ’s
Santa. What is the expected number of such groups?
Problem 21. Suppose a molecule stands at an integer point m on the real axis. Let p > 12 be a probability
that the molecule moves by 1 to the right, and by 1 to the left otherwise. The molecule will get absorbed if
it reaches the origin. What is the probability that the molecule gets absorbed?
Problem 22. A demon mathematician captures 100 programmers for his evil experiment. The program-
mers will be imprisoned and unable to communicate with each other. In the beginning, the demon will
randomly assign each programmer a bit ”0” or ”1”. Every day, every programmer needs to submit an in-
teger to the demon, and the demon will notify the programmer that submits the smallest integer. If more
than one person submits the smallest integer, the demon would randomly choose one to notify.
After 200 days, every programmer needs to independently guess which bit is the majority among all the
bits assigned to the programmers. They need to choose one from the three possibilities:
If all of them are correct, they’ll be freed; and if any one of them is wrong, all of them will be killed. The
programmers can discuss a strategy prior to the experiment. You may assume that all of the programmers
know each other. Please design a strategy that guarantees them to be freed.
Problem 23. 3000 Apples to be transported from city A to city B, between which the distance is 1000
miles. When there is apple on the truck, one apple disappears as every mile driven. Assume unlimited
gasoline, how many apples maximum can be transported to city B? Given your answer is x, what market
would you make on a lottery: you win 10 dollars if your answer is correct, otherwise 0 dollar. (All calculation
must be done without pen and paper)
3
Problem 24. Several people (including you) are playing the game where each of you bet a number. The
one with the highest number wins (though others can’t see/hear what others bet). In case when numbers
are equal, the winner is chosen at random. After that, player who won has to pay the number he bet, but
he will get the amount of money that is equal to the number of Tails after flipping (fair) 200 coins.
(a) What is the best strategy?
(b) Suppose you are playing against one player who chooses a random number on [0, 100] uniformly. How
would you bet?
(c) What if his betting range now become [0, 70] (still uniform)?
(d) You are playing million rounds against one player. You could one of the following:
1. Cooperative: You both can communicate and tell how will you play for the next million rounds (no
lies).
2. Competitive: You can’t communicate, but whenever one of you loses the round one will be told the
winner’s bet.
Which strategy would you choose and why?
Problem 26. 100 pirates needs to allocate 100 identical laptops among them. Their democratic system
works as follows: All pirates are ranked by their seniority. First, the most senior pirate (called ”Majority
leader”) propose an allocation plan that states exactly how many laptops each pirate would get. The 100
pirates would vote on the plan (no filibuster) and it would pass if more than or equal to half pirates voted
for it. If it passes, pirates take their laptops and go home. If it fails, the one who proposed the plan (the
most senior pirate in this case) would be killed, and then the second most senior pirate would take the place
of ”Majority leader” and propose his plan. We repeat the same process above in the order of seniority until
someone’s plan is passed.
Assume every pirate makes his decision based on the following priorities:
1. He doesn’t want to die
2. Given he’s not going to die, he would prefer to get as many laptops as possible.
3. Given he’s going to get the same number of laptops, he would prefer as many other pirates to die as
possible.
Assume every pirate is smart and knows other pirates are smart and they know that other pirates knows that
they are smart and etc. What will happen? i.e. whose proposal will be passed and what is the proposal?
Problem 27. What happens if there are 435 pirates (but still only 100 laptops)? This is qualitatively
more difficult than the case with 100 pirates. (There is nothing magic about 435. It’s just the number of
Representatives.)
Problem 28. In a certain matriarchal town, the women all believe in an old prophecy that says there will
come a time when a stranger will visit the town and announce whether any of the men folk are cheating on
their wives. The stranger will simply say ”yes” or ”no”, without announcing the number of men implicated
or their identities. If the stranger arrives and makes his announcement, the women know that they must
follow a particular rule: if on any day following the stranger’s announcement a women deduces that her
husband is not faithful to her, she must kick him out into the street at 10AM the next day. This action is
4
immediately observable by every resident in the town. I is well known that each wife is already observant
enough to know whether any man (expect her own husband) is cheating on his wife. However, no woman
can reveal that information to any other. A cheating husband is also assumed to remain silent about his
infidelity.
The time comes, and a stranger arrives. He announces that there are cheating men in the now. ON the
morning of the tenth day following the stranger’s arrival, some unfaithful men are kicked out into the street
for the first time. How many men are kicked?
Problem 29. You need to open the safe with 6 digit pin code. You also have a hacking device that helps
you in the following way:
1. If you guessed ≥ 3 digits, the device lights up green.
2. Otherwise, it lights up red. Once you guessed the pin code, the safe will open immediately (so no
button pressing, etc. is needed). Come up with the strategy to open the safe as quickly (on average)
as possible.
Problem 30. You have n > 1 numbers 0, 1, ..., n − 1 arranged on a circle. A random walker starts at 0 and
at each step moves at random to one of its two nearest neighbors. For each i, compute the probability pi
that, when the walker is at i for the first time, all other points have been previously visited, i.e., that i is the
last new point. For example, p0 = 0.
Problem 31. Choose, at random, three points on the circle x2 + y 2 = 1. Interpret them as cuts that divide
the circle into three arcs. Compute the expected length of the arc that contains the point (1, 0).
Problem 32. A box contains n balls of n different colors. Each time, you randomly select a pair of balls,
repaint the first to match the second, and put the pair back to the box. What is the expected number of
steps until all balls in the box are of the same color (that’s fairly difficult).
Problem 33. A chocolate bar consists of 100 squares in a single row. To break it into pieces, we number the
squares from left to right from 1 to 100 and then use a random process, as follows. For every i = 1, 2, . . . 100,
we pick a random number Xi from 1 to 100 and look for the square Xi .
• If the square is still on the bar, we break the bar into two pieces at that right boundary of that square,
and remove the piece on the left. (Note that, if Xi = 100, then we are essentially removing the whole
of the remaining chocolate.)
• If the square is not there (because it is in a piece that has already been removed), then we just remove
the leftmost square that is still there.
Note that the number of pieces created by this process can be anywhere from 1 (if X1 = 100) to 100 (if every
Xi equals i). Which of these possible values has the highest probability?
2 Solutions
Problem 1. Answer: 7/8
Suppose there is some strategy which guarantees correct guessing in at least 7 cases. Suppose, WLOG for
’RRR’ the first man guesses correctly, but then we would have guessed ’BRR’ incorrectly. Same with ’BBB’.
Contradiction.
Strategy for p = 43 : if wise man sees same colors of hats on both wise men, he guesses the other color,
otherwise passes. Obviously, it doesn’t only when all wise men have hats of the same color.
5
[12, 16]. So we could immediately omit [1, 10] as possible candidates (because 11 is clearly better). You may
also note that 11 is actually the best bet because decrease of P [X = x] cannot be ”recovered” from increase
of x, thus making 11 our answer.
Remark: I know it is not rigorous and we need to quantitatively show, but in interview it is better to first
show your approach and plan to calculate rather that calculation itself.
Problem 3. Suppose one (player A) of us bets X and other (player B) bets Y such that X < Y . Let M =
[ X+Y
2 ]. Clearly, if the die lands on [1, M], A would be the winner and receive W (A) = Sum(1, M )M/30 − δ
on average, otherwise B would be the winner and receive W (B) = Sum(M, 30)(30 − M )/30 − δ on average (δ
is used to consider to omit considering extra cases when there is a center between X and Y ). So it is better
to choose a player with higher expected winning. But if you were to play the first, the second player would
most likely find another number with higher pay except for the case when Sum(1, X) ≈ Sum(X + 1, 30),
which is 21. So the answer is betting 21 as the first player.
Problem 4. You roll the die three times until 3 numbers become different. There are 12 · 11 · 10 = 12 · 110
different outcomes, so we could map 110 outcomes to 1 outcome in a 12-sided die.
Problem 5. Let px − probability of getting x as the sum of the numbers on dice after throwing it multiple
times. Clearly, your answer should somehow involve those px . You could note a linear recurrence relation
px = 16 (px−1 + ... + px−6 ), x ≥ 6, but you would die calculating p300 , so you need some shortcut. You might
assume that px are approximately the same for large x. So p299 ≈ p298 ≈ p297 ≈ ... ≈ p294 = 16 . Now you
can see why 300 is the answer (why? more points to reach 300).
Problem 7. Suppose player with HTT wins. How the string of flips looked like? ”...X H T T”, but if X
was ’H’, then HHT would occur earlier, so in that case the probability of HTT winning is less than 12 . Of
course, you might argue ”What if HHT wins in 3 flips?”, etc. but at that point you could easily handle those
cases and rigorously prove it.
Problem 9. Let X− the random value of the game deploying the optimal strategy. Then, clearly my
strategy for some threshold h would look something like this : if the die lands on a number at least h + 1,
then I would I accept it and stop the game, otherwise re roll. Then, we have the following equation :
h 100 − h 101 + h
E[X] = (E[X] − 1) + ( ).
100 100 2
Now you can describe E[X] as a function of h and find the maximum
Problem 10. This is a good problem on you knowledge of linearity of expectation and variance. Clearly,
H - binomial distribution. So,
1
E[H] = 200 · = 100
2
and
1 1
V ar(H) = 200 · · (1 − ) = 50
2 2
So,
1 1 1
E[H(100 − H)/100] = E[H] − E[H 2 ] = E[H] − (V ar(H) + E[H]2 ) = − .
100 100 2
Problem 11. Let’s call such substrings ”beautiful”. Let X - number of beautiful substrings in a random
string. Instead of calculating the answer using cumbersome calculations, it is easier to break down the
problem into ”simpler things”. Let Ij − random indicator variable that is 1 if there is a beautiful substring
starting at j. Obviously, E[Ij ] = 2112 , so by linearity of expectation:
106 − 11
E[X] = = 244.14.
212
6
Problem 12. (a) By multiplication rule,
99 98 1 1
... =
100 99 2 100
(b) Let’s show the answer , f (n, k), when we have n locked safes. Trying out smaller cases, you may guess the
answer to be f (n, k) = nk . Fortunately, it is the case. Let’s show it. Take one opened safe : key inside that
safe is either a key from a locked or unlocked safe. If it is a key from an unlocked safe, we could ”imagine”
having k − 1 unlocked safes by ”sticking” that those safes. Same way, if it is a key from an locked safe,
we still have k unlocked safes (because opened locked safe now serves as an unlocked one). So we have the
following recursion:
Problem 13. Remark: This is a very good problem. It was on the actual 3rd round, so it’s better to
try to do it by yourself. Let suppose we picked x, and we are trying to maximize the expected winning
E[W in|X = x] = EX [W in] by picking x. Let Y be a number that pairs up with you and W, Z is opponent
pair’s numbers. One way to tackle this problem is to denote g(x, y) = EX [W in|Y = y] and noting that
5
X
EX (W in) = 0g(x, y)P [Y = y]
y=1,y6=x
And you can try and see that you can find g(x, y) and P [Y = y] using simple combinatoric approach (try
it), but you’ll have lot’s of crap to work with (expanding stuff and considering two cases for y). It is doable,
but not nice.
Let’s try something else. Clearly, EX [W in] = E[Z + W − X − Y ] (why?), so by linearity of expectation and
symmetry:
E[Z + W − X − Y ] = E[Z] · 2 − E[X] − E[Y ]
Obviously, E[X] = x, but how to calculate E[Y ] and E[Z]? Well, let’s start with E[Y ]. One way to calculate
it is using combinatoric approach and counting stuff with ”C’s”. It is doable and you can try it, but we can
calculate it considering several cases where X is the first, second, third, and the last number in ascending
order. We can pair them up by symmetry and calculate later, so it’s enough to show how to do first two
cases. Calculating probability of x being in some order is fairly straightforward, what about Y? Let’s say X
- min then all three numbers are in [X + 1...50], so Y is basically the minimum, so we need to calculate the
expected of the minimum of three numbers in [X + 1 ... 50] or just shift it to [1 ... 50 - X] and add X later
to the answer (if you solved some probability problems from those books, you should know how to calculate
E[Y] now). The same for the second case.
Calculation seems a bit complicated, so do we need to do the same thing for E[Z]? Thankfully not, we can
observe that E[Z + Y + W ] = E[sumof threenumbersin[1..50]excludingX] by linearity of expectation, that
is
7
occurences = [0]*51
num_test_cases = 1000000
for tc in range(num_test_cases):
a = [int]*4
while True:
for i in range(4):
a[i] = int(random() * 50) + 1
a.sort()
ok = True
for i in range(3):
if a[i] == a[i + 1]:
ok = False
if ok:
break
difference = int(a[0] + a[3] - a[1] - a[2])
occurences[a[0]] -= difference
occurences[a[3]] -= difference
occurences[a[1]] += difference
occurences[a[2]] += difference
y_points = [0]*51
for i in range(1, 51):
y_points[i] = occurences[i] / num_test_cases
x_points = [i for i in range(0, 51)]
plt.plot(x_points, y_points)
plt.show()
8
Problem 14. Let X - minimum in the box with card 100, then:
∞ 100 100
X X X 1 1
E[X] = P [X ≥ i] = P [X ≥ i] = i−1
= 2 − 99
i=1 i=1 i=1
2 2
Problem 17. How can we simulate a fair coin using an unfair coin ? Throw it twice until we get either
’TH’ or ’HT’ sequence. Both conditional probabilities are equal due to symmetry = 1/2. So we may assume
that the coin is now fair. Let
∞
X xi
α=
i=1
2i
- binary representation of α. Let’s create the following game. Alice throws a coin until she gets a head. If
she got head on i’s throw, she’ll win if xi = 1, and lose otherwise. Clearly winning events are independent,
so the probability of her winning is exactly α.
Problem 30. Note that to reach i as the last point, it is sufficient and necessary to reach both of its
neighbors before i. So
P[reaching neighbors of i before i] =
P[reaching one of its neighbors first time] P[reaching second neighbor without reaching i] = P[reaching second
neighbor without reaching i].
Clearly, it means that pi are equal for all (it is basically asking to find probability of reaching n from 1 before
1
reaching 0) i = 1, 2, ..., (n − 1). Thus, pi = (n−1)