This puzzle is often asked to solve in interviews. Check if you can beat her and win the employer's heart.

Three machines with ice cream, which operate on the principle of self-service, were delivered to the food court of the shopping center. Visitors take the cone and approach the machine with the taste they like: one gives out a vanilla dessert, the second a chocolate one, and the third fills the cone in a random way - either vanilla or chocolate. For any ice cream, you will give one coin.

Each vending machine has a sticker with the name of the offered flavor. True, there was some kind of malfunction at the plant, so all the stickers were mixed up. Now the wrong one hangs on each of the devices. How many coins do you need to spend to find out where is which machine?

First, let's give each of the machines a name:

1. "Vanilla".

2. "Chocolate".

3. "Random".

Now let's take one coin and put it into the slot machine with the "Random" sticker. The inscriptions always lie, which means that the vending machine definitely cannot dispense random ice cream. We can determine its true name based on the taste of the dessert that will be given to us. Let's say we were offered vanilla ice cream, so this is a machine called "Vanilla".

Then everything is simple. There are still machines with two stickers: "Chocolate" and "Vanilla". But we've already found the source of vanilla ice cream. Thus, there are only two options left: a device that gives out a random taste, and one that is guaranteed to fill the cone with only chocolate dessert.

Again, we remember that stickers are always deceiving us. So the vending machine labeled "Chocolate" can't really dispense chocolate ice cream. This is "Random".

The remaining device with the "Vanilla" sticker offers exclusively chocolate ice cream.

Answer: we only need one coin to understand what kind of ice cream the machines give out.

Show solution Hide solution