This puzzle dates back at least as far as the 1920s, and quite possibly earlier still.

The solution is as follows:

#First, fill the 3-liter container to the brim.

#Pour the 3 liters of water into the 5-liter container.

#Fill the 3-liter container again.

#Pour water from the 3-liter container into the 5-liter container until it is filled to the brim. This should leave you with 1 liter of water in the 3-liter container.

#Empty out the 5-liter container, then pour the 1 liter of water into it from the 3-liter container.

#Fill the 3-liter container once more, then pour the water from both containers into the third container.

An alternate solution with fewer fills:

# Fill the 5-liter container.

# Fill the 3-liter container from the 5-liter container, leaving 2 liters.

# Empty the 3-liter container. Then, pour the remaining 2 liters from the 5- to the 3-liter container.

# Refill the 5-liter, then fill the 3-liter from the 5-liter container. Leaving 4 liters in the 5-liter container.

Another alternate solution, though this one requires several assumptions: The containers must have at least one line of symmetry when looking at them from the top, and they must have a constant width. (Cylinders or rectangular prisms meet this requirement.)

# Fill the 5-liter container, then place one part of the bottom down, and tilt it until the water level makes a straight line from the upper edge of the bottom to the bottom edge of the lip.

# Do the same thing with the 3-liter container, and pour it into the 5-liter container.

# 2.5 + 1.5 = 4

It bears noting that this puzzle, like many other stock puzzles, is usually difficult only because the solver is overthinking it. In practice, if you actually have the two jugs, and you just start filling one jug and pouring it into the other, the solution presents itself very quickly. (This is incorporated in some tellings of the riddle, which demand that you come up with the answer in less than a minute, as an Aesop about the value of trying things out rather than just sitting there thinking.)

Maths nerd bit: You're looking for the smallest ''x'' and ''y'' that satisfy 3''x''−5''y''=4; then fill the 3-liter ''x'' times, pouring it into the 5-liter when full, and emptying the 5-liter when it's full (which you'll do ''y'' times). The solution is ''x''=3 and ''y''=1. The alternate solution up there is the dual formulation, 5''x''−3''y''=4 (''x''=2, ''y''=2). From here, two details present themselves: one, that it's easily adaptable to other values other than 3 and 5, and two, that a solution exists only if the target value is either a factor or a multiple of the highest common factor of the container sizes (e.g. you can't get 4 liters from 6- and 3-liter containers).

----

!!Examples

[[AC:AlternateRealityGame]]

* ''PerplexCity'' used this one on a card.

[[AC:{{Film}}]]

* In the movie ''Film/DieHardWithAVengeance,'' the two main characters must solve this type of puzzle in order to disarm a bomb near a public fountain.\\

[[WhatCouldHaveBeen In the original script]], the bomb was a ChekhovsGun, as the movie would end with [=McClane=] planting the bomb on the bad guy's helicopter, and upon discovery one of them [[GallowsHumor asks]] [[BrickJoke if anyone has a four gallon jug]] (in the final script the bomb was used for something else entirely without the puzzle being brought up again).

[[AC:VideoGames]]

* This puzzle appears in ''KnightsOfTheOldRepublic'' on Manaan, and solving it is a prerequisite for the "good" ending on that planet.

* This puzzle and several variants appear in the ''ProfessorLayton'' series.

* A slight variant with different values in ''VideoGame/ZorkZero'', a game almost entirely composed of [[StockPuzzle stock puzzles]].

* This puzzle appears pretty much verbatim in ''The Castle of Dr. Brain'', an old MS-DOS game where you essentially had to solve nothing ''but'' different types of [[StockPuzzle puzzles]] from all across the spectrum in order to progress through the titular castle.

* A variation of this puzzle occurs in ''FatalHearts'', where you need ⅔ cup of flour but have only an 800ml cup and a 100ml cup. The puzzle's not too hard if you're good at conversions.

* An apparently more complex version of this classic puzzle appears at the end of ''VideoGame/SherlockHolmesVersusArseneLupin'', where you have to measure exactly 478cc of black powder with only 250cc, 80cc and 12cc containers at your disposal. I say apparently only, because [[spoiler:1×250 + 19×12=478, so you don't actually have to use the pour-bigger-into-smaller subtraction trick at all to solve it]].

** [[spoiler:It ''can'' be done much faster with the pour-bigger-into-smaller trick, though: 1x250 + 3x80 − 1x12=478.]]

** The original version also appears in "SherlockHolmesAndTheMysteryofTheMummy" as well as "SherlockHolmesAndTheMysteryofthePersianCarpet" (Which borrowed every other puzzle too)

* Appears in ''{{Runescape}}'', among other {{Stock Puzzle}}s.

* Appears in ''{{Videogame/Phantasmat}}'' as an unusual method of switching on a generator.

* Done with [[spoiler: lava]] in the last chapter of the Wii ''CarmenSandiego'' game.

* In ''[[Creator/ZapDramatic Sir Basil Pike Public School]]'', if you pick the boy's path, you must solve this puzzle for the janitor before heading to the tennis court. (The girl's path has a KnightsAndKnaves puzzle instead.)

----