Books · The Fiddler: Solutions
Chapter 24
Some Coffee With Your Tea?
One glass holds exactly fluid ounces of coffee, another exactly fluid ounces of tea. Pour one ounce from the coffee glass into the tea glass and mix thoroughly. Then pour one ounce from the (mostly) tea glass back into the coffee glass and mix. Is there now more coffee in the tea glass, or more tea in the coffee glass?
The Fiddler, Zach Wissner-Gross, January 9, 2026(original post)
Solution
They are exactly equal, and no arithmetic is needed. Both glasses start and end with ounces. So whatever volume of coffee has left the coffee glass for good must have been replaced by an equal volume of tea, simply to keep the coffee glass at ounces. The coffee that left now sits in the tea glass; the tea that arrived is the tea now in the coffee glass. These two volumes are equal: Tracking the ounces confirms it. After the first pour the tea glass holds ounces, of it coffee; the ounce poured back therefore carries ounce of coffee and ounce of tea. The coffee glass ends with ounce of tea, and the tea glass ends with ounce of coffee.
The computation
Carry out the two pours on the actual contents, tracking the coffee and tea in each glass and transferring in proportion to the current mix. Both cross-contaminations come out to ounce.
from fractions import Fraction as F
coffee, tea = {'C': F(12), 'T': 0}, {'C': 0, 'T': F(12)}
def pour(src, dst, v):
tot = src['C'] + src['T']
for k in ('C', 'T'):
amt = v * src[k] / tot; src[k] -= amt; dst[k] += amt
pour(coffee, tea, 1); pour(tea, coffee, 1)
print(tea['C'], coffee['T']) # 12/13 12/13 -> equal
Extra Credit
Now both glasses can hold up to ounces; one starts with ounces of coffee, the other with ounces of tea. To dilute the coffee glass you repeat: pour some volume of tea in, mix, then pour that same volume down the sink so ounces remain. Doing this as often as you like, what is the least coffee you can be left with in the glass?
Solution
Each wash adds ounces of tea to the already present, then discards a fraction of the now-uniform mixture, so the coffee is multiplied by . The whole tea glass holds only ounces, so the wash volumes obey . By the AM–GM inequality the dilution is best with equal washes , leaving as the washes grow ever more numerous and ever smaller. (The source’s value is behind its paywall; this is my own.)
The computation
Run the washes: for equal pours of , multiply the coffee by its dilution factor each time. As grows the leftover coffee falls toward .
import numpy as np
def wash(k):
coffee = 12.0; v = 12.0/k
for _ in range(k): coffee *= 12/(12 + v) # add v tea, mix, discard v
return coffee
for k in (1, 2, 10, 1000):
print(k, round(wash(k), 5))
print("limit 12/e =", round(12/np.e, 5)) # 4.41455