01State-space puzzles: jugs, crossings, and timerswarm upNew
What common divisor prevents multiples of four and six from combining to make an odd integer?
02State-space puzzles: jugs, crossings, and timerswarm upNew
A test has three outcomes. Why is counting its possible outcome strings only part of proving a testing strategy works?
Core idea
Search state transitions rather than relying on a verbal sequence. Breadth-first search minimizes equal-cost moves; Dijkstra’s method minimizes nonnegative unequal costs. For timers, track observable events and remaining time.
Worked example
You have empty three-liter and five-liter jugs, unlimited water, and can fill, empty, or pour until a jug fills or empties. Measure four liters.
Let the state (x,y) record liters in the smaller and larger jug, with capacities A and B. For a pour from the larger jug into the smaller, the transferable volume is limited by the smaller jug's empty space and the larger jug's contents. Here , , and the goal is ; fills and empties set a coordinate to its capacity or to zero.
More practice
Solve these questions here. More practice counts separately from lesson completion.
1483State-space puzzles: jugs, crossings, and timerscoreNew
You are given two ropes and a lighter. If you light rope 1 it will take 40 minutes to burn all the way to the other end. For rope 2 this takes 60 minutes. The speed at which the ropes burn at different parts are unknown and vary. Which of the following times (in minutes) is impossible to time using the ropes and the lighter?
Modeling assumptions: Timing begins at the first lighting. Light rope ends initially or at an observed burnout; no cutting, extinguishing or additional clock.
Crossing the Stream
Practice
1459State-space puzzles: jugs, crossings, and timerscoreNew
A traveler is on his way back from a village fair. With him, he has a cat, a mouse, and a piece of cheese. When he reaches a stream, he must use a tiny raft only big enough for him and one other item. Unfortunately, if the cat is left alone with the mouse, it will eat it, and similarly, the mouse will eat the cheese if left alone with it. How can the traveler cross the stream?
Hourglasses
Practice
1464State-space puzzles: jugs, crossings, and timerscoreNew
Using only a 4 minute and 7 minute hourglass how can one measure exactly 9 minutes?
Measuring Wine
Practice
1468State-space puzzles: jugs, crossings, and timerscoreNew
You're at a vineyard and are given two empty wine bottles: one with a capacity of 3 liters and another with a capacity of 5 liters. There are no markings on the bottles except for their total volume. You have access to an unlimited supply of a rare vintage wine from a barrel. Your goal is to get exactly 4 liters of wine. How can you achieve this using only the two wine bottles?
Use states (x,y) for the smaller and larger jugs. The sequence is (0,0)→(0,5)→(3,2)→(0,2)→(2,0)→(2,5)→(3,4). Every step ends at an allowed observable event, and the larger jug finishes with four liters.
Figure5 A legal sequence of fill, pour, and empty operations reaches four liters in the five-liter jug.
Methods and variations
A. Represent both banks and the traveler
A crossing state records everyone’s bank and the raft’s bank. Reject states with an unattended forbidden pair. With equal-cost moves, breadth-first search proves the first reached solution uses the fewest crossings; a return carrying cargo can be essential.
A state must determine what moves are possible without needing the earlier story. For example, knowing only the number of people on the left bank loses which forbidden pairs are together. Encode each participant's side plus the traveler's or boat's side. An edge joins two states only when the crossing and the resulting unattended groups are legal.
Breadth-first search explores all states at distance 0, then 1, then 2, and so on. If the goal first appears in layer k, every shorter path has already been checked. That is the reason it proves minimality when every crossing counts equally.
Practice
03State-space puzzles: jugs, crossings, and timerscoreNew
A farmer must take a fox, goose, and grain across a river, carrying at most one at a time. The fox cannot be left with the goose without the farmer; the goose cannot be left with grain. Give a valid sequence.
04State-space puzzles: jugs, crossings, and timershardNew
A farmer carries at most one of a fox, goose, and grain across a river. Without the farmer, fox with goose and goose with grain are forbidden. Can all cross without ever bringing cargo back?
B. Use volumes and the exact pour rule
For capacities a,b, record current volumes (x,y). Fill, empty, or pour until the source empties or destination fills. Every reachable volume is a multiple of g=gcd(a,b), because each transition preserves integer combinations of the capacities.
The condition is sufficient for an integer target fitting in a jug: repeatedly transferring the smaller jug visits every multiple of g modulo the larger capacity. Filling the larger jug also reaches its capacity.
For a pour from the first jug into the second, the transferable amount is constrained by both the source and the empty destination space:
t=min(x,b−y),(x,y)⟼(x−t,y+t).
The minimum ensures that at least one permitted stopping event occurs. Arbitrarily stopping midway would change the problem. If g=gcd(a,b) divides both current volumes, it also divides b−y and therefore t; filling and emptying preserve the same property. Starting at zero proves necessity.
For sufficiency, repeated transfers produce remainders ma(modb). After dividing by g, the numbers a/g and b/g are coprime, so those remainders visit every multiple of g below b. Thus a target d is attainable in one jug precisely when 0≤d≤max(a,b) and g divides d, under the stated fill, empty, and pour rules.
Practice
05State-space puzzles: jugs, crossings, and timerscoreNew
Empty 2 L and 5 L jugs can be filled, emptied, or poured until a jug fills or empties. Show how to leave exactly 1 L in a jug.
06State-space puzzles: jugs, crossings, and timerscoreNew
A laboratory has empty unmarked 6 mL and 9 mL cylinders and unlimited reagent. Each operation fills a cylinder, empties one, or pours until one is full or the other empty. Show how to isolate exactly 3 mL.
07State-space puzzles: jugs, crossings, and timershardNew
With 4 L and 7 L jugs, the gcd is one. Does that allow a final reading of 9 L in a single jug?
C. Track burn time instead of physical length
A rope with T minutes of one-ended burn-time content finishes in T/2 when both ends are lit under the usual rope model. At an observable event, lighting its other end halves the remaining one-ended duration; uneven physical burning prevents using a geometric midpoint.
Imagine labeling each tiny rope segment by the time one flame would take to consume it. Those times add to T even though the physical lengths are uneven. Two flames consume two minutes of this content per elapsed minute, so they meet after T/2. If a single flame has already burned for t, the remaining content is T−t; lighting the other end then finishes it in
2T−t
additional minutes. The argument uses additive burn-time content and the same local behavior from either direction. Cutting a rope into equal lengths supplies no comparable time guarantee.
Practice
08State-space puzzles: jugs, crossings, and timerscoreNew
Two uneven ropes each burn in 40 minutes from one end. Measure 30 minutes from the start.
09State-space puzzles: jugs, crossings, and timershardNew
A 60-minute rope is cut into equal physical halves. Must each piece burn in 30 minutes from one end?
D. Advance only to observable timer events
A duration-T glass with r minutes remaining gets T−r minutes remaining after a flip. Record each emptying event and every residual time. State whether the measured interval must start immediately or may start at a later event.
Figure6 The first emptying events mark a five-minute interval. The measurement begins three minutes after both hourglasses are started.
Failure to find a schedule is not an impossibility proof; an exhaustive event-state argument or invariant is needed.
At a flip, the sand that had already fallen becomes the sand that still must fall. With total duration T and remaining duration r, that amount corresponds to T−r. Between observable events, advance time by the smallest positive remaining duration and subtract it from every running glass.
A search state therefore contains all remaining durations and whether the target interval has begun. Without a separate clock, “flip after one minute” is not an available move unless another observable event marks that minute. A schedule measuring an interval between two later events need not measure the same duration starting at time zero.
Practice
10State-space puzzles: jugs, crossings, and timerscoreNew
Start 4-minute and 9-minute hourglasses together. Which two initial emptying events delimit a five-minute interval?
11State-space puzzles: jugs, crossings, and timershardNew
An 8-minute hourglass has 3 minutes of sand remaining above. You flip it now. How long until it empties?
E. Minimize elapsed time over weighted transitions
With a lantern and unequal crossing times, a state includes both banks and the lantern’s side. A crossing of one or two people costs the slower traveler’s time; retain the least elapsed time for each state and expand the least-cost unsettled state.
For a≤b≤c≤d, compare 2a+b+c+d with a+3b+d. The latter is better exactly when 2b<a+c; the slowest time cancels. A state search supplies the optimality check.
Figure7 The two-bank timelines compare the 17-minute plan with a 19-minute plan in which the fastest person escorts each other person.
Let D(s) be the least known elapsed time to reach state s. A crossing from s to s′ with cost c updates
D(s′)←min(D(s′),D(s)+c).
Dijkstra's method finalizes the smallest tentative distance because nonnegative future costs cannot improve it via a longer unfinished route. Counting crossings alone would miss their unequal durations.
For four ordered crossing times, the fastest escort plan costs b+a+c+a+d=2a+b+c+d. Sending the two slowest together costs b+a+d+b+b=a+3b+d: the two fastest shuttle the lantern. Subtracting the totals gives a+c−2b, so the saving depends on the extra returns, not on d.
Practice
12State-space puzzles: jugs, crossings, and timerscoreNew
Four people take 1,2,7,10 minutes to cross. At most two share the lantern. Find a fastest complete crossing schedule.
13State-space puzzles: jugs, crossings, and timerscoreNew
A maintenance cart carries at most two technicians through a tunnel and must accompany every trip. Their one-way travel times are 1,4,5,8 minutes, with a pair moving at the slower pace. Find the minimum total to move everyone across.
14State-space puzzles: jugs, crossings, and timershardNew
Two proposed crossing schedules each use five crossings. Does that establish that they take the same time?
Lesson check
15State-space puzzles: jugs, crossings, and timerscoreNew
Two ropes each burn for 60 minutes from one end, possibly unevenly. Describe a way to measure 45 minutes from the start.
16State-space puzzles: jugs, crossings, and timerscoreNew
Can four-liter and six-liter jugs measure exactly one liter under the usual fill, empty, and pour rules?
17State-space puzzles: jugs, crossings, and timerscoreNew
Complete the following related parts.
18State-space puzzles: jugs, crossings, and timerscoreNew
A puzzle’s position is recorded, but whether its sole key is on the left or right is omitted. Why can a shortest-route search based on that record fail?