Interview Puzzles

15 Must-Know Puzzles โ€” The ones that separate thinkers from guessers. Master the logic, own the interview.

25 Horses Puzzle

Hard Classic 4 min

Problem Statement

You have 25 horses and a racetrack that allows 5 horses to race at a time. You have no stopwatch โ€” you can only see the relative order of finish. What is the minimum number of races needed to find the top 3 fastest horses?

Answer
7 Races

Step-by-Step Solution

1

Race all 25 horses in groups of 5 โ†’ 5 races

Label groups A, B, C, D, E. In each group, rank horses 1-5 (A1 is fastest in group A).

2

Race the 5 group winners โ†’ 1 race (Race 6)

Race A1, B1, C1, D1, E1. Say the result is: A1 > B1 > C1 > D1 > E1

3

Eliminate horses that can't be in top 3

D1 and E1 lost to 3+ horses โ†’ eliminated. All of D and E groups โ†’ eliminated. C3, C4, C5 โ†’ eliminated (C1 is at best 3rd, so C3+ can't be top 3). B3, B4, B5 โ†’ eliminated. A4, A5 โ†’ eliminated.

4

Final race with remaining candidates โ†’ 1 race (Race 7)

A1 is definitely #1 (no need to race). Race: A2, A3, B1, B2, C1. Top 2 from this race = 2nd and 3rd overall.

After Race 6: Candidates for Top 3 GROUP A (1st) A1 โ˜… #1 A2 A3 A4 GROUP B (2nd) B1 B2 B3 GROUP C (3rd) C1 C2 GROUP D โœ— Eliminated GROUP E โœ— Eliminated Race 7: A2, A3, B1, B2, C1 (A1 is already #1)

After 6 races, only 5 horses remain as candidates for 2nd and 3rd place.

Key Insight

The trick is elimination by logic, not brute force. After the winners' race, you can eliminate 19 horses without racing them again. The diagonal pattern shows: horses below and to the right of position 3 in the grid can't possibly be top 3.

Common Mistake

Don't include A1 in the 7th race โ€” it's already proven to be #1. Racing it again wastes a slot. Also, don't forget B2 โ€” it could potentially beat B1 in a direct race (we only know B1 beat other group winners, not that it beat B2 overall).

Variations

What if we need to find only the fastest horse?
Just 6 races. Race all 25 in groups of 5 (5 races), then race the 5 winners (1 race). The winner of the winners' race is the fastest.
What if we need to find top 5?
More complex โ€” requires careful analysis. Answer is 9 races. After race 7, you need 2 more races to determine 4th and 5th positions among remaining candidates.

8 Ball Puzzle

Medium Classic 3 min

Problem Statement

You have 8 identical-looking balls. One is slightly heavier than the others. Using a balance scale, what's the minimum number of weighings to find the heavy ball?

Answer
2 Weighings

Step-by-Step Solution

1

Divide into 3 groups: (3, 3, 2)

Key insight: divide by 3, not 2. This gives more information per weighing.

2

Weigh 3 vs 3 (Weighing 1)

If one side is heavier โ†’ heavy ball is in those 3. If balanced โ†’ heavy ball is in the remaining 2.

3

If heavy ball is in group of 3: weigh 1 vs 1 (Weighing 2)

If one side heavier โ†’ that's it. If balanced โ†’ third ball is heavy.

4

If heavy ball is in group of 2: weigh 1 vs 1 (Weighing 2)

Heavier one is the answer.

Key Insight

A balance scale has 3 outcomes: left heavy, right heavy, or balanced. So you can distinguish 3 possibilities per weighing. With 2 weighings: 3ยฒ = 9 possibilities โ†’ enough for 8 balls. With binary thinking (divide by 2), you'd need 3 weighings.

  • n balls โ†’ โŒˆlogโ‚ƒ(n)โŒ‰ weighings needed
  • For 8 balls: โŒˆlogโ‚ƒ(8)โŒ‰ = โŒˆ1.89โŒ‰ = 2

Variations

12 balls, one is different (heavier OR lighter), find it in 3 weighings
Much harder! Divide into (4,4,4). First weighing tells if odd ball is in the heavier group, lighter group, or the 4 not weighed. Then you use 2 more weighings with clever grouping, tracking which balls could be heavy vs light. Answer: 3 weighings is sufficient and necessary.
What's the maximum number of balls for N weighings?
If you know the odd ball is heavier: 3^N balls. If odd ball could be heavier or lighter: (3^N - 3)/2 balls. For 3 weighings: 12 balls if unknown, 27 if known heavier.

Competitive Edge

The generalization: with k weighings, you can identify one defective among 3^k items (if you know it's heavier). This is called the ternary search principle. Mentioning this shows mathematical thinking beyond the specific puzzle.

Bridge and Torch

Medium Classic 3 min

Problem Statement

Four people need to cross a bridge at night. They have one torch, and the bridge can hold only 2 people at a time. The torch must be carried on every crossing. Each person walks at different speeds: 1 min, 2 min, 5 min, 10 min. When two cross together, they move at the slower person's pace. What's the minimum total time to get everyone across?

Answer
17 Minutes

The Optimal Strategy

1

1 and 2 cross together โ†’ 2 min

2

1 returns with torch โ†’ 1 min

3

5 and 10 cross together โ†’ 10 min

This is the key insight โ€” send the two slowest together!

4

2 returns with torch โ†’ 2 min

5

1 and 2 cross together โ†’ 2 min

Total: 2 + 1 + 10 + 2 + 2 = 17 minutes

Key Insight

The counter-intuitive idea: send the two slowest people together. This way, you "pay" for the 10-minute person only once. The naive approach (always having fastest person escort everyone) gives: 2+1+5+1+10 = 19 minutes โ€” worse!

  • Naive approach: 1 escorts everyone โ†’ 2 + 1 + 5 + 1 + 10 = 19 min
  • Optimal: slow people together, fast people ferry torch โ†’ 17 min

Common Mistake

The intuition "fastest person should always carry the torch back" is WRONG for this puzzle. It's more efficient to have the two fastest make an extra crossing so that the two slowest can cross together.

Variations

What if there are N people?
For N people sorted by time (tโ‚ โ‰ค tโ‚‚ โ‰ค ... โ‰ค tโ‚™), the algorithm involves comparing: sending the two fastest back and forth vs sending the fastest as permanent escort. Dynamic programming or greedy comparison at each step.

Water Jug Problem

Medium 3 min

Problem Statement

You have a 3-liter jug and a 5-liter jug. You have unlimited water supply. Measure exactly 4 liters.

Answer
6 Steps

Step-by-Step Solution

Step Action 3L Jug 5L Jug
1 Fill 5L jug 0 5
2 Pour 5L โ†’ 3L (fill 3L) 3 2
3 Empty 3L jug 0 2
4 Pour 5L โ†’ 3L (2 liters) 2 0
5 Fill 5L jug 2 5
6 Pour 5L โ†’ 3L (only 1L fits) 3 4 โœ“

Key Insight

Any amount that's a multiple of GCD(3,5) = 1 can be measured. Since GCD is 1, you can measure ANY integer amount up to 5 liters. The operations form a mathematical system: you're essentially computing 5a + 3b = target where a and b are integers (can be negative, representing emptying).

// Possible if and only if:
target % GCD(jug1, jug2) == 0 AND target <= max(jug1, jug2)

Variations

4L and 6L jugs, measure 2L?
GCD(4,6) = 2. Since 2 is a multiple of 2, it's possible. Fill 6L, pour into 4L (leaves 2L in 6L jug). Done in 2 steps!
4L and 6L jugs, measure 3L?
GCD(4,6) = 2. Since 3 is NOT a multiple of 2, it's impossible. No sequence of operations can produce exactly 3L.

100 Prisoners Problem

Hard 4 min

Problem Statement

100 prisoners are numbered 1-100. There are 100 boxes, each containing a random prisoner's number. Each prisoner can open at most 50 boxes. They must find their own number. All must succeed for everyone to go free. They can strategize beforehand but cannot communicate once started. What strategy maximizes survival probability?

Answer
~31% Survival (Loop Strategy)

The Loop Strategy

1

Prisoner N starts by opening box N

2

If box N contains number M, open box M next

3

Continue following the chain until finding own number

This will ALWAYS find their number eventually โ€” the question is: in 50 boxes or less?

Why This Works

The box-number arrangement forms cycles (permutation loops). Each prisoner is guaranteed to be in exactly one cycle. If you start at your number and follow the chain, you'll eventually return to yourself. The strategy succeeds if ALL cycles have length โ‰ค 50.

  • Random strategy: (1/2)^100 โ‰ˆ 0.0000...% (impossible)
  • Loop strategy: P(no cycle > 50) โ‰ˆ 31.18%
  • Math: 1 - ln(2) โ‰ˆ 0.3069 in the limit
Example: Boxes form cycles Box 1 โ†’3 Box 3 โ†’1 Cycle length: 2 Box 2 โ†’5 Box 5 โ†’4 Box 4 โ†’2 Cycle length: 3 Both < 50 โœ“ Everyone survives!

Numbers in boxes form closed loops. Each prisoner follows their loop.

Competitive Edge

The mathematical beauty: probability of survival = 1 - H_100 + H_50 โ‰ˆ 1 - ln(2) as nโ†’โˆž, where H_n is the harmonic number. This connects to random permutation cycle statistics โ€” a deep area of combinatorics. Mentioning this shows serious mathematical depth.

Common Mistake

Thinking "31% is bad" โ€” compared to (1/2)^100 โ‰ˆ 10^-31, it's astronomically better! There's no strategy that can do better than ~31%. Also, this is NOT a trick question โ€” the loop strategy is genuinely optimal.

Egg Dropping Puzzle

Hard Classic 4 min

Problem Statement

You have 2 identical eggs and a building with 100 floors. There's a critical floor F: eggs break when dropped from floor F or above, and survive below F. Find F with minimum worst-case drops.

Answer
14 Drops (Worst Case)

The Optimal Strategy

1

First egg: Drop at floors 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100

Notice: gaps decrease by 1 each time (14, 13, 12, 11, ...)

2

When first egg breaks, use second egg to linear search the gap

If egg 1 breaks at floor 14, search floors 1-13 one by one (13 more drops).

3

Total drops = position of first break + gap size = always 14

Drop at 14 (1 drop) + break โ†’ search 1-13 (13 drops) = 14 total. Drop at 14 OK, drop at 27 (2 drops) + break โ†’ search 15-26 (12 drops) = 14 total. Pattern continues!

Key Insight

If first drop is at floor X, and egg breaks, you need X-1 more drops (linear search). If it survives, you've "used up" 1 drop, so next gap should be X-1. This gives: X + (X-1) + (X-2) + ... + 1 โ‰ฅ 100. Solving: X(X+1)/2 โ‰ฅ 100 โ†’ X โ‰ฅ 14.

// General formula for 2 eggs, N floors:
min_drops = โŒˆ(-1 + โˆš(1 + 8N)) / 2โŒ‰

// For k eggs and N floors (DP relation):
dp[k][n] = 1 + min(max(dp[k-1][x-1], dp[k][n-x])) for x in 1..n

Variations

What if you have 3 eggs and 100 floors?
With 3 eggs, you can use a more aggressive strategy. Answer: 9 drops. The first egg lets you do "ternary search" style narrowing before falling back to the 2-egg problem.
What if you have infinite eggs?
Binary search! โŒˆlogโ‚‚(100)โŒ‰ = 7 drops. Each drop eliminates half the remaining floors.

Common Mistake

Binary search (drop at 50, then 25 or 75, etc.) doesn't work with only 2 eggs. If the egg breaks at 50, you have 1 egg left and must check floors 1-49 one by one โ†’ 50 drops worst case! The constraint of limited eggs fundamentally changes the strategy.

Competitive Edge

This is a classic DP problem. In coding interviews, you might be asked to write the code. State: dp[eggs][floors] = minimum drops. Transition: try each floor, take min of max(break case, survive case). Time: O(knยฒ), can be optimized to O(kn log n) with binary search on transition.

Coin Flip Problems

Medium 3 min

Problem: Fair Result from Biased Coin

You have a biased coin (not 50-50). How can you generate a fair 50-50 outcome?

Answer
Von Neumann's Trick

Solution: Von Neumann Extraction

1

Flip the coin twice

2

If HT โ†’ call it "Heads". If TH โ†’ call it "Tails".

3

If HH or TT โ†’ discard and repeat.

Why It Works

If P(H) = p, then: P(HT) = p(1-p) and P(TH) = (1-p)p. These are equal! So HT and TH have the same probability, making the choice between them fair. HH and TT are discarded.

More Coin Problems

Expected flips to get first Head?
Geometric distribution with p = 0.5. E[X] = 1/p = 2 flips. Intuition: on average, you flip twice โ€” first flip might be T, second is H.
Expected flips to get HH (two heads in a row)?
Let E = expected flips. After first flip: if T (prob 0.5), wasted 1 flip, start over. If H (prob 0.5), flip again: if H, done in 2. If T, wasted 2, start over. Solving: E = 0.5(1+E) + 0.5(0.5ยท2 + 0.5(2+E)). Solution: E = 6 flips.
Which comes first on average: HH or HT?
HT comes first on average (4 flips vs 6 for HH). Once you get an H, you either get T (done with HT) or H (still need another H for HH, but any T restarts). HT is "easier" because after H, T completes it, while for HH you must avoid T.

Poisoned Bottle Puzzle

Hard Classic 3 min

Problem Statement

You have 1000 bottles, exactly one is poisoned. You have 10 test strips that change color if exposed to poison (one-time use). You can put multiple drops on each strip. How do you find the poisoned bottle in one round of testing?

Answer
Binary Encoding with 10 Strips

Solution

1

Number bottles 0-999 in binary (10 bits)

Bottle 0 = 0000000000, Bottle 1 = 0000000001, ..., Bottle 999 = 1111100111

2

Each strip corresponds to one bit position

Strip 1 = bit 0, Strip 2 = bit 1, ..., Strip 10 = bit 9

3

Put drop from bottle N on strip K if bit K of N is 1

Bottle 5 (binary 0000000101) โ†’ drops on strips 1 and 3

4

Read which strips changed โ†’ that binary number is the poisoned bottle

If strips 1, 3, 5 changed โ†’ binary 00000101010 = bottle 42 is poisoned

Key Insight

This is information theory in action. With 10 strips, you have 2^10 = 1024 possible outcomes (each strip is either positive or negative). That's enough to uniquely identify one bottle among 1000. You're essentially encoding bottle numbers in binary and using strips as bits.

  • N bottles need โŒˆlogโ‚‚(N)โŒ‰ strips
  • 1000 bottles: โŒˆlogโ‚‚(1000)โŒ‰ = 10 strips

Variations

What if poison takes time to show and you have limited time?
If poison takes 1 hour to show and you have 1 hour: use the same binary encoding โ€” apply all drops immediately, wait 1 hour, read result. If you have more time and fewer strips, you can do multiple rounds with different encoding schemes.
What if 2 bottles are poisoned?
Much harder! With 2 poisoned bottles, you need strips that can encode pairs. One approach: use error-correcting codes. For 1000 bottles with 2 poisoned, you'd need around 20+ strips with careful combinatorial design.

Pirate Gold Division

Hard 4 min

Problem Statement

5 pirates (ranked by seniority: A > B > C > D > E) must divide 100 gold coins. The most senior pirate proposes a division. All pirates vote. If majority accepts (โ‰ฅ50%), division happens. Otherwise, proposer is thrown overboard and next pirate proposes. Pirates are rational, want maximum gold, and prefer others die if it doesn't affect their gold. What does Pirate A propose?

Answer
A gets 98, B gets 0, C gets 1, D gets 0, E gets 1

Solution: Backward Induction

1

Case: Only D and E remain

D proposes 100-0. D votes yes (50% = pass). D gets everything, E gets 0.

2

Case: C, D, E remain

E knows he gets 0 if D proposes. So E accepts any offer โ‰ฅ 1 from C. C proposes 99-0-1. C+E vote yes (majority).

3

Case: B, C, D, E remain

D gets 0 if C proposes. So D accepts โ‰ฅ 1 from B. B proposes 99-0-1-0. B+D vote yes (50% = pass).

4

Case: All 5 pirates

C gets 0 if B proposes. E gets 0 if B proposes. A only needs to buy 2 votes. A offers 1 coin each to C and E. They accept (better than 0). A proposes 98-0-1-0-1. A+C+E vote yes (60%).

Key Insight

Backward induction: work from the smallest case (2 pirates) to the full case. At each step, figure out who gets 0 in the next scenario โ€” those pirates will accept 1 coin now to avoid getting 0 later. The proposer only needs to "buy" enough votes to reach majority.

Common Mistake

Thinking pirates would form alliances or that "fairness" matters. Pirates are purely rational โ€” they only care about their own gold. Also, the "prefer death" assumption matters: if A offers C 0 coins and C is indifferent, C votes NO (prefers A to die).

Variations

What if there are 6 pirates?
Now A needs 3 votes (self + 2 others). From the 5-pirate case, B and D get 0. A offers 1 to each, keeps 98. Answer: 98-0-1-0-1-0.
What if >50% is required (strict majority)?
Changes the dynamics significantly. With 5 pirates, A needs 3 votes (>50% of 5). So A must buy 2 others with 1 coin each. Answer stays 98-0-1-0-1. But with 2 pirates, D can't pass alone โ€” he'd need E's vote too, changing the chain.

Clock Angle Problem

Easy 2 min

Problem Statement

What is the angle between the hour hand and minute hand at 3:15?

Answer
7.5 degrees

Solution

1

Minute hand position: 15 minutes = 15 ร— 6ยฐ = 90ยฐ from 12

Minute hand moves 360ยฐ/60min = 6ยฐ per minute

2

Hour hand position: 3 hours + 15 minutes = 3.25 hours = 3.25 ร— 30ยฐ = 97.5ยฐ from 12

Hour hand moves 360ยฐ/12hr = 30ยฐ per hour = 0.5ยฐ per minute

3

Angle = |97.5ยฐ - 90ยฐ| = 7.5ยฐ

// General formula for H hours and M minutes:
angle = |30ร—H - 5.5ร—M|
// If > 180ยฐ, subtract from 360ยฐ for acute angle
if (angle > 180) angle = 360 - angle

Key Insight

The tricky part: hour hand moves continuously, not just on the hour. At 3:15, the hour hand is NOT at the 3 โ€” it's 1/4 of the way toward 4. Hour hand speed: 0.5ยฐ per minute. Minute hand speed: 6ยฐ per minute.

Variations

At what times are the hands exactly overlapping?
Set 30H - 5.5M = 0 (mod 360). Happens at: 12:00, 1:05:27, 2:10:55, 3:16:22, 4:21:49, 5:27:16, 6:32:44, 7:38:11, 8:43:38, 9:49:05, 10:54:33. That's 11 times in 12 hours (not 12 โ€” between 11 and 12, overlap is exactly at 12:00).
At what times are the hands at 90ยฐ?
Set |30H - 5.5M| = 90 or 270. Happens 44 times per day. For example: 3:00 exactly (hour at 90ยฐ, minute at 0ยฐ), but NOT 3:15 as we just calculated!

Train Crossing Problems

Medium 3 min

Problem 1

Two trains, 100 km apart, travel toward each other. Train A goes 30 km/h, Train B goes 20 km/h. A bird flies at 50 km/h between them, starting from Train A, bouncing back and forth until trains meet. How far does the bird fly?

Answer
100 km

Solution (The Smart Way)

1

Time until trains meet: 100 km รท (30 + 20) km/h = 2 hours

Combined approach speed = 50 km/h

2

Bird flies for 2 hours at 50 km/h = 100 km

Don't calculate each leg โ€” just total time ร— bird speed!

Key Insight

The trap is trying to calculate each back-and-forth trip of the bird โ€” that's an infinite series! The clever solution: the bird flies the ENTIRE time the trains are moving, so just find the total time and multiply by bird's speed. (Story: Von Neumann allegedly solved this instantly; when told "you found the trick!", he replied "What trick? I summed the series.")

More Train Problems

A 200m train crosses a 300m bridge. Train speed is 50 km/h. How long to cross?
Total distance = train length + bridge length = 200 + 300 = 500m. Time = 500m รท (50ร—1000/3600 m/s) = 500 รท 13.89 = 36 seconds.
Two trains of lengths 100m and 150m cross each other traveling opposite directions at 40 km/h and 50 km/h. Time to cross?
Relative speed = 40 + 50 = 90 km/h = 25 m/s. Total distance = 100 + 150 = 250m. Time = 250 รท 25 = 10 seconds.

River Crossing Puzzles

Easy Classic 3 min

Problem: Farmer, Wolf, Goat, Cabbage

A farmer must cross a river with a wolf, a goat, and a cabbage. The boat holds only the farmer + one item. If left alone: wolf eats goat, goat eats cabbage. How does everyone cross safely?

Answer
7 Crossings

Step-by-Step Solution

Step Action Left Bank Right Bank
Start โ€” F, W, G, C โ€”
1 Take Goat โ†’ W, C F, G
2 Return alone โ† F, W, C G
3 Take Wolf โ†’ C F, W, G
4 Bring Goat back โ† F, G, C W
5 Take Cabbage โ†’ G F, W, C
6 Return alone โ† F, G W, C
7 Take Goat โ†’ โ€” F, W, G, C โœ“

Key Insight

The goat is the problem child โ€” it can't be left with either wolf or cabbage. So the goat must travel more than others. The counter-intuitive step: bringing the goat back (step 4). Sometimes you have to "undo" progress to make overall progress.

Variations

3 missionaries and 3 cannibals crossing (boat holds 2)
Cannibals must never outnumber missionaries on either bank. Minimum: 11 crossings. Key move: sometimes send 2 cannibals, bring 1 back. Solution requires careful state-space search.
Jealous husbands (3 couples, boat holds 2, no woman alone with another man)
This is the classic "jealous husbands" problem. Minimum: 11 crossings. Similar to missionaries but different constraints โ€” women can only be with their own husbands or other women.

Dice Probability Questions

Medium 3 min

Problem 1: Sum of Two Dice

What's the probability of getting a sum of 7 when rolling two fair dice?

Answer
6/36 = 1/6

Key Insight

Total outcomes: 6 ร— 6 = 36. Ways to get 7: (1,6), (2,5), (3,4), (4,3), (5,2), (6,1) = 6 ways. P(sum=7) = 6/36 = 1/6. Note: 7 is the MOST likely sum (6 ways), while 2 and 12 are least likely (1 way each).

More Dice Problems

Expected value of a single die roll?
E[X] = (1+2+3+4+5+6)/6 = 21/6 = 3.5
Expected number of rolls to see all 6 faces?
This is the "Coupon Collector Problem." E = 6/6 + 6/5 + 6/4 + 6/3 + 6/2 + 6/1 = 6(1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6) = 6 ร— 2.45 = 14.7 rolls.
Roll until you get a 6. Expected rolls?
Geometric distribution with p = 1/6. E[X] = 1/p = 6 rolls.
Probability at least one 6 in four rolls?
P(at least one 6) = 1 - P(no sixes) = 1 - (5/6)^4 = 1 - 625/1296 โ‰ˆ 0.518 or 51.8%.

Competitive Edge

For expected value of "roll until condition" problems, use the formula: E = 1/p where p is probability of success. For "expected to collect all N items": E = N ร— H_N where H_N is the N-th harmonic number. These patterns appear repeatedly in interviews.

Monty Hall Problem

Medium Classic 3 min

Problem Statement

You're on a game show. There are 3 doors: behind one is a car, behind the others are goats. You pick a door (say #1). The host, who knows what's behind each door, opens another door (say #3) revealing a goat. He then asks: "Do you want to switch to door #2?" Should you switch?

Answer
YES โ€” Switch! (2/3 vs 1/3)

Why Switching Wins

1

Initial pick: 1/3 chance of car, 2/3 chance of goat

2

Host's action doesn't change YOUR door's probability

Your door is still 1/3. The other two doors together are still 2/3.

3

Host eliminates one goat door, concentrating 2/3 on the remaining door

The "2/3 probability" that was split between two doors is now ALL on the one remaining door.

Three Scenarios (You picked Door 1) Car behind Door 1 P = 1/3 ๐Ÿš— ๐Ÿ ๐Ÿ Switch = LOSE Car behind Door 2 P = 1/3 ๐Ÿ ๐Ÿš— ๐Ÿ Switch = WIN Car behind Door 3 P = 1/3 ๐Ÿ ๐Ÿ ๐Ÿš— Switch = WIN

In 2 out of 3 equally likely scenarios, switching wins. Host always opens a goat door.

Key Insight

The host's action is NOT random โ€” he MUST open a goat door. This gives you information. If you initially picked a goat (2/3 chance), the host is FORCED to reveal the other goat, and switching gets you the car. If you initially picked the car (1/3 chance), switching loses. Switching wins 2/3 of the time!

Common Mistake

Thinking "Now there are 2 doors, so it's 50-50." This ignores that the host's choice was constrained. The host had information and used it. Your original choice was uninformed (1/3). The remaining door inherits the 2/3 probability that was on "the other doors."

Variations

What if there are 100 doors and host opens 98?
Switch! Your door has 1/100 chance. The remaining door has 99/100 chance. When the host opens 98 doors with goats, all that probability concentrates on the one door he avoided. This extreme version makes the logic clearer.
What if the host opens doors randomly (might reveal the car)?
Different problem! If host randomly opens a door and happens to show a goat, then it IS 50-50. The host's knowledge is crucial. This is called the "Monty Fall" problem.

Logical Deduction Puzzles

Hard 4 min

Problem: Two Guards (Heaven/Hell)

You're at a fork. One path leads to heaven, one to hell. Two guards stand there: one ALWAYS lies, one ALWAYS tells truth. You don't know who's who. You can ask ONE question to ONE guard to find the path to heaven. What do you ask?

Answer
"Which path would the OTHER guard say leads to heaven?"

Why It Works

1

If you ask the truth-teller:

He truthfully reports what the liar would say. The liar would point to hell. So truth-teller points to hell.

2

If you ask the liar:

He lies about what the truth-teller would say. Truth-teller would point to heaven. Liar lies and points to hell.

3

Both guards point to HELL. Take the other path!

Key Insight

The trick is to create a double negation. By asking about what the OTHER guard would say, you force a lie to be applied exactly once (either the guard you ask lies, or they truthfully report a lie). One lie = wrong answer. So the answer is always wrong, and you take the opposite.

More Logic Puzzles

Blue Eyes Puzzle: 100 people, some have blue eyes. Everyone can see others' eyes but not their own. If you have blue eyes, you must leave. A visitor says "I see someone with blue eyes." On day 100, all 100 blue-eyed people leave. Why?
Common Knowledge is key. Everyone already saw blue eyes, but the announcement makes it "common knowledge" (everyone knows that everyone knows that everyone knows...). With 1 blue-eyed person: they see no blue, deduce they're blue, leave day 1. With 2: each sees 1 blue, waits to see if that person leaves on day 1. When they don't, both know they have blue, leave day 2. Induction to 100.
3 people with hats (2 black, 3 white available). Each sees others' hats but not own. First two say "I don't know my color." Third (blind) says "I know mine!" How?
If first two were both white: first person would know they're black (only 2 black, can't both be). First says "don't know" โ†’ not both white among persons 2+3. Second person sees person 3. If person 3 is white and first said "don't know," person 2 can deduce they're black. Second says "don't know" โ†’ person 3 is NOT white. Therefore: person 3 (blind) has black hat.
Sum and Product puzzle: "I don't know the numbers." "I knew you wouldn't." "Now I know." "Now I do too." Find the numbers.
Classic! Answer: 4 and 13. This requires careful analysis of what each statement reveals. S=17, P=52. Mr. S can deduce from Mr. P's inability that the sum isn't expressible as sum of two primes (odd + 2 or two primes). The deductions chain forward from there.

Competitive Edge

Logic puzzles test your ability to think recursively about what others know. Key concepts: Common knowledge (everyone knows X, and everyone knows everyone knows X, etc.) vs mutual knowledge (everyone knows X, but might not know others know). The Blue Eyes puzzle is specifically about the difference. Also know about meta-reasoning: "If they could deduce X, they would have said so. They didn't, so they couldn't, which tells me Y."

Home 01. DBMS 02. OOPs 03. Computer Networks 04. Operating System 05. C++ Core 05. Java Core 05. Python Core 06. Puzzles 07. Linux 08. Git 09. SQL 10. Projects 11. System Design 12. DSA Concepts