If friend buy native a attach in this post, I may earn a commission. This does not impact the price you pay. Together an Amazon Associate ns earn native qualifying purchases. Learn more.

You are watching: 5 gallon jug and 3 gallon jug

Posted February 4, 2013 through Presh Talwalkar. Read around me, or email me.

This is a trouble that is prominently featured in the movie Die hard With a Vengeance.

You have actually a 3-gallon and also a 5-gallon jug that you can fill native a spring of water.

The difficulty is to fill among the jugs with exactly 4 gallons of water. Exactly how do you do it?

Video: Die hard 3 The Water Jug mathematics Riddle

. ."All will certainly be fine if you usage your psychic for your decisions, and also mind only your decisions." since 2007, i have dedicated my life to share the delight of game theory and mathematics. betterworld2016.org now has actually over 1,000 cost-free articles v no ads many thanks to community support! aid out and get early accessibility to short articles with a pledge top top Patreon.

. . . . . . M i N D . Y O U R . D E C i S i O N S . W E E K l Y . P U Z Z together E . . . . Answer come the water jug riddle

Math In Movies: The Water Jug Riddle native Die tough With A Vengeance (1995)

The an initial attempt human being have is to try and calculation 4 gallons by including 3 gallons the water come 1/3 of the 3 gallon jug. But the riddle is asking for a an exact measurement and so this solution cannot work.

The trick is to realize that:

5 – 3 = 2 and also 5 – (3 – 2) = 4

Here is one way to discover the answer:

Incidentally, the reason we can find a solution is since the two numbers 5 and also 3 are fairly prime–that is, they have no usual divisors. We have the right to actually generate any kind of volume the water native 1 to 5 (in fact, we did gain measurements the 1, 2, 3, 4, and also 5 along the means in our solutions).

The more general trouble is finding integer remedies for the equation ax + by = c. Solutions (x,y) exist when the greatest usual divisor the a and b is a element of c. This is an old problem. For more, read this article: http://mathforum.org/library/drmath/view/51595.html ——————————————————— (This is the solution in plain text)

1. Fill up the 5-gallon jug 2. Fill up the 3-gallon jug using the water indigenous the 5-gallon jug (leaving 2 gallons in the 5-gallon jug) 3. Pour out the 3-gallon jug right into the spring 4. Carry the 2 gallons native the 5-gallon jug into the 3-gallon jug 5. Fill up the 5-gallon jug 6. Transport water indigenous the 5-gallon jug until the 3-gallon jug is full. Because the 3-gallon jug currently had 2 gallons the water, over there is room for just 1 gallon. 7. The lot of water in the 5-gallon jug is exactly 4 gallons

If we denote the components of the jugs together the pair (5-gallon jug amount, 3-gallon jug amount), the sequence of events is:

(5, 0)–>(2, 3)–>(2, 0)–>(0, 2)–>(5, 2)–>(4, 3)

That’s no the only path. We can additionally consider the route:

1. To fill up the 3-gallon jug 2. Carry to the 5-gallon jug 3. Fill up the 3-gallon jug again 4. Move water to to fill up the 5-gallon jug, leaving 1 gallon in the 3-gallon jug 5. Empty out the 5-gallon jug 6. Transfer the 1 gallon come the 5-gallon jug 7. To fill up the 3-gallon jug and transfer that to the 5-gallon jug 8. The 5-gallon jug contains 4 gallons the water

The sequence here is:

(0, 3)–>(3, 0)–>(3, 3)–>(5, 1)–>(0, 1)–>(1, 0)–>(1, 3)–>(4,0)

### PRESH TALWALKAR

I run the betterworld2016.org channel on YouTube, which has over 1 million subscribers and also 200 million views. I am also the author of The delight of video game Theory: An development to strategic Thinking, and also several other publications which are available on Amazon.

(As you could expect, the web links for my books go to their listings ~ above Amazon. Together an Amazon Associate i earn from qualifying purchases. This walk not impact the price girlfriend pay.)

By means of history, I started the Mind your Decisions blog ago in 2007 come share a bit of math, personal finance, an individual thoughts, and also game theory. It"s been rather a journey! I thank everyone that has shared my work, and also I am very grateful for coverage in the press, consisting of the Shorty Awards, The Telegraph, Freakonomics, and many other popular outlets.

I learned Economics and also Mathematics in ~ Stanford University.

People often ask how I make the videos. Like many YouTubers i use popular software come prepare my videos. You have the right to search for animation software tutorials top top YouTube to learn how to make videos. Be prepared--animation is time consuming and software have the right to be expensive!

Feel complimentary to send me an email . I gain so plenty of emails the I may not reply, yet I conserve all proposal for puzzles/video topics.

### MY BOOKS

If you purchase through these links, I might be compensated because that purchases make on Amazon. As an Amazon Associate ns earn indigenous qualifying purchases. This go not impact the price you pay.

Book ratings are from June 2021.

Mind your Decisions is a compilation of 5 books:

(1) The happiness of video game Theory: An arrival to strategy Thinking (2) 40 Paradoxes in Logic, Probability, and Game concept (3) The Irrationality Illusion: how To do Smart Decisions and Overcome prejudice (4) The ideal Mental math Tricks (5) Multiply number By drawing Lines

The pleasure of video game Theory shows just how you can use math to out-think her competition. (rated 4.2/5 stars ~ above 200 reviews)

40 Paradoxes in Logic, Probability, and also Game Theory has thought-provoking and also counter-intuitive results. (rated 4.1/5 stars top top 30 reviews)

The Irrationality Illusion: exactly how To do Smart Decisions and also Overcome Bias is a handbook that defines the numerous ways we room biased about decision-making and also offers techniques to make smart decisions. (rated 4/5 stars on 17 reviews)

The best Mental mathematics Tricks teaches how you can look prefer a math genius through solving troubles in her head (rated 4.2/5 stars on 57 reviews)

Multiply number By illustration Lines This book is a reference overview for my video clip that has actually over 1 million see on a geometric an approach to main point numbers. (rated 4.1/5 stars top top 23 reviews)

Mind your Puzzles is a collection of the three "Math Puzzles" books, quantities 1, 2, and also 3. The puzzles topics incorporate the mathematical subjects including geometry, probability, logic, and also game theory.

Math Puzzles Volume 1 attributes classic mind teasers and riddles with finish solutions for difficulties in counting, geometry, probability, and game theory. Volume 1 is rated 4.4/5 stars on 75 reviews.

Math Puzzles Volume 2 is a sequel publication with more great problems. (rated 4.3/5 stars on 21 reviews)

Math Puzzles Volume 3 is the 3rd in the series. (rated 4.3/5 stars on 17 reviews)

### KINDLE UNLIMITED

Teachers and students approximately the people often email me around the books. Due to the fact that education can have such a huge impact, I try to do the ebooks available as widely as possible at together low a price as possible.

Currently you can read many of mine ebooks with Amazon"s "Kindle Unlimited" program. Contained in the subscription you will certainly get access to millions of ebooks. You don"t need a Kindle device: you have the right to install the Kindle application on any smartphone/tablet/computer/etc. I have compiled links to program in some nations below. Please inspect your local Amazon website for access and routine terms.

See more: What Was The Drug That Hermes Gave Odysseus To Help Resist The Magic Of The Witch-Goddess?

US, list of my books (US) UK, list of my books (UK) Canada, publication results (CA) Germany, list of my publications (DE) France, perform of my books (FR) India, perform of my publications (IN) Australia, book results (AU) Italy, perform of my publications (IT) Spain, perform of my publications (ES) Japan, perform of my books (JP) Brazil, book results (BR) Mexico, book results (MX)

### MERCHANDISE

Grab a mug, tshirt, and more at the official site because that merchandise: Mind your Decisions in ~ Teespring.