Another easy way to solve the bucket problem:
Fill the 3 gallon jug with a full five gallon jug. This leaves two gallons in the fiver. Empty the three gallon jug, and then dump the two gallons from the five into the three. Now, refill the five. At this point, all you need to do is fill up the remaining gallon space in the three gallon jug with the fiver, which will leave the fiver filled with four gallons.
The upshot of this one is that you only waste three gallons, unlike LD's solution, which will lead to five gallons lost forever YOU WASTEFUL BASTARD