7–0 : First fill bucket a
2–5 : Then use bucket a to fill bucket b, leaving 2 gallons in bucket a
2–0 : Dump bucket b
0–2 : Dump the 2 gallons from a into b
7–2 : Fill bucket a again
4–5 : Fill bucket b with bucket a leaving 4 gallons in bucket a
4–0 : Dump bucket b
0–4 : Pour the 4 gallons from bucket a into bucket b
7–4 : Fill bucket a
6–5 : Use bucket a to fill bucket b leaving 6 gallons in bucket b
6–0 : Dump bucket b and you are left with 6 gallons