
The Logic Puzzle You Can Only Solve with Your Brightest Friend - dnetesn
http://nautil.us/blog/-the-logic-puzzle-you-can-only-solve-with-your-brightest-friend
======
ggambetta
I think the puzzle isn't specified well enough. Critically, it doesn't say
that your friend knows whether you passed or not when you're asked, and this
is a central part of the proposed solution:

> First, you and your friend have to realize that each “pass” counts as a
> signal.

But the spec only says

> The caretaker asks you each one at a time, once a day, and you can choose to
> answer or to pass. Both of you know that you’re always asked first. If you
> both pass on a given day, the question [...] is posed to each of you again
> the next day, and the next, and so on, until you get it right or wrong.

Also, "both of you know that you’re always asked first" could have been
written in a less confusing way, e.g. "both of you know who is asked first".

~~~
skrebbel
Not true. You're always asked first. If you had not passed, then your friend
would be either freed or locked up forever (thus not asked at all).

~~~
ggambetta
This assumes the caretaker uses short-circuit evaluation :) It's a reasonable
assumption to make, but I'd still argue the problem is under-specified.

~~~
neogodless
I thought what you thought at first, but I re-read it, and it's quite clear.
Especially this second sentence.

> The only way for you both to escape is for one of you to give the total
> number of visible statues. Get it wrong, and neither of you ever leave.

------
mhandley
I wonder if there's too much common knowledge here for the proposed solution
to actually work.

We both know there are either 18 or 20 statues. I can see 12, so I know from
the start my friend can see either 6 or 8. My friend can see 8, so she knows
from the start that I can see 10 or 12. Now, when I don't give the answer, she
knows I can't see 19 or 20, but she already knew that. Did she actually learn
anything from the fact I didn't give the answer? She knows I can't answer
already, so what does she learn?

~~~
mhandley
Replying to myself, I think we can take this further.

I know she can see 6 or 8. She knows I can see 10 or 12. She knows that I know
she can see 6, 8 or 10.

Given this information, we both know that the minimum number she can see that
the other knows is 6. This allows us to both shortcut the process. We can both
discard the first rounds that eliminate that she can see 2 or 4. The first
round we need to play is the one where she can see 6.

So, in my first round, I'd give an answer if I could see 14. I don't give an
answer, so she knows I don't see 14. We both already knew that, but it was the
first round we could agree on, so that's where we synchronize.

After that, you just play out the rounds as in the proposed solution.

Edit: doesn't work: if she had actually seen 6 rather than 8, she'd have known
I'd see 12 or 14, so she'd know I knew she would see 4 , 6 or 8. So you can't
synchronize on 6 after all.

~~~
n4r9
I think your idea is pretty much the same as lucraft's below:
[https://news.ycombinator.com/item?id=17548391](https://news.ycombinator.com/item?id=17548391)
and fails for the same reason.

------
benmmurphy
I have a solution to the puzzle in Rust:

[https://play.rust-
lang.org/?gist=c56bd7d745ffcc90d59e4801e41...](https://play.rust-
lang.org/?gist=c56bd7d745ffcc90d59e4801e4126ceb&version=stable&mode=debug&edition=2015)

    
    
        new_common_knowledge of A: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
        new_common_knowledge of B: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
        new_common_knowledge of A: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
        new_common_knowledge of B: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
        new_common_knowledge of A: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
        new_common_knowledge of B: [6, 7, 8, 9, 10, 11, 12, 13, 14]
        new_common_knowledge of A: [6, 7, 8, 9, 10, 11, 12]
        new_common_knowledge of B: [8, 9, 10, 11, 12]
        A announces: 20

------
mimimihaha
This reminds me of one of my favorite puzzles:

"Three wise men are told to stand in a straight line, one in front of the
other. A hat is put on each of their heads. They are told that each of these
hats was selected from a group of five hats: two black hats and three white
hats. The first man, standing at the front of the line, can’t see either of
the men behind him or their hats. The second man, in the middle, can see only
the first man and his hat. The last man, at the rear, can see both other men
and their hats.

None of the men can see the hat on his own head. They are asked to deduce its
color. Some time goes by as the wise men ponder the puzzle in silence. Finally
the first one, at the front of the line, makes an announcement: “My hat is
white.”

He is correct. How did he come to this conclusion?"

~~~
Lewton
Reminds me of the joke

Three logicians walk into a pub, the bartender goes "3 pints?"

First logician goes "Maybe", second goes "Maybe", third goes "Yes!"

~~~
mimimihaha
Haha i love it

------
heptathorp
It'd be funny if the puzzle was to count graves. Then you would answer 20.
Either there are 20 and you're right, or there are only 18 so the caretaker
digs 2 more for you and your friend, so you become right.

------
sweezyjeezy
I'm not sure I get the setup of this puzzle. He tells you at the start that
the total between between you is 18 or 20. So you know from the start that
your friend sees 6 or 8 and she knows that you can see 10 or 12. So neither of
you 'learn' that the other person sees at least 1 / fewer than 19 on the first
round - you both already knew this.

So what knowledge have you actually learned after the first round, that you
can take forward into the second round?

~~~
falsedan
> _So what knowledge have you actually learned after the first round?_

That your friend sees 2 or more, and your friend knows you see 18 or less. By
itself, this is trivially deducable; but each day walks the limits closer to
revela a fact that isn't trivial. You start the puzzle knowning that your
friend can see either 6 or 8 statues, and each day you add a new fact about
how many statues she can't see.

I'm more concerned that the problem as stated can be solved in 2 days: you say
18 on day one, then 20 on day two…

~~~
4ndr3vv
_" Get it wrong, and neither of you ever leave. "_

~~~
AstralStorm
Therefore you say I see more than (y - 2) statues while he says morethan (x +
2) until you both repeat the same value.

You know you cannot lie so a simple iteration on inequalities is enough to
find the right value.

This relies on your friend figuring out the linear addition scheme.

------
pjmorris
What if two of the 12 statues are also part of the 8 statues (or vice-versa?)
There'd be 18 statues, making a guess of 20 statues incorrect. I don't see how
that's ruled out here.

~~~
n4r9
It's not made explicit but I think there is not supposed to be any overlap
between the visible statues. Otherwise I'm pretty sure the problem would
become impossible.

~~~
rimliu

      > Out of your friend’s window, which overlooks
      > the opposite side of the graveyard
    

I'd say it is pretty explicit, unless the same statues happen to be on the
opposite side, which sound funny.

------
n4r9
Very similar to the "Blue-Eyed Islanders" riddle:
[https://www.popularmechanics.com/science/math/a26557/riddle-...](https://www.popularmechanics.com/science/math/a26557/riddle-
of-the-week-27-blue-eyed-islanders/)

They should make it clearer in the introduction that there is no overlap
between the visible statues from each side.

~~~
joshumax
Funny enough, it was the exact puzzle which I read about on XKCD that allowed
me to draw a conclusion for this one so quickly. The trick for these is using
shared knowledge and a shared signaling mechanism to deduce overall state at a
specific time period.

~~~
n4r9
xkcd calls it the "hardest logic puzzle in the world".

I think this one is a lot harder: [http://olivernash.org/2009/10/31/yet-
another-prisoner-puzzle...](http://olivernash.org/2009/10/31/yet-another-
prisoner-puzzle/index.html)

~~~
misterdata
Much better explanation by Nick Berry:
[http://datagenetics.com/blog/december12014/index.html](http://datagenetics.com/blog/december12014/index.html)

------
a008t
For those of you that are interested, there is a formal logic that can be used
to reason about such problems, called Dynamic Epistemic Logic:
[https://eprints.soton.ac.uk/261816/1/EUMAS2.pdf](https://eprints.soton.ac.uk/261816/1/EUMAS2.pdf)
A book chapter on the topic is available here:
[http://www.vub.ac.be/CLWF/SS/DELhandbookarticle.pdf](http://www.vub.ac.be/CLWF/SS/DELhandbookarticle.pdf)

Course slides and other information can be found here:
[https://sites.google.com/site/thealexandrubaltagsite/teachin...](https://sites.google.com/site/thealexandrubaltagsite/teaching/dynamic-
epistemic-logic-2017-2018)

It is a fascinating topic. Equipped with DEL, you can approach similar
problems dealing with knowledge, belief, private and public announcements
systematically.

------
lucraft
It’s strange because at the beginning you know for a fact that your friend
sees either 6 or 8, and your friend knows you see either 10 or 12, but the
given process throws that information away.

I think it’s possible to escape on Day 2 if you keep that knowledge:

A is 12, B is 8

A knows B is either 6 or 8. If 6, B knows A is either 12 or 14. If 8, B knows
A is either 10 or 12.

B knows A is either 10 or 12. If 10, A knows B is either 8 or 10. If 12, A
knows B is either 6 or 8.

So the common knowledge (they both know it and they both know the other knows
it too) at the beginning is: A is between 10 and 14 and B is between 6 and 10.

 _Day one_ : if A saw 13 or 14 they would know it was 20, so when A passes,
that signals to B that A is between 10 and 12.

Now, if B saw 9 or 10, they would know it was 20, so B must be between 6 and 8

 _Day two_ common knowledge: A between 10 and 12. B between 6 and 8.

If A saw 10 or 11 they would know it was 18, so when they pass B knows it must
be 12

B knows it’s 20, and wins.

... Right?

~~~
Zarel
Nice try, but you actually do need to work up from nothing.

> Day one: if A saw 13 or 14 they would know it was 20, so when A passes, that
> signals to B that A is between 10 and 12.

Your problem here is that if A saw 13, they would conclude that B saw 7 or 5.
If A saw 14, they would conclude that B saw 4 or 6. In no case can A guess
immediately.

So B can't conclude anything quite so strong from the fact that A passes on
Day One.

~~~
laszlokorte
But by knowing that the total number is even in either case and by each one
knowing that their own number is even, the odd numbers can be discarded
anyway, right?

~~~
Zarel
Yes, I only brought up the odd-number cases because lucraft did.

------
idrios
I think I solved the problem backwards but I ended up with the same answer.

I made a table of what I know vs what my friend knows. I know they have 6 or
8. If they have 6, then I have 12 or 14. If they have 8, then I have 10 or 12.

    
    
                   |   Me         Them       ||  Them         Me         |  Them         Me         |
        --------------------------------------------------------------------------------------------
        I have     |   12       6  ..  8     ||   6       12  ..  14     |   8       10  ..  12     |
        They have  |  6, 8    12 14..10 12   || 12,14    6  8 .. 4  6    | 10,12    8 10 .. 6  8    |
    

The first column is what I see and what I know about my friend. The 2nd and
3rd columns are what this table looks like to my friend.

\-----------

My friend has 6 or 8.

4 is the first number to appear on the table so start on day 4.

Day 4: If my friend has 6, he thinks I have 12 or 14. If I have 14, then I
would have notified the caretaker today because now 14 + 6 = 20. Now he knows
I don't have 14. As a result, if he has 6 then he knows I have 12 and should
tell the caretaker that the total number is 18.

    
    
                   |   Me         Them       ||  Them         Me         |  Them         Me         |
        --------------------------------------------------------------------------------------------
        I have     |   12       6  ..  8     ||   6       12  ..         |   8       10  ..  12     |
        They have  |  6, 8    12   ..10 12   || 12       6  8 ..         | 10,12    8 10 .. 6  8    |
    

Day 5: I don't have 14, and now my friend knows that. If he has 6, he should
now have alerted the caretaker the number is 18. He did not. This means he
does not 6.

    
    
                   |   Me         Them       ||  Them         Me         |  Them         Me         |
        --------------------------------------------------------------------------------------------
        I have     |   12          ..  8     ||                          |   8       10  ..  12     |
        They have  |     8         ..10 12   ||                          | 10,12    8 10 .. 6  8    |
    

So Day 5 I know I have 12 and he has 8.

------
owenversteeg
Sure, the given solution is nice. But the absolutely critical thing is that
both people would think of it, eventually, which I doubt. The given solution
seems to confuse quite a bit of people.

Are there other solutions?

The first "solution" I thought of was the first friend just using their "pass"
as a simple signal of how many statues they have. This has the benefit of
being very simple and more likely for someone to think of it themselves. Sadly
it does not work because there's no way for them to signal the "end" of when
to stop counting.

~~~
joleal
I thought about that too, if he passes 6 times (and I've passed 6 times) I
know that he has at least 6 (and he knows I have 10 or 12), so I pass a 7th
time, and he passes a 7th time too. So now I know he can't have 6 therefore he
has 8.

This, however isn't the quickest way so it would probably fail if your partner
is optimizing.

~~~
owenversteeg
Hmm. I was pretty convinced that my method would work, then I got convinced it
couldn't work, now I'm confused again.

A few notes: You can see 12, your friend can see 8. So your friend knows you
have either 12 or 10. You know your friend has either 8 or 6.

Step 1: you pass, friend knows you have >=1. Friend passes, you know they have
>=1.

Step 2: you pass, friend knows you have >=2. Friend passes, you know they have
>=2.

[...]

Step 7: you pass, friend knows you have >=7. Friend passes, you know they have
>=7; you have 12, so there must be 20, you win.

I'm actually pretty convinced that it would work now... anyone want to poke a
hole in it?

~~~
nomynous
I thought of something along those lines at first as well. However, the
problem is that the answer is not logically deducible using this method as it
requires both of you to agree on a counting system and an end condition. And
since the puzzle states that the two of you are not able to communicate, this
method would not be viable. The given solution allows you to deduce the result
with only the information and actions you have readily available to you.

------
palotasb
Can it still be solved if I generalize the question like this?

    
    
      * Same setup: two prisoners A and B overlooking two distinct gardens with a constant nonnegative integer number of statues each.
      * The guard asks A and B each day if there are more than N statues total.
      * They can either guess or pass.
      * Wrong guess is a life sentence for both, game over.
      * Good guess and they are both out instantly.
      * N is a nonnegative integer.
      * N is the same each day.
      * N is the same for both A and B.
      * The question is posed each day to A first.
      * They both know all rules of this game.
      * A and B can't exchange information except indirectly by the fact that the other has passed in his turn and they get the question posed to them again.
    

So the same except generalizing [18 or 20?] to [more than N, in this case more
than 18?].

The solution in the article doesn't seem to require the more specific question
and the information derived from it ("the other guy must see either either 20
- X or 18 - X statues"), while this seems to confuse some solutions given
here.

The guard asks whether there are at least N statues total. [For any integer N
which in the linked case would be 19.]

------
yogascribble
I think I have a solution at day 2.

At the start: A sees 12. A knows B can see 6 or 8. If 6, B knows A sees 12 or
14. If 8, B knows A sees 10 or 12. A knows B knows A sees 10 or 12 or 14.

B sees 8. B knows A can see 10 or 12. B knows if A sees 10, A would know B
sees 8 or 10. B knows if A sees 12, A would know B sees 6 or 8. B knows that A
knows B sees 6 or 8 or 10.

Day 1:

A passes.

B thinks, since A sees 10 or 12 he knows I see 6 or 8 or 10. If I saw 6, I
would think he saw 12 or 14. A knows I see 6 or 8 or 10, so if he actually saw
14 he would know I see 6 and the answer is 20. A just passed, which means A
does not see 14. B passes.

Day 2:

A thinks, B sees 6 or 8. If he saw 6 and thought I saw 12 or 14, then when I
passed he would know I did not see 14. That would mean if he saw 6, I would
have had to see 12 and he would have known the answer was 18. B just passed,
which means B does not see 6. That means B sees 8.

The answer is 20.

------
skate22
The answer is: 19 + 5 % -2

If he says you got it wrong, the answer is 18, then you tell him that you
wrote the answer in python

If he says you got it wrong, the answer is 20, then you tell him you wrote it
in javascript

Thanks modulo!

------
duke-from-prima
Please help understanding the puzzle.

Is it possible we see 18 statues together? (e.g. there is 2 common statues, so
I see 10 "own" \+ 2 "common", and friend sees 6 "own" \+ 2 "common"?)

So, would that count as 18 or as 20 anyways?

~~~
EliRivers
No. There are no common statues.

------
jonahrd
How do you know who starts as the "low" counter and who's the "high" counter?

~~~
rhplus
You start with 12: you can infer that the most your friend can see is 8. Your
friend starts with 8: they can infer that the least you can see is 10.

------
laumars
I don't really understand the point of this puzzle because if he asks you 18
or 20 each time then you can escape in fewer days than the "correct" solution
just by brute forcing the correct answer. There's only a maximum of 4
permutations that you and your friend can come up with.

[edit]

ahhh, I missed the "get it wrong and you die" bit. Thanks for the
clarification guys.

~~~
palotasb
Guessing wrong gets you locked up forever.

~~~
rimliu
Buried. The captor says he is preparing graves.

------
mcrowson
Answer: 22. You're wrong so he prepares your graves bringing the count to 22.

