Here is the answer. If you don’t want to know yet don’t look.
Answer:
He fills the 3-gallon bucket and pours it into the 5-gallon bucket. He again fills the 3 gallon bucket, and pours into the 5 gallon bucket till it is full, leaving 1 gallon in the 3 gallon bucket. He empties the 5-gallon bucket and pours the 1-gallon remaining in the 3-gallon bucket into the 5-gallon bucket. He then refills the 3 gallon bucket and pours it into the 5 gallon bucket which now contains exactly 4 gallons, give or take a drop or 2. There is another similar solution, but I don’t remember it.
