Four friends are gathered at a pub. They have in front of them two 8-pint trankards full of beer, and an empty 3-pint mug.

Since they are still sober, they quickly calculate that they have 16 pints for the four of them, which comes out to an even 4 pints per person.

Can they divide the beer equally with the containers they have available?

There may be a better way of doing this, but, let's use A, B and M to indicate the contents of the two tankards and the mug, as before. Also W, X, Y and Z to indicate how much the four friends have drunk.

-To begin with we have:

A8 B8 M0 - W0 X0 Y0 Z0

-Fill M from A - W drinks this

A5 B8 M0 - W3 X0 Y0 Z0

-Fill M from A again - X drinks A (2 pints)

A0 B8 M3 - W3 X2 Y0 Z0

-Pour M back into A, fill M from B, and pour M back into A once more

(A6 B5 M0)

-Fill M from B once more and top up A from M - W drinks from M (1 pint left)

A8 B2 M0 - W4 X2 Y0 Z0

-Pour B into M and top up from A. Pour back into B once more.

(A7 B3 M0)

-Fill M from A and pour into B - fill M from A once more

(A1 B6 M3)

-Y drinks from A, then B is topped up from M, and Z drinks M (1 pint left)

A0 B8 M0 - W4 X2 Y1 Z1

-From here it's a simple matter of pouring out two mugs (one for Y and one for Z) and letting X have the rest - everyone will have had 4 pints each.