IBM Research

PUZZLE   IBM-321

The irrational three-jug problem

IBM Research · Ponder This · 2025-01

IBM Ponder This #321 · January 2025

This puzzle was suggested by Latchezar Christov - thanks!

Three jugs A, B, and C have volumes VA=5, VB=3, and VC=2 liters, respectively. There is a tap from which we can fill the jugs, and a sink into which we can empty them. At the beginning of the problem, the three jugs are empty.

To achieve the solution of the problem, we perform a sequence of steps that can only be one of the following:

  • Pour water from the tap into a jug until it is filled to the top.
  • Empty a jug into the sink.
  • Pour water from one jug into another until either the source jug is empty or the receiving jug is filled to the top, whichever happens first.

We assume that these steps are performed with absolute accuracy and no water is spilled.

Our goal is to measure a specific amount of water, meaning we seek to arrive at a state where any one of the jugs (no matter which one) contains this specific amount. As it is impossible to measure with these jugs any rational, non-zero volume with a finite number of steps, we will relax the condition: Instead of measuring a volume of 1, we measure a volume of 1±0.0003 liters, i.e., any volume in the interval [0.9997,1.0003] will suffice.

The solution should be presented as a list of two-letter strings that represent the steps of the solution, in which the first letter denotes the source, and the second letter denotes the recipient. The tap is denoted by T and the sink by S. The list should also be preceded by a number representing the minimum number of steps.

For example: If the task is to measure 1±0.01 liters, the fastest solution would require six steps and could be described as
6 TA AB BS AB TA AB
Upon completion of the above sequence of six steps, jug A would contain 1.00803 liters of water, a volume within the specified tolerance.

Your goal: Find a sequence of steps measuring 1±0.0003 liters such that the number of steps is minimal. Submit your answer using the above format.

A bonus "*" will be given for solving the following problem: Keeping the same jugs A and B, replace jug C with one of the volume VC such that:

  1. VC is a rational number: VC=pq, where p and q are integers.
  2. VC<VB.
  3. 1±108 liters can be measured with 11 steps.
  4. 11 is the minimum possible number of steps.
  5. q has the smallest possible value.

Submit VC in the form pq and a description of the steps in the above format.

Solution

Best opened after a real attempt

To be added.