Code Monkey home page Code Monkey logo

thirst_men_problem's Introduction

Thirsty men problem

The scene

On a hot day, a water outage occurred 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 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 the 2 remaining 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 (You are the host)
  • The cups can be filled only if all of them are put on the table.
  • 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. However, if a timeout can help solve this problem you can set one (1 < x days).
  • 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 honestly ๐Ÿง , however the guests can behave honestly or dishonestly
  • A guest can drink only from his cup, but he can give his cup to another player.
  • The host is only responsible of pouring water. He is not to be involved in your solution. He ensures that the rules as executed as defined.

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 (winning strategy) 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 the /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.

This problem is not a simple riddle but it requires a creative mind

thirst_men_problem's People

Contributors

bellaj avatar ethereumx avatar

Stargazers

mohamed amine ozennou avatar Zak avatar Lakhder Amine avatar Yassine Afnisse avatar ROUSHAN KUMAR avatar Safir Mohammed avatar Yassir Elkoraichi avatar Mehdi Ouled-Hali avatar  avatar Ayoub BOUMZEBRA avatar Robert Bright avatar Mohamed Amine LEGHERABA avatar  avatar  avatar Christian W. avatar NAIT BELKACEM avatar Bareich Tareq avatar

Watchers

James Cloos avatar Anas avatar  avatar  avatar  avatar

thirst_men_problem's Issues

Question

can guests agree to prevent someone from putting his cub ?

Clarification request : fisrt and last cups put

In the statement said by the host : "I'll fill only the first and the last cups".
The first and last cups are those placed in the head and the tail of the row ?, or they can be in any position and can be determined by the time in which they were placed ?

What is cheating exactly ?

Hello.
Either i don't understand the problem or something is missing.

  • If there's no plan at all => deadlock.
  • If we establish any plan or strategy => they can cheat.

What is the point of establishing any strategy if they can behave literally in any way ?

Clarification request : Managing the row of cups

1-how can we manage the putting of cups in a row (is there any contest like Flip a Coin or Rock Paper Scissors game where the winner will not put his cup first)

2-Must all the guests drink water or not? if not so at least we know that only two guests will drink the water.

3 - for this "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)." that means the host can choose who can drink and who can't

4 - "A guest can drink only from his cup, but he can give his cup to another player"
-Does that mean there are not enough cups? or
-He can sip(taking small mouthfuls) and he can pass the cup to another guest to sip as well or he should pass the cup vacant?
5 - can the winner share the water in his cup with others
6 - what is the relationship between the guests (for example if there is family the father will try to let his opportunity of getting water to his wife or his children )

7-can two guests or more nominate one of them to take their place and share with them water if he/she wins?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.