# With a 45-gallon and a 124-gallon jug with no marketings (but known capacities), how do you measure exactly 1 gallon of water?

I could imagine filling up the $124$, then filling the $45$ from it, so there is $124-45=79$ left in the $124$, then again so there is $37$. Then I'm lost!

You could use the 124-gallon jug four times to get 496 gallons, and subtract the 45-gallons 11 times to get 1 gallon.

How to solve:

Let $x$ be the number of 124-gallons and $y$ the number of 45-gallons. We want solutions to

$$124x + 45y = 1$$

Obviously, one will be negative. Taking modulo 45, we get

$$34x = 1 \mod 45$$

Multiplying by $34^{-1} = 4$, we see $x = 4 \mod 45$ and when $x = 4$, $y = -11$.

If you don't have free extra cups, then you could do this but just make sure you don't go over the 124 limit. So fill the the 124-gallon jug, take out 45 as many times as you can until you get 37 gallons. Then fill the 45-jug with all 37 gallons, refill the 124-jug and repeat. You will end up refilling 4 times and throwing away water 11 times.

If you don't have spare cups, the exact path would look like this, where (r) represents refilling the 124-gallons jug and --> indicates that you emptied the 45-gallon jug.

124 0 (r)
79 45-->0
34 45-->0
0 34
124 34 (r)
113 45-->0
68 45-->0
23 45-->0
0 23
124 23 (r)
102 45-->0
57 45-->0
12 45-->0
0 12
124 12 (r)
91 45-->0
46 45-->0
1 45-->0 (Solution)

• I think you want $y=-11$.
– Ian
Commented Dec 3, 2015 at 2:32
• @Ian Yeah thanks Commented Dec 3, 2015 at 2:33
• How does that work exactly unless you have somewhere to put the water? Commented Dec 3, 2015 at 2:37