# A Set of Water Jug Challenges

You've probably heard about challenges with water jugs, so why not try a few?

1. Use 3- and 5- liter jugs to get 4 liters.
2. Use 5- and 7- liter jugs to get 4 liters.
3. This one's different. How many different exact measurements can you get using only 8- and 11- liter jugs (not including 0 liters)?
4. Use 3- and 11- liter jugs to get 7 liters.

These numbers are made by me, so if any of these exactly match the popular ones out there (except for the first one), it is purely coincidental.

Note: accepted answer is the one that is first with all 4 correct answers.

(example with 5- and 8- liter jugs to get 6 liters)
0-0, 0-8, 5-3, 0-3, 3-0, 3-8, 5-6

1. 3-0, 0-3, 3-3, 1-5, 1-0, 0-1, 3-1, 0-4.
2. 5-0, 0-5, 5-5, 3-7, 3-0, 0-3, 5-3, 1-7, 1-0, 0-1, 5-1, 0-6, 5-6, 4-7.
3. You can get 19 exact measurements (1 litre - 19 litres) not including 0 litre.
4. 3-0, 0-3, 3-3, 0-6, 3-6, 0-9, 3-9, 1-11, 1-0, 0-1, 3-1, 0-4, 3-4, 0-7.

For $1,2,4$ you can just fill one jug, fill the other from it, and repeat until solved. This will work for any jug contents as long as they have no common factor. If they have a common factor, you can only get multiples of the common factor. One direction will be faster than the other for a given target.

For 3, you can get any number from $1$ through $11$ in the $11$ jug, and have the $8$ full or not, so you can get anything $1$ through $19$, for $19$ values.

• To clarify: 7 in either jug is still the same measurement, and the same goes for 6, 5, etc. Aug 5, 2014 at 23:08
• True, that is how I counted it. I was counting the number of total amounts of water in the two jugs that you can achieve. Aug 5, 2014 at 23:45
• I said in the question that 0 liters does not count. I just realized that error in your answer. Aug 6, 2014 at 18:36
• OK, fixed........ Aug 6, 2014 at 19:41

As I said in another post, the general solution for jug A and B is:

• If A is empty, fill A
• If B is full, empty B
• else transfer what you can from A to B.
• stop when you have the wanted quantity.

Depending on which jug you choose as A or B, you get 2 solutions. One of them is optimal.

For number 3, here's a sequence that hits every number from 1 to 19:

0+0=0
0+11=11
8+3=11
0+3=3
3+0=3
3+11=14
8+6=14
0+6=6
6+0=6
6+11=17
8+9=17
0+9=9
8+1=9
0+1=1
1+0=1
1+11=12
8+4=12
0+4=4
4+0=4
4+11=15
8+7=15
8+0=8
0+8=8
8+8=16
5+11=16
5+0=5
0+5=5
8+5=13
2+11=13
2+0=2
0+2=2
8+2=10
0+10=10
8+10=18
8+11=19


For 1:

0-5, 3-2, 0-2, 2-0, 2-5, 3-4