Logic Puzzles: Lamps, Switches, Hourglasses and Ropes

These puzzles train you to tell states apart, use every piece of information available and look for an intermediate measurement. Here are 4 classic riddles, each with its step-by-step solution.

4 riddles · Published on November 7, 2026

Three Switches and a Light Bulb Riddle: The Solution

Logic · Medium

Classic computer science interview question

Three switches are placed in a hallway, and only one of them controls a light bulb in a closed room that cannot be seen from the hallway. You can enter the room only once. How can you tell, in a single visit, which switch controls the bulb?

Need a hint?

A lit bulb gives more than light: it also gives off heat, and a bulb that is switched off can still keep some of its warmth.

Show the answer and the solution

Answer: Heat the bulb with the first switch, turn it off, turn on the second switch, then go in: lit means the second switch; off but warm means the first; off and cold means the third.

The reasoning

The key is to use heat as well as light. Turn on the first switch and leave it on for several minutes, then turn it off. Next, turn on the second switch and enter the room right away. If the bulb is on, the second switch controls it. If it is off but warm, it is the first switch, since the bulb had time to heat up before being turned off. If it is off and cold, it was never powered, so it must be the third switch.

100 Lamps Riddle: Why Perfect Squares Stay Lit

Logic · Hard

Classic logic and math puzzle

One hundred lamps are lined up, all switched off, and numbered from 1 to 100. One hundred people pass by one after another: person number n changes the state of every lamp whose number is a multiple of n, meaning they turn on the lamps that are off and turn off the lamps that are on. How many lamps are on at the end, and which ones?

Need a hint?

Count how many times each lamp is toggled: this depends on the number of divisors of its number.

Show the answer and the solution

Answer: 10 lamps are on, those numbered with a perfect square: 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100.

The reasoning

Lamp number k is toggled by each person n such that n divides k, so it is toggled as many times as k has divisors. A lamp ends up on if it has been toggled an odd number of times, since it starts off. The divisors of a number pair up (d and its quotient), except when the number is a perfect square: the square root then pairs with itself, so the number of divisors is odd. Only the lamps numbered with a perfect square therefore stay on: 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100, that is 10 lamps.

Two Hourglasses Riddle: How to Measure Exactly 9 Minutes

Logic · Medium

Logic brain teaser

You have a 4-minute hourglass and a 7-minute hourglass, and you can turn either one over at any time, as many times as needed. You have no other instrument to measure time. How can you measure exactly 9 minutes?

Need a hint?

Start both hourglasses together and note the moments when one of them empties: they give intermediate markers.

Show the answer and the solution

Answer: Turn the 4-minute hourglass over at minute 4, and the 7-minute one at minute 7 and again at minute 8: the sand stops at minute 9.

The reasoning

Start both hourglasses together at time 0. At minute 4, the 4-minute hourglass is empty: turn it over. At minute 7, the 7-minute hourglass is empty: turn it over immediately, while the 4-minute hourglass has run for 3 minutes since it was turned. At minute 8, the 4-minute hourglass is empty, and the 7-minute hourglass, turned at minute 7, has run exactly 1 minute. Turn it over: the minute of sand that has run goes back to the top and runs out in 1 minute. The sand therefore stops at minute 9, and 9 minutes have been measured.

Two Burning Ropes Riddle: How to Measure 45 Minutes

Logic · Hard

Logic puzzle used in job interviews

You have two ropes, each burning for exactly 60 minutes, but unevenly: a rope does not burn at a constant rate, so cutting a rope in half does not give two halves of 30 minutes. You have matches, but no other instrument to measure time. How can you measure exactly 45 minutes?

Need a hint?

Think about lighting one rope at both ends, and ask what happens if you light the other rope at the right moment.

Show the answer and the solution

Answer: Light rope A at both ends and rope B at one end; when A has fully burned (30 minutes), light the other end of B: 15 more minutes, for a total of 45.

The reasoning

A rope lit at both ends burns twice as fast, since the fire spreads from both sides at once. Rope A, lit at both ends, is therefore fully burned in 30 minutes. At the same moment, rope B is lit at only one end; after 30 minutes, it has 30 minutes of burning left, at one end only. At that moment, the other end of B is lit: the fire now spreads from both sides, and what remains of B burns in 15 minutes. The total is therefore 30 + 15 = 45 minutes.

Frequently asked questions

What is the method for solving a lamp or switch riddle?

Listing the possible actions and noting what information each one gives is the basic method. You then choose a sequence of actions that tells apart all the possible cases before acting.

Do you need to be good at math for these puzzles?

No: these puzzles rely mostly on logic, and the only arithmetic is adding simple durations and recognizing perfect squares up to one hundred. Reasoning about states matters more than tricks.

How can you practice these logic puzzles?

Redo each puzzle by writing down every step, then solve it again without looking at the solution. Varying the types of puzzles helps you spot the same reasoning under different settings.

What next?

Reasoning improves like memory: by practising often. Next, test yourself on our general knowledge quizzes.