Two jugs and a tap

The question

You have a 7L jug, a 23L jug, and a tap. Neither jug has any markings.

What is the fewest steps that leave exactly 9L in a jug?

Map every move to find the shortest route

7Land23L· want9L
fillemptypour
(0,0)
(0,23)
(7,16)
(0,16)
(7,9)
(0,23)
(7,16)
(0,16)
(7,9)
4steps
  1. You start with two empty, unmarked jugs: 7L and 23L. The goal is to leave exactly 9L in either jug, using only fills, empties and pours.
  2. At any point you may fill either jug, empty either jug, or pour in either direction. That is only six possible moves.
  3. Write the amount in the 7L jug first and the amount in the 23L jug second. The start is (0, 0), and every move takes one pair to another.
  4. Check every state one move from (0, 0), then two moves away, and so on. The first time 9L appears is the shortest route.
  5. It first appears after 4 steps, with the 9L standing in the 23L jug.

How it works.

  1. 01

    You start with two empty, unmarked jugs: 7L and 23L. The goal is to leave exactly 9L in either jug, using only fills, empties and pours.

  2. 02

    At any point you may fill either jug, empty either jug, or pour in either direction. That is only six possible moves.

  3. 03

    Write the amount in the 7L jug first and the amount in the 23L jug second. The start is (0, 0), and every move takes one pair to another.

  4. 04

    Check every state one move from (0, 0), then two moves away, and so on. The first time 9L appears is the shortest route.

  5. 05

    It first appears after 4 steps, with the 9L standing in the 23L jug.