drslax / thirst_men_problem

This riddle describes a difficult readlock problem in a multi-agent system. Enjoy the riddle ;)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thirsty men problem

On a hot day, a water outage occured while you were feeling very thirsty. You went to the fridge to get some cold water. You were lucky enough and you found a single bottle of water left. While you were enjoying this finding and tossing your bottle in the air. Ding dong, somebody rang at the door.

You had got N unexpected guests, all of them staring at the bottle in your hand, and suddenly shouting all once "we are thirsty". You let them in, and you all gathered in the same room around a table and everybody asked you to drink.

Now the problem :

The bottle (½ littre) can only fill 3 cups.

To overcome this problem you've ingeniously proposed a solution. You gave them each an empty cup and told them :

”Look guys I will drink a cup and give you 2 cups of water. But, I'll fill only the first and the last cups put on the table before me. The intermediaries cups will remain empty”

illustration

Besides your main rule, you agreed upon the following terms:

  • It's only you who can pour water
  • The cups can be filled only if all of them are put .
  • The cups should be put in a row (the first one is the head of the row and the last is the tail). We can assume that the pourer has marked the final spots (first place, second,.. last), so each cup should be placed in one of these positions.
  • No timer will be used and the game doesn't have a timeout.
  • It's up to you to determine who is the first depositor/winner in case they race to put the first cup (in the first position).
  • You will act with honesty 🐧

The question : In this context, how would your guests behave, if you know that they are smart and can cheat 😈 (but cannot kill each other 💀)? Would there be a good compromise avoiding a deadlock?

To make the situation more real let's assume that 2<N<15

If you have questions

If you require additional information about the problem please open an issue in this repository. I'll provide the necessary clarifications

How to propose solutions

Please fork/clone the repository, write your solution in a txt file under solutions folder and then propose a pull request. If the answer is correct the pull request will be accepted and you'll be added as contributor.

About

This riddle describes a difficult readlock problem in a multi-agent system. Enjoy the riddle ;)