Try your hand at the logic puzzle(s) presented in the video Solving one of the logic puzzles of all time! While you don't technically need to watch the video, it probably helps to.
You are at a local beer garden (Boolos' Brewery) with your colleagues Alice, Bob, and Charlie. You're colleagues, but you're not that close. You know that one of them is a mathematician, one is a physicist, and one is an engineer, but you can't remember who is who, and their general demeanours aren't helping you figure it out.
As the night grows late, you notice that all three of your colleagues are quite drunk. Since they won't remember the conversation anyway, now is probably your best chance to figure out who studies in what field. However, since they're so drunk:
This may seem simple enough, but there's a catch.
You see, you yourself are a computer scientist.
During the night, your colleagues decided that it would be "fun and quirky" to only speak to you in foo
s and bar
s.
You don't remember how this decision came about, as you are also pretty drunk.
foo
and bar
to "yes" and "no", but you don't remember what the assignment was.foo
to mean "yes", then the physicist would say bar
to mean "yes".foo
and bar
, though, the engineer is trying to catch up with the trend.
However, since they weren't paying attention, the engineer will randomly choose foo
or bar
as a response to any yes/no question.How many directed yes/no questions do you need to determine everyone's field of expertise?
[!NOTE] This is a classic logic puzzle. You can determine everyone's field of expertise using only three questions.
[!TIP] Find the predicament too easy (or too hard)? Check out the variants!
You could try to gather a few friends and play it the old-fashioned way, but let's be realistic.
Assuming you suivez le rythme du temps, you can get the game going with
cargo run
Once the game is up and running, marvel at the text-based conversation-simulator!
Every question must be directed to someone, and must end with a ?
.
Bob: Charlie studies engineering implies Alice studies mathematics?
# perhaps Bob will say "Foo."
If you're not sure how to formulate your questions, or you're not sure what's possible, consult the grammar.
Unlike the original logic puzzle, I don't need to clarify anything.
Nonetheless, I'll provide some clarifications:
If you would like to play the easier or harder variants, just enable the corresponding feature:
cargo run --features "easy"
cargo run --features "hard"
# the quotation marks are intentional
For any version of the game, you can de-randomise it (for science?) with the derand
feature, e.g.:
cargo run --features "hard derand"
[!WARNING] "Just use
derand
:smirk:." is not a solution to any of the puzzle variants.
If you want more questions than the game allows, add the endless
feature.
cargo run --features "easy endless"
When you think you've figured out everyone's professions, you can just enter done
(don't worry, the UI will remind you of this).
If you think you have worked out a solution to this puzzle or its variants:
.py
file in the submissions/
folder.python3 test_strategy.py
[!TIP] Although submissions are ranked first and foremost by number of questions asked, they are also scored based on "minimal complexity". Even if you can't beat #1, I strongly encourage you to submit your solutions!