logic puzzles

The Rope Bridge

Four people need to cross a rickety rope bridge to get back to their camp at night. Unfortunately, they only have one flashlight and it only has enough light left for seventeen minutes. The bridge is too dangerous to cross without a flashlight, and it’s only strong enough to support two people at any given time.

Each of the campers walks at a different speed. One can cross the bridge in 1 minute, another in 2 minutes, the third in 5 minutes, and the slow poke takes 10 minutes to cross. How do the campers make it across in 17 minutes?

Solution

To get everyone across in 17 minutes, we need get the two slowest people across together; otherwise we are wasting too much time. Once we get them across, how do we not make one of them walk back with the flashlight? Just have one of the faster people already there waiting to sprint the flashlight back across.

 



person A: 1 minute



person B: 2 minutes



person C: 5 minutes



person D:10 minutes







1. A & B cross.  total time:  2 minutes.



 



 C |==========================| A



 D |                          | B



   |==========================| flashlight



 



2. B comes back. total time:  4 minutes.



 



 C |==========================| A



 D |                          | 



 B |==========================| 



flashlight



 



3. C & D cross.  total time: 14 minutes.



 



 B |==========================| A



   |                          | C



   |==========================| D



                               flashlight



 



4. A comes back. total time: 15 minutes.



 



 A |==========================| C



 B |                          | D



   |==========================| 



flashlight



 



5. A & B cross.  total time: 17 minutes.



 



   |==========================| A



   |                          | B



   |==========================| C D



                              flashlight 



Another valid solution is to have A bring the flashlight back in step 2.

2026 Update: Is the Torch / Bridge Puzzle Still Asked?

The Torch Puzzle (four people cross a bridge at night with one torch; find the minimum time) is a classic algorithmic puzzle that tests optimization intuition. Microsoft made it famous in the 2000s, and it still circulates as a warm-up wherever interviewers want to see optimization instincts rather than memorized code.

The key insight: send the two slowest people across together so their crossing times overlap, and let the two fastest ferry the flashlight back. For the classic {1, 2, 5, 10} example that gives 2 + 1 + 10 + 2 + 2 = 17 minutes. The tempting alternative — the fastest person escorts everyone across one at a time — costs 19 minutes, which is exactly why the puzzle filters for people who question the first strategy that comes to mind.

How it connects to modern engineering:

  • Job scheduling with shared resources (the torch is the shared constraint)
  • Network packet transmission where bandwidth is the bottleneck
  • CI/CD pipeline parallelization — which jobs share a resource and in what order?

Python solution for the general case:

def min_crossing_time(times: list[int]) -> int:
    """Two slowest cross together; the two fastest ferry the flashlight."""
    times = sorted(times)
    total = 0
    while len(times) > 3:
        # fastest escorts the slowest across, comes back, escorts the next
        solo = times[0] + times[-1] + times[0] + times[-2]
        # two fastest cross, fastest returns,
        # two slowest cross, second-fastest returns
        pair = times[1] + times[0] + times[-1] + times[1]
        total += min(solo, pair)
        times = times[:-2]
    if len(times) == 3:
        total += times[0] + times[1] + times[2]
    elif len(times) == 2:
        total += times[1]
    else:
        total += times[0]
    return total

print(min_crossing_time([1, 2, 5, 10]))  # 17

newsletter

What's actually being asked right now

Interview patterns & comp trends, straight to your inbox.

No spam. Unsubscribe anytime.

newsletter

What's actually being asked right now

Interview patterns & comp trends, straight to your inbox.

No spam. Unsubscribe anytime.

1972 Soviet postage stamp commemorating the Mars 2 probe

worth a read

Mars For The Rest of Us — a weekly-or-more deep dive on the technical side of Mars exploration: rocket propulsion, microbiology, mission architecture, and everything in between. Written by Maciej Ceglowski.

Read it on Substack →
Scroll to Top