Probability + Logic Questions
Probability + Logic Questions
But
if you are at home or work and the umbrella is in the opposite location, you will get wet. If you
start at home with your umbrella and the probability of rain each trip is p, what's the expected
number of trips before you get wet?
100 passengers board a plane. The first forgets their seat assignment and so takes a random
seat. Subsequent passengers take their assigned seat if available, and a random seat if not.
What’s the probability that the final passenger sits in their assigned seat?
You and your friend are playing darts. You are equally (not) good, so your throws are distributed
iid with the same (smooth) distribution. You throw first, then you take turns. If at any point, you
or your friend’s throw lands further from the bullseye than the previous throw, that thrower loses.
Thus, the game continues as long as throws keep getting closer and closer to the bullseye, and
the first player to disrupt this trend loses. Q1: What is the probability you lose? Q2: What is the
expected length of the game? (from Christian Szegedy during Google Brain interview)
You have two ropes and a lighter. Each rope has the following property: If you light one end of
the rope, it will take one hour to burn to the other end. They don't necessarily burn at a uniform
rate, nor are there rates necessarily the same. How can you measure a period of 45 minutes?
There are twenty-six coins lying on a table in a totally dark room. Ten are heads and sixteen are
tails. In the dark you cannot feel or see if a coin is heads up or tails up but you may move them
or turn any of them over. Separate the coins into two groups so that each group has the same
number of coins heads up as the other group.
You're on a game show with three doors in front of you. Behind two are goats, and behind the
third is a shiny new car. The game show host asks you to pick a door. Let's say you pick door 1.
The game show host then opens one of the other two doors to reveal a goat, say door 2 (he
won't open a door with a car because he doesn't want to spoil the game). He then asks you if
you want to switch to the remaining door, door 3. Do you switch? (Monty Hall problem)
You have the option to invest in two funds, fund A and fund B. Both have the same expected
returns, but their variances may differ. How should you invest your money? (RenTech interview)
What is the expected number of coin flips before you've seen at least one of each heads and
tails? (RenTech interview)
You and I are going to play to Russian roulette with a six-barrel revolver. The referee flips a
coin: if heads, he loads a bullet into one barrel, and if tails, he does not. He hands the gun to
me. I pull the trigger and... survive! You're up next. You pull the trigger and... survive! We
passed the gun back and forth until I have gone three times, you have gone twice, and you are
about to pull the trigger for sixth and final time. What is the probability that you survive?
(RenTech interview)
The blue eyes puzzle: https://xkcd.com/blue_eyes.html
Sample 3 points uniformly from the surface of a circle. What is the probability that the triangle
connecting them contains the center point?
N coins are on a table, H of which are heads. You are blind-folded, but need to separate the
coins into two piles with equal numbers of heads by moving and flipping coins. You know H, but
not N. What do you do?
4 coins are located on the corners of a square. You are blindfolded and don’t see whether they
are heads/tails. Your goal is to get them all showing the same face. You can do so by flipping
any number of coins. After each round, if you were wrong, a (potentially adversarial) demon can
rotate the square any number of times. How do you guarantee winning in a finite number of
moves?
Consider the following 2-player game: There are 9 cards, face-up, in front of both of you, with
the numbers 1-9 on them. You and the other player take turns taking a card, and the winning
condition is for you to be the first to get 3 cards that sum to 15. Everything stays face-up, so
there's perfect information all around. Is there a winning strategy? (DM slack #random)
You are on an island and there are three people: one always says the truth, one always lies,
and one is crazy - sometimes telling the truth and sometimes lying, randomly. They know who is
who. Your task is to find who is who by asking as few questions as possible. Each question has
to have a yes/no answer. You ask each person sequentially and if you ask the same question to
each person it counts as 3 questions. There are no tricks in this puzzle. How many questions do
you need to figure out who is who and how will you do it? (Misha Dashevskiy @ DM slack
#puzzles)
You and your friend are going to flip a coin to see who gets the last slice of pizza. Your friend
produces the coin. However, you don’t trust your friend - you suspect the coin might be biased.
Without knowing the bias of the coin, how can you nevertheless produce a draw from an
unbiased coin? (Hint: you can flip the coin multiple times.) (John von Neumann)
[Follow-on] If you need to produce N draws from an unbiased coin with your possibly biased
coin, how can you make this most efficient (i.e. fewest flips) as N grows?
Cut a stick uniformly at random in two places. What’s the probability the resulting pieces can
form a triangle?
The King of a small country invites 1000 senators to his annual party. As a tradition, each
senator brings the King a bottle of wine. Soon after, the Queen discovers that one of the
senators is trying to assassinate the King by giving him a bottle of poisoned wine. Unfortunately,
they do not know which senator, nor which bottle of wine is poisoned, and the poison is
completely indiscernible. However, the King has 10 prisoners he plans to execute. He decides
to use them as taste testers to determine which bottle of wine contains the poison. The poison
when taken has no effect on the prisoner until exactly 24 hours later when the infected prisoner
suddenly dies. The King needs to determine which bottle of wine is poisoned by tomorrow so
that the festivities can continue as planned. Hence he only has time for one round of testing.
How can the King administer the wine to the prisoners to ensure that 24 hours from now he is
guaranteed to have found the poisoned wine bottle? (Joel Veness on DM email thread)
A pizza his cut by straight lines into small pieces. The number of lines is very large and the cuts
are drawn completely randomly. Most of the pizza pieces are then polygons with straight edges,
with varying number of vertices. Question 1: What is the average number of vertices of a pizza
piece? Question 2: Let S be the average area and p be the average perimeter of a pizza piece.
What is the value of S/p^2? (Andrei Sakharov via here)
100 prisoners are due to be executed, unless they can pass a test. There are 100 closed boxes
in a row, with the numbers 1 to 100 written inside in a random order. The prisoners are assigned
numbers 1 to 100. Each prisoner must go into the room with the boxes, open up to 50 boxes,
and then close all the boxes they opened. They cannot move the boxes. If they all find their
assigned number, the prisoners survive. If any prisoner fails to find their number, all the
prisoners are executed. After the test begins, there is no communication of any kind (so prisoner
2 has no idea what prisoner 1 did, beyond any pre-agreed strategy). What chance of survival
can the prisoners achieve? (Tom Eccles on DeepMind #puzzles, 100 prisoners puzzle)
N cars are driving on a single lane road. Each has a unique preferred speed and will tailgate up
close to the car in front if that car is slower. This causes cars to bunch. What’s the expected
number of bunches of the N cars? (this video via David Schwab)
Frog is on lily pad i_0 = N, gonna jump onto new lily pad i_1 < i_0 towards the shore sampled
uniformly, including possibly jumping straight to shore. Repeat until get to shore. What’s the
expected number of hops it takes him to get to shore? To clarify: he only jumps on lily pads
closer to shore than where he is at any given step. (David Schwab)
Another "prisoners passing the test of a jailer who likes puzzles" problem: An 8x8 (standard)
chessboard is placed in a room with one coin on each square, either heads or tails up, by the
jailer. Prisoner A enters the room, and the jailer points to a square on the chessboard. Prisoner
A then chooses exactly one coin, flips it over, and leaves the room. Then, prisoner B enters the
room and must guess the square that the jailer pointed to. If correct, both prisoners are freed; if
incorrect, both prisoners are executed. The prisoners can discuss their strategy in advance, but
they cannot communicate once the trial starts, except through that one coin flip. Can the
prisoners pass the test and how? (3Blue1Brown)
Yola and Zela have devised a clever card trick. While Yola is out of the room, audience
members pick five random cards from a bridge deck and hand them to Zela. She looks them
over, pulls one out, and calls Yola into the room. Yola is handed the four remaining cards and
proceeds to guess correctly the identity of the pulled card. How do they do it, with nothing for
Yola to base her guess on other than the four cards she is handed? (Museum of Math via David
Schwab)
Twenty-four ants are placed randomly on a meter-long rod; each ant is facing toward one end or
the other with equal probability. At a signal, they proceed to march forward (that is, in whatever
direction they are facing) at 1 cm/sec; whenever two ants collide, they reverse directions. How
long does it take before you can be certain that all the ants are off the rod? (MoMath)
Twenty-four ants are placed randomly on a circular hoop, 1 meter in circumference. Each ant is
facing clockwise or counterclockwise with equal probability. At a signal, they proceed to march
forward (that is, in whatever direction they are facing) at 1 cm/sec; whenever two ants collide,
they reverse directions. After precisely 100 seconds, the ants stop where they are. One of the
ants, Ant Alice, is of particular interest to us. What is the probability that Ant Alice ends up
exactly where she began? (MoMath)
At the start of the 2019 season, WNBA star Missy Overshoot's lifetime free-throw percentage
was below 80%, but by the end of the season, she was above 80%. Must there have been a
moment in the season when her free-throw percentage was exactly 80%? (MoMath)
You come along just as a church lottery is closing; its prize is a quilt worth $100 to you, but
they've only sold 25 tickets. At $1 a ticket, how many tickets should you buy? (MoMath)
So there are 100 lockers in a row. They’re all closed, okay? A kid goes by. He opens every
single locker. A second kid goes by. Now he closes every other locker, every second locker.
Third kid comes by, every third locker. If it’s open, he closes it. If it’s closed, he opens it. Then
the fourth kid goes by. Every fourth locker, he changes the state. And now 100 kids go by. What
is the state of the lockers after 100 kids go by? (Coinbase first employee interview)
A logician is visiting the South Seas and, as is usual for logicians in puzzles, she is at a fork,
wanting to know which of two roads leads to the village. Present this time are three willing
natives, one each from a tribe of invariable truth-tellers, a tribe of invariable liars, and a tribe of
random answerers. Of course, the logician doesn't know which native is from which tribe.
Moreover, she is permitted to ask only two yes-or-no questions, each question being directed to
just one native. Can she get the information she needs? How about if she can ask only one yes-
or-no question? (MoMath)
A logician is visiting the South Seas and, as is usual for logicians in puzzles, she is at a fork,
wanting to know which of two roads leads to the village. Present this time are three willing
natives, one each from a tribe of invariable truth-tellers, a tribe of invariable liars, and a tribe of
random answerers. Of course, the logician doesn't know which native is from which tribe.
Moreover, she is permitted to ask only two yes-or-no questions, each question being directed to
just one native. Can she get the information she needs? How about if she can ask only one yes-
or-no question? (MoMath)
If you have a data stream of N numbers (like from a generator), and you’re told that there’s a
value that occurs >N/2 times, can you identify the value? With O(1) space? (David Schwab’s DE
Shaw interview, solution)