Die Harder

There is a 3-gallon jug and a 5-gallon jug next to a fountain with infinite water. Your goal is to fill the 5-gallon jug with exactly 4 gallons of water by filling, emptying, and pouring between the jugs.

Variables

Your spec should contain two variables:

  • small — the number of gallons currently in the 3-gallon jug.
  • big — the number of gallons currently in the 5-gallon jug.

Initial State

Both jugs initial start without any water.

Transitions

At each step any of the following can happen

  • Fill the small jug to its capacity (3).
  • Fill the big jug to its capacity (5).
  • Empty the small jug.
  • Empty the big jug.
  • Pour from the small jug into the big jug until the big jug is full or the small jug is empty.
  • Pour from the big jug into the small jug until the small jug is full or the big jug is empty.
die-really-hard
Ready
⌘↵ to submit