Measure 45 minutes with two ropes
IntersystemsSoftware Engineer · Technical ScreenLast updated
This problem tests creative logical reasoning and the ability to decompose time-based tasks into parallelizable components without standard measurement tools.
Problem Statement
You are given two ropes of varying density, meaning they do not burn at a uniform rate. Each rope takes exactly 60 minutes to burn completely from one end to the other. However, because the density is inconsistent, half of the rope length does not necessarily represent 30 minutes of burn time.
You have an unlimited supply of matches and these two ropes. Your goal is to measure exactly 45 minutes of time.
Rules
- You can light one or both ends of a rope at any time.
- You may light the second end of a rope while it is already burning from the first end.
- Once a rope is burning, you cannot adjust the burn rate, but you can use the ropes to determine discrete time intervals.
Task
Explain the process to measure exactly 45 minutes using only these two ropes.
Worked Example
- If you light one end of a 60-minute rope, it finishes in 60 minutes.
- If you light both ends of a 60-minute rope simultaneously, it finishes in 30 minutes regardless of the rope's internal density distribution.
Constraints
- You cannot cut the ropes.
- You cannot use other measuring tools like clocks or rulers.
- Focus on the logical sequence of events.
Hints
Hint 1
Think about how lighting both ends of a single rope affects the total time it takes to burn compared to lighting only one end.
Hint 2
If you have a 30-minute interval established by burning one rope from both ends, how can you use that state to signal the start of a new interval on the second rope?
Hint 3
Try to set up the second rope such that its remaining burn time is precisely 15 minutes once the first rope has finished its 30-minute burn.
Follow-up questions
- How would you measure 15 minutes using only one of these ropes?
- If you were given three ropes instead of two, what is the minimum amount of time you could measure?
- Does the order in which you light the ends of the ropes matter if the ropes are of different total lengths (e.g., one burns in 60 minutes, the other in 30)?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.