I know there has to be a way to solve this puzzle with math. I have included a picture, because I don't know the proper terms for this puzzle. I have included two pictures, I believe they are the same problem, along the lines of the famous joke of empty the bucket and the problem as been reduced to the previous solution. I am sorry if this is a repeated question, as I have no idea the proper terms to search for a solution or explaining paper. Also, I don't know how to properly tag this question.

ps. Ok, get is getting cold here and I have spent to much time trying to solve this that I am dreaming about it. Any help would be great.