ctci/06. Math and logic puzzles/6.5. Jugs of water.md

695 B

6.5. Jugs of water

You have a five-quart jug, a three-quart jug, and an unlimited supply of water (but no measuring cups). How would you come up with exactly four quarts of water? Note that the jugs are oddly shaped, such that filling up exactly "half" of the jug would be impossible.

How about filling the 5-quart jug to the top, then pour it to the 3-quart jug to the top. There are 2-quarts remaining in the big jug. Do that twice, you get the 4 quarts. But how to save?

  1. Fill big one
  2. Transfer to small
  3. Dump small
  4. Transfer the 2q to small
  5. Fill big one again, now we have 5q in big and 2q in small
  6. Transfer 1q to the small until full, we're left with 4q in the big one.