Question: If you had an infinite supply of water and a 5 quart and 3 quart pails, how would you measure exactly 4 quarts? and What is the least number of steps you need?


Answer: Lets count the steps as we move along

  1. Fill 5 quart pail with water
  2. Transfer 3 quart of water from 5 quart pail to 3 quart pail
  3. Make empty 3 quart pail
  4. Transfer remaining 2 quart of water from 5 quart pail to 3 quart pail
  5. Fill 5 quart pail with water
  6. Transfer 1 quart of water from 5 quart pail to 3 quart pail
  7. Remaining water in 5 quart pail is 4 quart

General steps are to fill up the 3 quart pail and keep transferring to the 5 quart pail (empty if full) until we hit 4 quarts. Therefore, the total amount of water we filled in the 3 quart pail must be equal to 4 more than a multiple of 5 (since we discard 5 quarts of water at a time).

5 * n + 4 = 3 * m, where n and m are arbitrary positive integers

n represents the number of times we had to empty the 5 quart pail and m represents the number of times we had to fill up the 3 quart pail. Now all we have to do is solve for the lowest set of positive integer solutions for {n,m}. {1, 3} is the lowest set. Some of the other solutions are {4, 8}, {7, 13}, {10, 18} and so on.