Compute answers to probability and counting puzzles
Compute answers to probability and counting puzzles
This is a collection of independent interview-style math and logic problems.
1) Barn legs
In a barn, there are spiders, chickens, and cows.
- Total legs: 560
- Number of chickens = 2 × Number of cows
- Number of spiders = 2 × Number of chickens
Determine the number of spiders.
2) Seating toddlers (round table)
Five toddlers (Anna, Brian, Charlie, Dixie, Eva) are to be seated around a round table. Rotations are considered the same arrangement.
Constraints:
- Anna will not sit next to Brian or Eva.
- Brian will not sit next to Charlie.
- Dixie will not sit next to Eva or Charlie.
Given that Dixie is sitting immediately to the right of Anna, determine who is sitting immediately to the left of Brian.
3) Which factory? (Bayes)
Factory A produces widgets with the following probabilities: 40% red, 60% black. Factory B produces widgets with the following probabilities: 80% red, 20% black.
A factory is chosen uniformly at random. Then, two widgets are sampled independently and uniformly at random from that factory.
Given that both sampled widgets are black, compute the probability that Factory A was chosen.
4) Dice game expected value
Three fair 6-sided dice are rolled.
- If all three dice show the same number, you win $20.
- If exactly two dice show the same number, you win $10.
- If all three dice show different numbers, you lose $2.
Compute the expected return per roll.
5) Bakery croissants
Each customer buys exactly one item.
- Probability of buying a croissant: 0.8
- Probability of buying a muffin: 0.2
- There are 2 croissants remaining.
- There are 5 customers left in line.
Compute the probability that the remaining croissants are sufficient (i.e., at most 2 customers request a croissant).
6) Cats: truth/lie based on who has more
Asta (A), Bronya (B), and Clara (C) each have a distinct number of cats.
Rules for speaking:
- When speaking to someone with fewer cats, the speaker tells the truth.
- When speaking to someone with more cats, the speaker lies.
Conversations:
- B → C: "You have the most cats."
- A → B: "I have exactly 30% more cats than you."
- A → C: "Your cats are the average of mine and Bronya's."
- C → A: "You have at least 4 more cats than me."
Determine the number of cats Bronya has.
7) Canoeing (relative speed)
A river current flows at a constant speed of 2 mph.
Two friends paddle at a constant speed v mph relative to the water.
- Day 1: They canoe upstream for 4 hours, then turn around and canoe downstream for 5 hours to reach the campsite.
- Day 2: They canoe back to the original starting point, which is 23 miles upstream from the campsite, arriving at 16:00.
What time did they leave on Day 2? (Format: hh:mm)
8) Cookie arrangements
You have baked:
- 4 indistinguishable snickerdoodles (S)
- 7 indistinguishable chocolate chip cookies (C)
Determine the number of distinct ways to arrange 5 cookies in a line.
9) Cheering for a cat (conditional probability)
Three cats compete, with the following win probabilities:
- Most athletic cat: 2/3
- Least athletic cat: 1/12
- Remaining cat: 1/4
You pick one cat uniformly at random to cheer for. You are then told that the cat you picked did not win.
Compute the probability that you picked the most athletic cat.
10) Spinner: expected spins to see two regions
A spinner has three regions with the following probabilities of landing:
- Region 1: 1/2
- Region 2: 1/3
- Region 3: 1/6
Compute the expected number of spins required to land in at least two distinct regions.
11) Two blooming flowers (overlap probability)
Time is continuous in days. The start day for each flower is uniformly distributed on the interval [0, 20], independently.
- The purple flower blooms for exactly 4 days.
- The red flower blooms for exactly 8 days.
Compute the probability that their bloom intervals overlap (i.e., they are simultaneously in bloom for a non-zero amount of time).
12) Expected number of pairs in a hand
A deck contains 8 cards: two 10s, two Js, two Qs, and two Ks. You are dealt a hand of 4 cards without replacement.
A "pair" is defined as having both cards of the same rank.
Compute the expected number of pairs in the hand.
13) Bold betting strategy (reach 5 before 0)
You start with 3 tokens and aim to reach 5 tokens before reaching 0 tokens. In each turn, you bet as many tokens as possible, but not more than needed to reach 5 (this is the "bold play" strategy).
You win each bet with a probability of 2/3; otherwise, you lose.
Compute the probability of reaching 5 tokens before reaching 0 tokens.
14) Frog grid paths with a run-length constraint
A frog travels from (0,0) to (5,4).
- Each step is either 1 unit to the right (R) or 1 unit up (U).
- The frog refuses to make three consecutive steps in the same direction (no RRR and no UUU).
Determine the number of valid paths.
AI interview prep
Core dilemma
Balancing rigorous mathematical derivation with clear, concise communication of probabilistic and combinatorial logic.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Compute answers to probability and counting puzzles
Compute answers to probability and counting puzzles
This is a collection of independent interview-style math and logic problems.
1) Barn legs
In a barn, there are spiders, chickens, and cows.
- Total legs: 560
- Number of chickens = 2 × Number of cows
- Number of spiders = 2 × Number of chickens
Determine the number of spiders.
2) Seating toddlers (round table)
Five toddlers (Anna, Brian, Charlie, Dixie, Eva) are to be seated around a round table. Rotations are considered the same arrangement.
Constraints:
- Anna will not sit next to Brian or Eva.
- Brian will not sit next to Charlie.
- Dixie will not sit next to Eva or Charlie.
Given that Dixie is sitting immediately to the right of Anna, determine who is sitting immediately to the left of Brian.
3) Which factory? (Bayes)
Factory A produces widgets with the following probabilities: 40% red, 60% black. Factory B produces widgets with the following probabilities: 80% red, 20% black.
A factory is chosen uniformly at random. Then, two widgets are sampled independently and uniformly at random from that factory.
Given that both sampled widgets are black, compute the probability that Factory A was chosen.
4) Dice game expected value
Three fair 6-sided dice are rolled.
- If all three dice show the same number, you win $20.
- If exactly two dice show the same number, you win $10.
- If all three dice show different numbers, you lose $2.
Compute the expected return per roll.
5) Bakery croissants
Each customer buys exactly one item.
- Probability of buying a croissant: 0.8
- Probability of buying a muffin: 0.2
- There are 2 croissants remaining.
- There are 5 customers left in line.
Compute the probability that the remaining croissants are sufficient (i.e., at most 2 customers request a croissant).
6) Cats: truth/lie based on who has more
Asta (A), Bronya (B), and Clara (C) each have a distinct number of cats.
Rules for speaking:
- When speaking to someone with fewer cats, the speaker tells the truth.
- When speaking to someone with more cats, the speaker lies.
Conversations:
- B → C: "You have the most cats."
- A → B: "I have exactly 30% more cats than you."
- A → C: "Your cats are the average of mine and Bronya's."
- C → A: "You have at least 4 more cats than me."
Determine the number of cats Bronya has.
7) Canoeing (relative speed)
A river current flows at a constant speed of 2 mph.
Two friends paddle at a constant speed v mph relative to the water.
- Day 1: They canoe upstream for 4 hours, then turn around and canoe downstream for 5 hours to reach the campsite.
- Day 2: They canoe back to the original starting point, which is 23 miles upstream from the campsite, arriving at 16:00.
What time did they leave on Day 2? (Format: hh:mm)
8) Cookie arrangements
You have baked:
- 4 indistinguishable snickerdoodles (S)
- 7 indistinguishable chocolate chip cookies (C)
Determine the number of distinct ways to arrange 5 cookies in a line.
9) Cheering for a cat (conditional probability)
Three cats compete, with the following win probabilities:
- Most athletic cat: 2/3
- Least athletic cat: 1/12
- Remaining cat: 1/4
You pick one cat uniformly at random to cheer for. You are then told that the cat you picked did not win.
Compute the probability that you picked the most athletic cat.
10) Spinner: expected spins to see two regions
A spinner has three regions with the following probabilities of landing:
- Region 1: 1/2
- Region 2: 1/3
- Region 3: 1/6
Compute the expected number of spins required to land in at least two distinct regions.
11) Two blooming flowers (overlap probability)
Time is continuous in days. The start day for each flower is uniformly distributed on the interval [0, 20], independently.
- The purple flower blooms for exactly 4 days.
- The red flower blooms for exactly 8 days.
Compute the probability that their bloom intervals overlap (i.e., they are simultaneously in bloom for a non-zero amount of time).
12) Expected number of pairs in a hand
A deck contains 8 cards: two 10s, two Js, two Qs, and two Ks. You are dealt a hand of 4 cards without replacement.
A "pair" is defined as having both cards of the same rank.
Compute the expected number of pairs in the hand.
13) Bold betting strategy (reach 5 before 0)
You start with 3 tokens and aim to reach 5 tokens before reaching 0 tokens. In each turn, you bet as many tokens as possible, but not more than needed to reach 5 (this is the "bold play" strategy).
You win each bet with a probability of 2/3; otherwise, you lose.
Compute the probability of reaching 5 tokens before reaching 0 tokens.
14) Frog grid paths with a run-length constraint
A frog travels from (0,0) to (5,4).
- Each step is either 1 unit to the right (R) or 1 unit up (U).
- The frog refuses to make three consecutive steps in the same direction (no RRR and no UUU).
Determine the number of valid paths.