Generalization of the two bucket puzzle The classic puzzle goes something like this: "You are standing in front of a lake with a 3 gallon bucket and a 5 gallon bucket, how can you get 4 gallons of water?"
Is there an easy way to generate the triple (A,B,C) where you can get C gallons of water using buckets of size A and B?
 A: Not an answer but rather a good thing to look at in connection with the problem-
http://numb3rs.wolfram.com/501/puzzle.html
A: Yes. The answer follows from Bezout's theorem which says that given integers A,B and C, C can be written as XA+YB if and only if C is a multiple of the highest common factor of A and B. Euclid's algorithm tells you how to compute X and Y.
It is not too hard to see that the only volumes you can get are ones of the that are integer linear combinations of A and B and you can  get every positive volume that arises in this way (as long as you have a large enough additional container to store it all).
A: Mathloger has a beautiful video about this, here.
A: I am not a professional mathematician but a software developer given the generalization of this problem as a coding challenge.  I implemented a simple site and open-sourced the code much to the help of this thread clarifying the equation so thought it would be a valuable addition.  
My algorithm code can be seen at https://github.com/metame/infinite-lake/blob/master/app/js/algorithm.js.
A: Simon's answer points out that the Euclidean algorithm shows that gcd(A,B) divides C is necessary, but the lack of large container makes the problem more difficult, because obviously you can't get $C$ if $C \gt A+B$.  However, the following modification of the algorithm seems to work.
Let's assume $A \lt B$ and gcd$(A, B)=1$ for simplicity.  By pouring from B into A and dumping A, you can get any positive integer $B-nA$ left in B.  Do this until the answer is less than $A$.  Then by transferring the contents to bucket A and filling it from B into it, we get $2B-(n+1)A$.  Then subtract $A$ again until you have $0 \lt 2B-kA \lt A$, and we can iterate this process to get $3B-(k+1)A$, etc.  This gives any integer linear combination $rB-sA$ up to the size of $A+B$ because once you get the right multiple of $B$ into the combination, you can always add bucketsful of $A$.  
You just need to get $rB\equiv C$ (mod A) in order to find a combination for $C$, which happens if gcd$(A, B)=1$.  With this algorithm run in the general case you can get any multiple of gcd($A, B$) up to $A+B$ (this holds trivially when $A=B$).  
(Sorry, I had to edit this answer several times because parts disappeared, until I realized that my inequality signs were being parsed as HTML tag starts even after dollar signs.)
