# The tavernero problem

A man enters the village tavern and asks to put 4 liters of wine. The worried bartender tells him:

- Wouldn't it be the same to buy 5 or 3 liters? is that I only have an 8-liter barrel full of wine and two containers: one of 3 liters and another of 5.

- No, no, says the man, 4 liters are what I want.

And here is that the innkeeper after a few seconds of reflection manages to serve the exact 4 liters using the containers he has.

Can you think of how to do it?

#### Solution

First, the innkeeper begins by completely filling the 5-liter container so that 3 liters will remain inside the barrel. Then fill the 3-liter container with the contents of the 5-liter container, in which only 2 liters will remain. Pour the 3 liters of the small container into the barrel where with the remaining 3 there will now be 6. The 2 liters that are in the 5-liter container passes them to the 3. Fill the 5-liter container with the wine that is in the barrel, where only 1 liter will remain and finally ends up filling the 3-liter pot (where there were only 2 liters) with the wine that has the 5-liter container in which, finally, only the four liters remain You have to serve the customer.