# The Three Glass Problem

I just came across the so called “Three Glass Problem” and thought I would try and solve it. It turns out to be fairly trivial with a bit of abstract algebra!

Obviously there are spoilers ahead if you have never heard of this problem. So turn away now if you care for the challenge!

The problem goes as follows: Given 3 cups, one that holds 8 units of liquid, one that holds 5 units of liquid, and one that holds 3 units of liquid, create two servings 4 units in volume.

Here is your final warning if you want to work this out for yourself. Below is my solution.

For the sake of clarity, I’m going to say the goal is to measure out 2 drinks of 4 fluid ounces each. Knowing that we have to create two drinks, I assumed each drink had to be created with the 3 ounce cup and one of the other cups. Since we can fill cups and combine them and dump them when full, I thought of cyclic groups with addition mod $n$ as a perfect model for this problem. Specifically, $\mathbb{Z}_8$ and $\mathbb{Z}_5$ will be used here.

As a reminder the cyclic group $\mathbb{Z}_n$ is the group under addition mod $n$, where the group elements are $0,1,2, \ldots, n$. Another term we need is the group “generated” by $a$, where $a$ is in $\mathbb{Z}_n$. So the group generated by $a$ looks like: ${a, 2a, 3a, \ldots, 0}$.

The group generated by $3$ in $\mathbb{Z}_8$ is ${3, 6, 1, 4, 7, 2, 5, 0}$.

Similarly, the group generated by $3$ in $\mathbb{Z}_5$ is ${3, 1, 4, 2, 0}$.

So following these “instructions” gives you this:

First, fill the 3 and pour it into the 8 twice, giving you 6 in the 8. Fill the 3 again, top off the 8, giving you 1 in the 3. Dump the 8 and move the 1 from the 3 to the 8. Fill the 3 one last time, and transfer to the 8. Boom, first drink done.

Now take fill the 3 and pour it into the 5. Fill the 3 and top off the 5, giving you 1 in the 3 and dump the 5. Transfer the 1 to the 5, and add one last 3. This gives you the second 4 ounce drink. QED.

Thanks for reading this post! Comments, questions, and feedback are always welcome.