# Are there eighteen or twenty bars in my castle?

Two friends, Mark and Rose, are very famous logicians; they are so clever that they can deduce any logic connection possible in a matter of minutes even from the most vague situation.

Unfortunately, one day, the two friends are abducted by the Evil Logician, who is envious of their fame, and believes they don't deserve it. He imprisons them in his castle and decides to test their cleverness. They are kept in two different cells, which are located on opposite sides of the castle, so that they cannot communicate in any way. Mark's cell's window has twelve steel bars, while Rose's cell's window has eight.

The first day of their imprisonment, the Evil Logician tells first Mark and then Rose that he has decided to give them a riddle to solve. The rules are simple, and solving the riddle is the only hope the two friends have for their salvation:

• In the castle there are no bars on any window, door or passage, except for the windows in the two logicians' cells, which are the only barred ones (this implies that each cell has at least one bar on its window).
• The Evil Logician will ask the same question to Mark every morning: "are there eighteen or twenty bars in my castle?"
• If Mark doesn't answer, the same question will then be asked to Rose the night of the same day.
• If either of them answers correctly, and is able to explain the logical reasoning behind their answer, the Evil Logician will immediately free both of them and never bother them again.
• If either of them answers wrong, the Evil Logician will throw away the keys of the cells and hold Mark and Rose prisoners for the rest of their lives.
• Both Mark and Rose know these rules.

Can the two logicians redeem themselves? If so, what will the reasoning behind the correct answer be, and what's the minimum number of days it will take either of them to answer correctly?

• Is the question "are there (18 bars in the castle) or (20 bars in the castle)", or "are there (18 or 20 bars in the castle) or (some other number of bars in the castle"? If the former, is it guaranteed that one of the options is correct (i.e. is it a rule that there are either 18 bars in the castle or 20 bars in the castle)? Nov 15, 2016 at 5:27
• Hello Marco, very nice puzzle. Did you come up with it or it is a famous one? Nov 15, 2016 at 7:09
• I'm sorry but, are you copying your puzzles from a youtube channel ? The second time I see one of your puzzle it's coincidently also one that has been talked about by the same youtube channel. Nov 15, 2016 at 16:17
• Ok, I challenge everyone who thinks that he understood the solution to try it out in chat or at home. Two players, one arbiter (Evil Logician). Each player tells only the arbiter how many bars are on the window and the arbiter tells both players only the right sum and a wrong one. We go now step for step through the puzzle and if this really works, it could be demonstrated, right ? Nov 15, 2016 at 20:32
• @FlorianF well, for starters, maybe they would like to think about those together. Mar 12, 2020 at 12:33

## 21 Answers

I think I have a faster solution than Rubio. (Or I did, when Rubio's solution took one day longer than mine; he's since incorporated my solution into his answer).

The answer:

They can escape, and will do so in four days.

The explanation:

Let's start on the time of release and follow the thought process.

Mark learns that Rose has 8 bars on the morning of the 4th day. To avoid long lists of "he knows she knows" let's use some shorthand. "M12: R=6,8" means "In the case that Mark has 12 bars, Mark knows that Rose has 6 or 8 bars". On the next indent level, "R6" and "R8" describes both possible cases. Here's the thought process of Mark on the morning of the 4th day, just before he announces that there are 20 bars in total. The logic starts like this: Mark knows Rose has 6 or 8 bars. If Rose had 6 bars, she would think Mark had 12 or 14 bars. If Rose had 6 bars and assumed Mark had 12, Mark would think... etc.
M12: R=6,8
- R6: M=12,14
- - M14: R=4,6
- - - R4: M=14,16
- - - - M16: R=2,4
- - - - - R2: M=16,18
- - - - - - M18: If M had 18 bars, he would have answered "20" on the first morning
- - - - - - M16: Since M didn't answer day 1, R would answer "18" on the first evening.
- - - - - R4: That didn't happen, so M would answer "20" on second morning
- - - - M14: That didn't happen, so R would answer "18" on second evening
- - - R6: That didn't happen, so M would answer "20" on the third morning
- - M12: That didn't happen, so R would answer "18" on the third evening
- R8: None of the above happened, so this is the only remaining choice
Mark announces that 20 is the answer on the fourth morning.

• Wrong. You cannot draw any conclusions from "if Mark had 18 bars..." since it was impossible for him to have 18 bars and Rose knew it. Nov 15, 2016 at 18:44
• @Sejanus Sure you can. In the hypothetical situation that Rose had 2 bars, Mark having 18 would be perfectly possible.
– Joe
Nov 15, 2016 at 18:59
• @Sejanus this kind of "perfect logician" problem has been discussed to death online, so I don't want to reiterate all of the arguments for why this type of reasoning is valid. It may help to think about the simpler cases: what if Mark had 2 bars, Rose had 1, and the question was 3 or 4 total? What about M=3 R=2 and question is 4/5? If you look up the "forehead spot puzzle" or the "blue eyes" puzzle they follow a similar chain of reasoning and may be helpful.
– Joe
Nov 15, 2016 at 19:12
• This type of reasoning may be valid in a sense that it works if both persons agreed to use this type of reasoning beforehand. But it is not logical. There's nothing logical in making conclusions that do not follow from premises. It's like saying the sky is clear today therefore 20 bars. This may be valid in a context of some secret code agreed upon beforehand, but it has nothing to do with logic. Nov 15, 2016 at 19:29
• Mark couldnt have 18. Theres no way he could have 18. Rose knows it. Since Mark didnt answer Rose knows Mark had no 18 which she already knew. Rose knows Mark has either 10 or 12 and no other number. She always knew it from the beginning. Marks silence didnt tell her anything new. She cant draw any conclusions she couldnt before. Rose didnt have 2. Mark knows it. Mark always knew it. Rose can have only 8 or 6 from Marks perspecrive. It seems to me you are trying to apply the solution that probably worked in a superficially similar but ultimatelly different puzzle before. It does not work here. Nov 15, 2016 at 21:10

### The answer

They can escape, and will do so in FOUR days.
Joe's answer shows that Mark will answer "20" on the morning of the fourth day.
All credit to Joe for finding the shortcut; go upvote him, please!

I'm updating here to flesh out the logic in the vein of my original answer.

### Assumptions

We assume both have at least one bar on their window (or the window couldn't be said to be barred, and they're told their windows are the only barred ones).

We further assume that they must determine which total, 18 or 20, is correct.
If they are being asked to determine if it is either (18 or 20) or (not(18 or 20)), that's a whole different puzzle, but the plain meaning of the riddle suggests the first interpretation is the correct one (OP confirms this in comments).

### Explanation

With those assumptions:

Mark knows he has 12 bars. So Rose must have 6 or 8. If 6, he knows Rose knows he has 12 or 14; if 8, he knows Rose knows he has 10 or 12. For each of those possibilities, he knows Rose knows he knows Rose knows blah blah blah; shortcutting all the explanations, it is easy to see that regardless, each for SURE knows the other has to have an EVEN number of bars on their window.

We know neither has zero; thus neither can have 20, so each has at least 2 and at most 18.
Borrowing Jonathan Allan's notation, we have —

If (person) has [N] bars they will say "total" and be correct:
Day     Mark knows Rose...      Morning (Mark)  Rose knows Mark...      Evening (Rose)
1       has 2..18               [18]"20"        has 2..16               [2]"18"; [18]"20"
2       has 4..16               [16]"20"        has 4..14               [4]"18"; [16]"20"
3       has 6..14               [14]"20"        has 6..16               [6]"18"; [14]"20"
4       has 8..12.              [12]"20" → which is exactly what happens.

My original answer below - this is no longer optimal

On day one:
Mark would say 20 if he had 18 or 19 bars; Rose has at least one, so 18 could not be the answer; he doesn't answer. Rose gets asked, and knows Mark has 1..17 bars.
Rose would say 20 if she had 18 or 19 bars; she doesn't.
Rose would say 18 if she had 1 bar, as she knows Mark has at most 17; she doesn't.

On day two:
Mark gets asked, so he knows Rose has 2..17 bars.
If he had 1 or 2 bars, he would now say 18 (as (1..2) + (2..17) < 20); he doesn't. If he had 17 bars, he would now say 20 (as 17 + (2..17) > 18); he doesn't.
Rose gets asked, so she knows Mark has 3..16 bars.
Rose would say 18 if she had 2 to 3 bars (as (2..3) + (3..16) < 20); she doesn't.
Rose would say 20 if she had 16 or 17 bars (as (16..17) + (3..16) > 18); she doesn't.

On day three:
Mark gets asked, so he knows Rose has 4..15 bars.
If he had 15 or 16 bars, he would now say 20 (as (15..16) + (4..15) > 18); he doesn't. If he had 3 or 4 bars, he would now say 18 (as (3+4) + (4..15) < 20); he doesn't.
Rose gets asked, so she knows Mark has 5..14 bars.
Rose would say 20 if she had 14 or 15 bars (as (14..15) + (5..14) > 18); she doesn't.
Rose would say 18 if she had 4 or 5 bars (as (4..5) + (5..14) < 20); she doesn't.

On day four:
Mark gets asked, so he knows Rose has 6..13 bars.
If he had 5 or 6 bars, he would now say 18 (as (5..6) + (6..13)<20); he doesn't.
If he had 13 or 14 bars, he would now say 20 (as (13..14) + (6..13) > 18); he doesn't. Rose get asked, so she knows Mark has 7..12 bars.
Rose would say 18 if she had 6 or 7 bars (as (6..7) + (7..12) < 20); she doesn't.
Rose would say 20 if she had 12 or 13 bars (as (12..13) + (7..12) > 18); she doesn't.

On day five:
Mark gets asked, so he knows Rose has 8..11 bars.
He has 12, so knows their total cannot be 18.
He now says 20, and is correct.

• You got it fast, nice job, good explanation for every day and number range, it helps understanding the problem a lot. I would have formatted it a bit better though. Nov 15, 2016 at 8:08
• Nice. Thanks for the downvote, whoever.
– Rubio
Nov 15, 2016 at 8:55
• There are two things limiting how many bars each knows the other can have: one is their knowledge of how many their own window has—which is static—and the other is their knowledge of what the other's (lack of) answers tells them. Rose knows both that Mark has 10 or 12, and also that because Mark didn't give an answer that he cannot have more than 17 or fewer than 2. This second bit of knowledge continues to be refined as time passes with no answer given, until it finally decides between the two possibilities each knows the other can have from the first bit.
– Rubio
Nov 15, 2016 at 9:02
• (It's actually even more complicated than that—Mark has 12 bars so he knows Rose has to have 6 or 8; he also knows if Rose has 6, Rose knows he has 12 or 14, and if Rose has 8, she knows he has 10 or 12. So they each know what they know, and what the other knows, and what the other knows THEY know. But in this case the numbers just happen to be such that this extra knowledge doesn't actually help them at all. So it's not included in my analysis.)
– Rubio
Nov 15, 2016 at 9:06
• I have trouble with these sorts of problems. Here's where I get hung up: Mark not answering on day one tells Rose nothing she doesn't already know: Mark must have either 10, 12 or 14 bars. She can not possibly think that Mark has 1.. 17. Likewise, Rose not answering on day two does not tell Mark anything he doesn't already know. He knows that Rose has either 8 or 6 blocks, and further, knows that Rose obtained no new information by him not answering on day 1. Mark has no new information on day 3. The cycle repeats. I understand this is probably wrong - but what am I missing? Nov 15, 2016 at 17:25

Along the lines of Glen O's answer, this answer attempts to explain the solvability of the problem, rather than provide the answer, which has already been given. Instead of using the meta-knowledge approach, which, as Glen stated, can get hard to follow, I use the range-base approach used in Rubio's answer, and specifically address some of the objections being raised.

The argument has been put forward that when Mark fails to answer on the first morning, he gives Rose no new information. This is actually true (sort of— see the last spoiler section of this answer). Rose could have predicted beforehand with certainty that Mark would fail to answer on the first day, so his failure to answer doesn't tell her anything she didn't know. However, that doesn't make the problem unsolvable. To see why, you must understand the following logical axiom: Additional information never invalidates a valid deduction. In other words, if I know that all of the statements $P_1,\dots P_n$ and $Q$ are true, and that $R$ is definitely true if $P_1, \dots P_n$ are true, I can conclude that $R$ is true. My additional knowledge that $Q$ is true, though unnecessary to deduce $R$, doesn't hamper my ability to deduce $R$ from $P_1,\dots P_n$. I will call this rule LUI for "Law of Unnecessary Information." (It may have some other name, but I don't know it, so I'm giving it a new one.)

The line of reasoning goes as follows:

Let $R,\;M$ be the number of bars on Rose's and Mark's windows, respectively. Before the first question is asked, both Mark and Rose know the following:

$P_1$: Mark knows the value of $M$

$P_2$: Rose knows the value of $R$

$P_3$: $M+R=20 \;\vee \;M+R=18\;$ ($\vee$ means "or", in case you're unfamiliar with the notation)

$P_4$: $M\ge 2\;\wedge\;R \ge2\;$ ($\wedge$ means "and")

$P_5$: Both of them know every statement on this list, and every statement that can be deduced from statements they both know.

To help keep track of $P_5$ I will say that I will call a statement $P$ (with some subscript) only if it is known to both prisoners (or neither); thus, $P_5$ becomes "the other prisoner knows every $P$ that I know."

Additionally, Mark knows that $M=12$ and Rose knows that $R=8$. Call this knowledge $Q_M$ and $Q_R$, respectively. Finally, as soon as one of them is asked the question for $k^\text{th}$ time, they both know (and know that one another know, etc.) $P_{\leftarrow k}$:

$P_{\leftarrow k}$: The other prisoner could not deduce the value of $M+R$ given the information they already had.

After Mark doesn't answer on the morning of day one, both prisoners can deduce from $P_1, P_3, P_4, P_5,$ and $P_{\leftarrow 2}$ that $M\le 16$ (call this $P_6$). It is true that both prisoners have more information than this about the value of $M$, but LUI tells us that that doesn't invalidate the deduction. It basically just means that Rose won't be surprised when she gets asked the question. She already knows she will be.

By the following morning, both prisoners can deduce from $P_1\dots P_6$ and $P_{\leftarrow 3}$ that $4\le R \le 16$ ($P_7$), and that evening, they can deduce from $P1,\dots P_7$ and $P_{\leftarrow 4}$ that $4 \le M \le 14$ ($P_8$). Again, both prisoners know all of this already. (But the conclusions are still valid by LUI.)

On the next day, in a similar manner, they can deduce in the morning that $6 \le R \le 14$ ($P_9$), and in the evening that $6 \le M \le 12$ ($P_{10}$). Here's where things get interesting. Mark can deduce from $P_3$ and $Q_M$ that $R$ is either $6$ or $8$, but $R=6\wedge P_{10} \wedge P_3\implies M+R=18$ and $R=6\wedge P_{10} \wedge P_3\wedge\left[R=6\wedge P_{10} \wedge P_3\implies M+R=18\right]\implies \neg P_{\leftarrow 7}$. When he gets asked the question again on the following morning, he learns that $P_{\leftarrow 7}$ is true, and can thus deduce that $R \neq 6$ and therefore $R=8$ and $M+R=20$. This is actually the first time in the sequence that a $P_{\leftarrow k}$ provides any more information about the value of $M+R$ than the prisoner already has, but the sequence of irrelevant questions is necessary to establish the deep metaknowledge Glen talks about. In this formulation, all this metaknowledge is encapsulated in $P_5$. When a prisoner is asked a question, $P_5$ says that they can deduce not only $P_{\leftarrow k}$ but also that both of them know $P_{\leftarrow k}$ and, by repeatedly applying $P_5$, that both of them know that both of them know $P_{\leftarrow k}$ and so on. For any $P_{\leftarrow k}$, there is some level of "we both know that we both know" that can't be deduced from $P_1\dots P_5$ and $Q_M$ or $Q_R$ alone. This is the "new information" being "learned" at each stage. Really nothing new is learned until Rose fails to answer on the $3^\text{rd}$ evening, but the sequence of non-answers $P_{\leftarrow k}$ is necessary to provide the deductive path to $P_{\leftarrow 7}$.

In fact, viewing it another way, the fact that not answering provides "no new information" (and in fact doesn't provide any new direct information about the number of bars) is exactly why the puzzle is solvable, because

It says that the previous answer provided no new information. Because they both know that the number of bars is either $18$ or $20$ (only two possibilities), any new information about the number of bars (eliminating a possibility) will allow them to give the answer; thus, not answering sends the message "I have not yet received any new information," which, eventually, is new information for the other prisoner.

The "conversation" the prisoners have amounts to this:

Mark: I don't know how many bars there are.

Rose: I already knew that (that you wouldn't know).

Mark: I already knew that (that you'd know I wouldn't know).

Rose: I already knew THAT (etc.)

Mark: I already knew THAT.

Rose: I already knew $\mathbf {THAT}$.

Mark (To the Evil Logician): There are $20$ bars.

But how, you may ask, can a series of messages that provide their recipient with no new information lead to one that does? Simple!

The non-answers provide no new information to the recipient, but they do provide information to the sender. If I tell you that I'm secretly a ninja, you might already know that, but even if you do, knowledge is gained, because by telling you, I give myself the knowledge that you know I'm a ninja, and that you know I know you know I'm a ninja, etc. Thus, each message sent, even if the recipient already knows it, provides the sender with information. After several such questions, this is enough information that a message recipient can draw conclusions based on the sender's inability to draw any conclusions from the information they know the sender has.

Ok, fine, you might say, but what, exactly, is learned when Mark fails to answer on the first morning, and how can you prove this was not already known? Great question, thanks for asking. You see...

At this point, we have to resort to metaknowledge (I know she knows I know...) even though it can get confusing, However, I'll break it down in such a way as to hopefully satisfy anyone who still objects that there is (meta)knowledge available after Mark fails to answer the first question was not available before he did so. Specifically, After failing to answer the first question, Mark gains the information that Rose knows that Mark knows that Rose knows that Mark knows that Rose knows that Mark's window has less than $18$ bars. Now, that's a mouthful, so let's break it down into parts:

$R_0$:Mark's window doesn't have $18$ bars

$M_1$:Rose knows $R_0$

$R_2$:Mark knows $M_1$

$M_3$:Rose knows $R_2$

$R_4$:Mark knows $M_3$

$M_5$:Rose knows $R_4$

My claim is that A) Before he fails to answer on the first morning, Mark does not know $M_5$, and B) Afterwards, he does. Let's examine A) first:

To show that Mark doesn't know $M_5$ beforehand, we work backwards from $R_0$. In order for Rose to know that Mark's window doesn't have $18$ bars, her window would have to have more than $2$ bars. Since the rules (and numbers of bars) imply that they both have an even number of bars, in order for Mark to know $M_1$, he would have to know that Rose's window has at least $4$ bars. The only way for him to know that is if his window has less than $16$ bars. Thus, for rose to know $R_2$, she must know that Mark has no more than $14$ bars, which requires that she have at least $6$ bars. For Mark to know $M_3$, then, he must have no more than $12$ bars, so for Rose to know $R_4$ she must have at least $8$ bars, and for Mark to know $M_5$ he must have no more than $10$ bars. But he does have more than $10$ bars, so he doesn't know $M_5$ beforehand.

To see why Mark must know $M_5$ after he fails to answer the question, we must realize that they both know the rules of the game and one of the rules of the game is that they both know the rules of the game. This creates an infinite loop of meta-knowledge, meaning that they both know that they both know that they both know... the rules, no matter how many times you repeat "they both know". This infinite-depth meta-knowledge extends to anything that can be deduced from the rules. If Mark's window had $18$ bars, he could deduce from the rules that Rose must have $2$, and the tower must have $20$ in total. Because he doesn't answer, rose will be asked, and when she is, she will know that he couldn't deduce the answer, and therefore has less than $18$ bars. Because this is all deduced directly from the rules, rather than the private knowledge that either prisoner has, it inherits the infinite meta-knowledge of the rules, and Mark knows $M_5$.

So, Mark learns $M_5$. Does Rose learn anything? It's tempting to think that she doesn't, because she can predict in advance that Mark won't answer and therefore, one might think, she can draw in advance any conclusions that could be drawn from his not answering. However, as was shown above, by not answering, Mark learns $M_5$. Not answering changes the state of Mark's knowledge. This means that Rose's ability to predict Mark's behavior doesn't prevent her from gaining new information. She can predict in advance both what he will do (not answer) and what he will learn when he does it ($M_5$), but since he doesn't learn $M_5$ until he actually declines to answer, his failure to answer provides her with the information that he now knows $M_5$. Since he didn't know $M_5$ beforehand, the knowledge that he does is by definition new information for Rose. Rose already knew that she would know this, but until Mark doesn't answer, she doesn't actually know it (because it isn't true). By following this prediction logic out, it's possible to show that Rose knows (at the start) that Mark will be unable to answer until the $4^\text{th}$ morning, but not whether or not he'll be able to answer then. Mark, meanwhile, knows that Rose will be unable to answer until the $3^\text{rd}$ evening, but not whether or not she'll be able to answer then. As soon as one of the prisoners observes an event that they were unable to predict at the beginning, they can deduce from it something they didn't know about the state of the other's knowledge. Since the only hidden information is how many bars are in the other prisoners window, and they know that it must be one of two values, learning new information about that allows them to eliminate one of the values and find the correct result.

• THIS. times a million. If anyone can't understand how the non-answers provide information to limit how many bars each knows the other might have, this explanation should explain it entirely. At this point, anyone continuing to argue for unsolvability falls under the umbrella of "There is none so blind as he who will not see."
– Rubio
Nov 17, 2016 at 19:42
• Thanks, skimming the last part of your answer gave me the intuition I needed. I imagined a simpler problem: Mark has 1 bar; Rose has 1 bar. The evil logician asks: 2 or 3? The evil logician first visits Mark: Mark knows that he has 1 bar, and that the total number of bars is 2 or 3. So he knows that Rose has 1 or 2 bars. Mark says nothing. The evil logician then visits Rose: Rose knows Mark would have said 3 if he had 2 bars. As Rose has 1, and the total is 2 or 3, Rose now knows that Mark has 1 bar; and that total number of bars is 2. She says "2". Nov 18, 2016 at 10:30

Here is another mathematical / graphical solution :

Rose can answer after 4 days. Let's enumerate all the possible pairs of number of bars : left is Mark and right is Rose.
There are 2 ways to create this list :
- by recursively thinking "If Rose has 6 bars she can think that Mark has 12 or 14 bars, so she thinks that mark thinks that she has 8,6 or 4 bars...".
- By listing all the pairs and remove all the odd numbers (they both know they have an even number of bars, and they know that this is shared knowledge).

I have graphically rearranged it so on a line we can see the different possibilities given Mark number of bars and in a column the different possibilities given Rose Number of bar :

DAY 1 morning, before Mark talks
(2,18) (2,16)
(4,16) (4,14)
(6,14) (6,12)
(8,12) (8,10)
(10,10) (10,8)
(12,8) (12,6)
(14,6) (14,4)
(16,4) (16,2)
(18,2)

If the true number of someone only appears one time then he can safely talk. If not, he remains silent and then we can rule out this answer. For example at first step if Mark had 18 bars : he could have talked but he didn't so we remove the (18,2) possibility.
 DAY 1 evening, before Rose talks
(2,18) (2,16)
(4,16) (4,14)
(6,14) (6,12)
(8,12) (8,10)
(10,10) (10,8)
(12,8) (12,6)
(14,6) (14,4)
(16,4) (16,2)

Then Rose can safely speak if she has 18 or 2 bars, but she didn't so we remove it.
 DAY 2 morning, before Mark talks
(2,16)
(4,16) (4,14)
(6,14) (6,12)
(8,12) (8,10)
(10,10) (10,8)
(12,8) (12,6)
(14,6) (14,4)
(16,4)


Then Mark can safely speak if he has 2 or 16 bars, but he didn't so we remove it :
 DAY 2 evening, before Rose talks
(4,16) (4,14)
(6,14) (6,12)
(8,12) (8,10)
(10,10) (10,8)
(12,8) (12,6)
(14,6) (14,4)

Then Rose can safely speak if she has 4 or 14 bars, but she didn't so we remove it.
 DAY 3 morning, before Mark talks
(4,14)
(6,14) (6,12)
(8,12) (8,10)
(10,10) (10,8)
(12,8) (12,6)
(14,6)

Then Mark can safely speak if he has 4 or 14 bars, but he didn't so we remove it.
 DAY 3 evening, before Rose talks
(6,14) (6,12)
(8,12) (8,10)
(10,10) (10,8)
(12,8) (12,6)

Then Rose can safely speak if she has 14 or 6 bars, but she didn't so we remove it.
 DAY 4 morning, before Mark talks
(6,12)
(8,12) (8,10)
(10,10) (10,8)
(12,8)

Mark has 12 bars and sees there is only one possibility so he can safely say that there is 20 bars.

• I've made a mistake thinking there could be 0 bars, I hope it's correct now Nov 16, 2016 at 1:13
• Thanks for all the effort put into this and the well formatted explanation! Very good answer. Nov 16, 2016 at 3:14

## This answer does not attempt to directly answer the question, but to help understand why it's solvable.

There is some confusion occurring due to the language used in some other answers – they imply that the logicians are able to directly deduce things like "Rose doesn't have 2" from failure to respond. This isn't quite right.

Instead, it's about depth of knowledge – think of the initial knowledge like this:

Depth 0: Mark has 12 (and he knows it); Rose has 8 (and she knows it).  They both know that the total is either 18 or 20.

Depth 1: Mark knows that Rose has either 6 or 8, and Rose knows that Mark has either 10 or 12.

Depth 2: Mark knows that Rose knows that Mark has either (10 or 12) or (12 or 14), and Rose knows that Mark knows that Rose has either (6 or 8) or (8 or 10).

And so on down.

When Mark initially is asked on Day 1, it's his Depth 1 knowledge being tested – he has 12, so he can't know whether Rose has 6 or 8, and thus cannot answer.

When Rose is asked on Night 1, it's her Depth 2 knowledge being tested. Why? Because if she could rule out which pair Mark considers possibilities because he couldn't answer, then that tells her which ones are possible.

To see this, let's consider a different case: Mark has 16, Rose has 2.

In this case, Rose knows that Mark knows that Rose has either (0 or 2) or (2 or 4).

But if he knew the options for Rose were 0 or 2, he'd know the answer was 2. Therefore, she can rule out the idea that Mark thinks that Rose has either 0 or 2. Thus Rose knows that Mark knows that Rose has "either 2 or 4". The only way he'd see that is if Mark had 16. Therefore, Rose knows Mark has 16, and she answers 18.

On Day 2, Mark is now being tested on his Depth 3 knowledge.

Again, let's see it in action with an example: Mark has 16, Rose has 4. Now Mark knows that Rose knows that Mark knows that Rose has either [(0 or 2) or (2 or 4)] or [(2 or 4) or (4 or 6)]. If Rose knew that Mark knew that Rose had either (0 or 2) or (2 or 4), as discussed earlier, she would have answered. But she didn't answer, so Mark now knows that Rose knows that Mark knows that Rose has "either (2 or 4) or (4 or 6)".

Yes, I know it's getting hard to follow.

This allows Mark to determine the answer in this example. Mark knows Rose's Depth 2 knowledge, now. For Rose to know that Mark knows that Rose has either (2 or 4) or (4 or 6), it is necessary for Rose to think that Mark has either 14 or 16. And for that to be true, Rose must have 4. Thus, Mark can answer 20.

To get to the final answer, Mark is going to have to determine the truth from Depth 7.

In other words...

Mark knows that Rose knows that Mark knows that Rose knows that Mark knows that Rose knows that Mark has either [([([(0 or 2) or (2 or 4)] or [(2 or 4) or (4 or 6)]) or ([(2 or 4) or (4 or 6)] or [(4 or 6) or (6 or 8)])] or [([(2 or 4) or (4 or 6)] or...

... and it keeps on going like that. The "0 or 2" at the start is what allows Mark to get the answer.

• 16 and 2 isn't a very good example, because it just so happens that Rose having 2 means that Mark, if he did have 18, knows that the answer is 20 - So this is a boundary case leading to the possibility that Mark can answer correctly immediately, otherwise he doesn't answer, indicating to Rose that he has 16. If you drop to 15 - 3 you are then away from the boundary condition, and you don't get the solution - unless both participants follow an inductive process that doesn't logically follow in reality.
– Cato
Sep 11, 2017 at 13:09
• @Cato - I don't think you've actually understood the logic as described, because what you just said about the 16+2 case is exactly the point of the example - Rose can work out that the answer is 18 because if it were 20, Mark would have figured it out. Now in the 16+4 case, Rose isn't able to figure it out - which tells Mark that the answer is 20, because if it were 18, Rose would have been able to figure it out. And so it propagates. The case of 15+3 works similarly, but the expressed numbers at each depth change - if Mark had 17, he would've answered 20, but he didn't, so Rose answers 18 Sep 11, 2017 at 17:31
• my point is that 15 and 3 does not then work without the artificial construct of the 'countdown' sequence, that they would have to agree on before hand. You realise the person with 3 bars knows the other has 15 or 17 bars, there is then no longer any concept of 18,19 or 20 bars being 'excluded' by a non answer, unless a completely notional concept of them doing this is artificially introduced.
– Cato
Sep 12, 2017 at 9:58
• @Cato - they know that there is either 18 or 20 bars - it's established in the question. And the exclusion process still works - it's just that, rather than being caught when "0" is a possibility at that level, it's caught when "-1" is a possibility. Think about it - if it were 17 and 1, then Mark wouldn't be able to answer, and then Rose would (because Rose knows Mark would answer if he had 19). With 15 and 3, it takes a little longer - Mark doesn't answer, then Rose doesn't answer, then Mark doesn't answer, then Rose answers 18. Sep 20, 2017 at 17:20
• Think it through - Mark can't answer because Rose could have 3 or 5. Rose can't answer because she doesn't know whether Mark thinks she has [1 or 3] or [3 or 5]. Mark then can't answer because he doesn't know if Rose thinks he thinks she has ([1 or 3] or [3 or 5]) or ([3 or 5] or [5 or 7]). But then Rose can answer because if Mark had 17, he'd have been able to answer (because if he had 17, then ([3 or 5] or [5 or 7]) would mean the total was at least 20). Sep 20, 2017 at 17:26

Nice problem! This is an attempt to illustrate the solution graphically. This is also how I found it, I then could confirm with the previous answers it was the correct one :)

Let's start by a simpler problem. Mark has 12 bars, Rose 4, and Evil Logician is asking : do I have 14 or 16 bars in my castle?

We first note that if, at any point in the reasoning of Rose, Mark is suspected to have 14 bars, he would be a jerk not telling immediately having a total count of 14 is impossible (Rose cannot have 0 bars), and correct answer is 16. If Rose is still living at that point, she would know Mark cannot have 14 bars and have only 12, and should tell at that moment the correct answer.

This reasoning is illustrated below, the black numbers being the order of the days/nights, and the count in parenthesis being respectively the number of bars of Mark and Rose. An arrow between two nodes M=12 and R=2 means "if I am Mark and I have 12 bars, I think Rose could have 2".

Now the real problem. Mark has 12 bars, Rose 8, and Evil Logician is asking : do I have 18 or 20 bars in my castle? Here is the illustrated graph:

We can note that the values of the nodes in the tree can be computed from the previous values, and Mark and Rose have fixed answers (Mark is always telling about 20 for instance). The depth of the tree indicates the number of half days to wait until they are made free (here, a depth of 7 corresponds to 7 half days, thus the freedom is for the morning of the 4th day). The depth also equals the length of the alternative path between Mark and Rose, which can be computed from the two possible answers of the Evil Logician (18 and 20): starting with M=12, and given 18-12=6, we jump to R=6, given 20-6=14, we have M=14, given 18-14=4, we have R=4, given 20-4=16, we have M=16, given 18-16=2, we have R=2, and given 20-2=18, we have M=18, which is 7 nodes. This could be used to compute the number of days in the general case :-)

Here is my solution

Here is the info they can gather after each day
day 1 both <= 18(If anyone had over 18, they would know it's 20)
day 2 neither have 0(If anyone had 0, they would know the answer)
day 3 neither have 1(If anyone had 1, they would know the answer)
day 4 neither have 2(If anyone had 2, they would know the answer)
day 5 neither have 3 or 18
day 6 neither have 4 or 17
day 7 neither have 5 or 16
day 8 neither have 6 or 15
day 9 neither have 7 or 14
day 10 Mark knows she have a 8 and the total is 20

EDIT(new answer)

- The first day, when Rose gets the question, she knows that Mark didn't know. Which could only mean that he doesn't have 19 or 20
- The morning of the second day, when Mark gets the question, he knows Rose didn't know. Which means she didn't have 19-20 but also didn't have 0 or 1(or else she would have known it was 18)
- The night of the second day, Rose will now know that Mark doesn't have 0-1 but also doesn't have 17-18.(or else he would have known it was 20)
- The morning of the third day, he will know she doesn't have 17-18 and 2-3
- The night of the third day, she will know he doesn't have 2-3 and 15-16
- The morning of the fourth day, he will know she doesn't have 15-16 and 4-5
- The night of the fourth day, she will know he doesn't have 4-5 and 13-14
- The morning of the fifth day, he will know that she doesn't have 6 and since he knows she must have 6 or 8, he will know the result is 20.

• @Marco Bonelli How about my new answer? Nov 15, 2016 at 7:41
• Your limits are off by one, I believe. You get to the right day but by slightly incorrect limiting.
– Rubio
Nov 15, 2016 at 7:54
• @Rubio it all depends on if you accept 0 or not. Since the result is the same, I went ahead and included it so that my solution is good for any cases. Nov 15, 2016 at 8:03
• I was just reading the old one when I saw the edit: the first one looks good, a bit slow because it requires ten days, maybe the kind of answer a computer running a procedural algorithm would give I think. The second one is indeed better, it involves more thinking, and also the Evil Logician says that "the windows in the two logicians' cells are the only barred ones": a barred window must have at least one bar to be considered such, so yeah, the solution is more general than the actual solution to this problem. Nov 15, 2016 at 8:05

My answer was originally wrong as I had switched who was who half way though by mistake.
I believe:
Rubio had the correct answer given zero bars on the other cell window is a theoretical possibility (although it turns out that there was a mistake going with the not possible case); and that
Joe has the correct answer given zero bars on the other cell window is not a theoretical possibility.

So, instead, here are tables of who would say what and when - up to the point at which they free themselves in the current scenario given those two situations:

Zero bars is a possible situation:
If (person) has [a, or b] bars they will say "total" and be correct

Day   Morning (Mark)            Evening (Rose)
1     [19,20]"20"               [0,1]"18"; [19,20]"20"

2     [17,18]"20"; [0,1]"18"    [2,3]"18"; [17,18]"20"

3     [15,16]"20"; [2,3]"18"    [4,5]"18"; [15,16]"20"

4     [13,14]"20"; [4,5]"18"    [6,7]"18"; [13,14]"20"

5     [11,12]"20" ...
Zero bars is not a possible situation:
If (person) has [a, or b] bars they will say "total" and be correct

Day   Morning (Mark)            Evening (Rose)
1     [18,19]"20"               [1,2]"18"; [18,19]"20"

2     [16,17]"20"; [1,2]"18"    [3,4]"18"; [16,17]"20"

3     [14,15]"20"; [3,4]"18"    [5,6]"18"; [14,15]"20"

4     [12,13]"20" ...

Note that

For the "zero is possible" case:
On the first evening if Rose has 0 bars and is not free, she knows that Mark does not have 20 bars and hence may deduce there are 18 in total. Similarly if she has 1 bar and is not free she knows that Mark does not have 19 and again may deduce there are 18 in total. If she has 19 or 20 she can say 20, just as Mark could in the morning.

On the second morning if Mark has 18 bars and is not free, he knows that Rose does not have 0 bars and hence may deduce there are 20 in total. (Similarly if he has 17...) If he has 0 bars and is not free he knows Rose does not have 20 and hence may deduce there are 18 in total. (Similarly if he has 1).

and so on...

For the "zero is not possible" case, the sets of values get shifted away from 20 and 0 by one, because they have the knowledge that the other window does not have zero bars.

• I'm not sure I understand your logic... could you elaborate a bit more explaining each day morning/night (specially the third and fourth one)? Nov 15, 2016 at 8:14
• I switched the "he knows she knows" with the "she knows he knows" at some point. So this answer is wrong actually. Nov 15, 2016 at 8:31
• Oh snap, I thought you came up with the most clever answer for a minute... Nov 15, 2016 at 8:32
• You can confine this a little more. You know (and OP confirmed in a comment) that "a barred window must have at least one bar to be considered such", so on the first evening Rose knows Mark does not have 18 bars either, as his 18 + her minimum 1 would preclude 18 as an total and he would say 20. That makes things more narrowly confined throughout. In this specific case it ends up not mattering, but for different numbers it would have been the difference of a day.
– Rubio
Nov 15, 2016 at 9:47
• I added the 1 bar implication in the question as well since that it didn't look so obvious. Nice well organized table by the way, +1. Nov 15, 2016 at 10:06

I have an alternative answer which, if correct, would allow Mark to give an answer on the morning of the second day.

Breakdown of knowledge prior to any exchange of information:

Mark’s knowledge, prior to any exchange of information

• There are either 18 or 20 bars in total.
• I will be asked for an answer every morning, Rose will be asked every evening.
• I can see 12 bars.
• R must have 6 / 8 bars.
• If R had 6 bars, she’d think I had 12 / 14. If she had 8, she’d think I had 10 / 12. She can therefore ascertain that I have 10 / 12 / 14 bars. She can narrow it down to two numbers but I don’t know which two.
• I have more bars than Rose.
• R has at least 6 bars.
• If R had 6 bars and therefore thought that I had 12 / 14, she would reason that I would think she had 6 / 8 or 4 / 6. If she had 8 and therefore thought that I had 10 / 12, she would reason that I would think she had 8 / 10 or 6 / 8.
• She is therefore aware that I know she has at least 4.
• I must give an answer first.

• Rose’s knowledge, prior to any exchange of information

• There are either 18 or 20 bars in total.
• Mark will be asked for an answer every morning, I will be asked every evening.
• I can see 8 bars.
• M must have 10 / 12 bars.
• If M had 10 bars, he’d think I had 8 / 10. If M had 12, he’d think I had 6 / 8. He can therefore ascertain that I have 6 / 8 / 10 bars. He can narrow it down to two numbers but I don’t know which two.
• If M had 10 bars and therefore thought that I had 8 / 10, he would reason that I would think he had 10 / 12 or 8 /10. If he had 12 and therefore thought that I had 6 / 8, he would reason that I would think he had 12 / 14 or 10 / 12.
• Mark has more bars than me.
• M has at most 12 bars.
• He is aware that I know he has at most 14.
• Mark must give an answer first.
• Breakdown of Events:

Morning of Day 1: Mark is asked whether there are 18 or 20 bars?

• The common knowledge is that Mark sees at most 14 bars. Mark needs to tell Rose that he doesn’t see 14 bars so he passes.
• Rose already knows this but also knows that Mark needed to tell her. Now they both know she knows this.
• The common knowledge is now that Mark has at most 12 bars.

• Evening of Day 1: Rose is asked.
• As Mark can have at most 12 bars, the lowest number of bars that Rose can have is now 6. She needs to tell Mark that she doesn’t see 6 bars so she passes.
• Mark did not know this. Had Rose seen 6, she would have known there were 18 bars and given the answer. Mark now knows that Rose has 8 bars and has the answer.

• Morning of Day 2: Mark is asked.
• Mark gives the answer 20 and both are freed.
• This is what I found as well, and it should be the accepted answer. @marco-bonelli May 5, 2021 at 4:17
• This answer is not correct. If you apply this logic to the scenario where Rose instead has 6 bars, you'll find that she does not give an answer on the first evening in that case either. So Mark cannot tell on day 2 whether she has 6 or 8 bars in her window. The problem is that it is not common knowledge that Mark sees at most 14 bars - they both know it, they both know the other knows it, but they don't know if the other knows the other knows it. May 12, 2021 at 8:44

Without 0 bars excluded:

Mark will answer 20 on the fifourth day

Here's why, working from the known to the unknown:

If Mark had 20: M=20 (M would say 20 the first time asked)
If Mark had 18: M=20 (Rose has 2)
If Rose had 0: M=?,R=18 (Rose knows Mark has 18 because he didn't answer)
If Rose had 2: M=?,R=?,M=20 (Mark knows Rose has 2 because she didn't answer)

If Mark had 16:
If Rose had 2: M,R,M,R=18 (R knows M has 16)
If Rose had 4: M,R,M,R,M=20 (M knows R has 4)
If M had 14:
If R had 4: M,R,M,R,M,R=18 (R knows M has 14)
If R had 6: M,R,M,R,M,R,M=20 (M knows R has 6)
If M had 12:
If R had 6: M,R,M,R,M,R,M,R=18 (R knows M has 12)
If R had 8: M,R,M,R,M,R,M,R,M=20 (M knows R has 8)

• They both have more than 0 (given in the problem). So actually the answer comes sooner than you said. Nov 16, 2016 at 19:49

# Another way of looking at it...

As some people still have trouble understanding how they can logically figure it out by induction, I'm going to introduce two more people, so that Mark and Rose don't actually know how many bars are on the windows. Mark will be asking Mary a question, while Rose will be asking Rove. Each one can only ask a single yes-or-no question, and it has to be answerable by Mary/Rove with only the information visible to them.

### Day 1

Mark is asked whether there are 18 or 20 bars in total, and he turns to Mary. "Do we have 18 bars on our window?" Mary says no, and Mark cannot answer the question, as the only way he could be confident of the number of bars on the windows in total is if there were 18 on his.

Rose is now asked, and, knowing that Mark could have answered if there were 18 bars on his window, concludes that there can't be 18 on his window. Therefore, there's one way she could be confident of the total - "Are there 2 bars on our window?" she asks Rove. He says no, and Mary cannot answer the question.

### Day 2

Mark knows that Mary will have asked if there are two bars on her window, and as she couldn't answer, he also knows she doesn't have 2 bars. This means there's just one way he could know the answer, and he asks if there are 16 bars on his window. Mary says no, and Mark cannot answer.

Now Rose knows there aren't 16 bars on Mark's window, asks if there are four on hers, Rove says no, and Rose can't answer.

### Day 3

This continues - Mark knows Rose doesn't have four, asks Mary if their window has 14, she says no, and he cannot answer.

Rose knows Mark doesn't have 14, asks Rove if their window has 6, he says no, and she cannot answer.

### Day 4

Mark now knows that Rose doesn't have six, and asks Mary "Do we have 12 bars on our window?" - Mary smiles and says yes. Mark now knows the answer: there must be 20 bars between the two cells, as Rose has at least 8 and Mark has 12.

But here's the thing - even if Mark and Rose know the real numbers, rather than needing Mary and Rove to check for them, the logic is still the same. Having the information about the number of bars on their own window doesn't restrict their ability to draw the same conclusions.

At each step, there's only one relevant piece of information outside of the known restrictions (at least two bars on each, total is either 18 or 20, etc): "is the number of bars on my window the number necessary for me to be able to determine the answer right now?" All further information is extraneous.

The introduction of Mary and Rove allows us to see this in action more easily, but is unnecessary for the logic itself.

# Answer:

Yes they can and be free in 2 days.

There are 3 phases of logical reasoning involved in the Main Line of Logic, each building upon the previous: An 8 Day Method which leads to a 5 Day Method which finally leads to the 2 Day Solution.

You can not prove the logical steps involved in the 2 Day Solution without working out the other 2 methods first, and then using logic to eliminate them. They are both part of this 2 Day Solution.

[Note: I suspect the original logic problem included a caveat of there being no food and water in the cells and a reminder that people die in 3 days without water.]

# Main Line of Logical Reasoning:

[This all occurs before any passing or answer.]

1) Both want to be free as quick as possible without taking chances & both will work out the fastest way to be free (reason: survival instinct).

2) Each knows the other can only see a certain number of bars and what those numbers must be and that the other knows this: Rose sees 6 or 8 bars & Mark see 10 or 12 bars (this is common knowledge between them).

* Mark Knows Conclusively:
> I see 12 bars.
> That Rose can only see either 6 or 8 bars because I see 12, and the only correct answers are 18 or 20.
> That Rose can come to a similar conclusion from her point of view.
> That Rose knows I can only see 10 or 12 bars because Rose can only see 6 or 8 bars.

* Rose Knows Conclusively:
> I see 8 bars.
> That Mark can only see either 10 or 12 bars because I see 8, and the only correct answers are 18 or 20.
> That Mark can come to a similar conclusion from his point of view.
> That Mark knows I can only see 6 or 8 bars because Mark can only see 10 or 12 bars.

3) 'Passing' is the only way to communicate, and can only be used to count. Count what? Bars.
> Reason: The only thing that needs to be communicated to solve the problems is the answer to this question: How many bars do you see?

4) Both know that Rose has the least number of bars required to be counted -- 6 or 8 -- thus, they are going to be counting Roses' bars to escape the quickest.

5) There are only 2 ways to communicate an increase in the 'Count' with 'passing': a) Counting each day both of them passes, or; b) counting each pass. Can both methods lead to success?

* If counting by the day, they CAN be free in 7 to 8 days. (See 8 Day Method Below.)

* If counting by the pass, they CAN be free in 4 to 5 days. (See 5 Day Method Below.)

6) Since both can work out they can safely be free in 4-5 days, they will eliminate the 8 Day Method, conclusively establishing that 'passing' is going to mean the Count will increase by 1 with each pass.

7) Next, both will examine if it can be done even quicker than 4-5 days.

8) Having worked out the 5 Day Method, both can now see the Count on Day 4 is the key Day/Count to determine if the answer is 18 or 20. They couldn't come to this conclusion before working out the 5 Day Method.

9) Now they can both come to the logical conclusion that they can use the Count for Day 4 on Day 1 -- which is 6 -- and be free in 2 days. So the 2 Day Solution will be the ultimate logical conclusion of how they will escape. (See 2 Day Solution Below)

### 8 Day Method

[Note: We're keeping track of the Count by the Day due to both passing.]

Day 1) pass | pass - Both know the Count is 1

Day 2) pass | pass - Both know the Count is 2

Day 3) pass | pass - Both know the Count is 3

Day 4) pass | pass - Both know the Count is 4

Day 5) pass | pass - Both know the Count is 5

Day 6) pass | pass - Both know the Count is 6

Mark can now reason:

> I see 12 bars, and if Rose sees 6 then the Total is 18 and we now have the right answer, but I can't tell if Rose has 6 or 8 bars conclusively at this point.

> I know Rose will know I can't come to a conclusion about if she sees 6 or 8 bars today, and so I can't answer.

> But, I must say 20 when the Total reaches 20, which will happen on Day 8 if Rose sees 8 bars.

> Rose can come to the conclusion I will say 20 on Day 8 because:

> If Rose sees 8 bars Rose will pass to allow the Count to increase, else Rose will answer 18 to prevent the count from increasing to 8.

Day 7) pass | pass - Before passing, Rose can come to a similar line of reasoning that Mark did:

> I know that Mark sees 10 or 12 bars but Mark couldn't tell if I have 6 or 8 conclusively yesterday, and had to pass.

> The Total will be 20 tomorrow if Mark sees 12 bars.

> Mark will say 20 tomorrow if I pass because the Total will be 20 & because I can confirm that I only see 6 bars today by saying 18 to prevent the Count from increasing to 8.

> Mark expects me to answer 18 today if I only see 6 bars to prevent the Count from increasing to 8.

Day 8) Mark Answers 20 - Freedom.

Mark knows conclusively the Count + the 12 bars he sees = 20

## 5 Day Method

[NOTE: We're keeping track of the Count by each pass.]

Day 1)

Mark pass (Count is 1)
Rose pass (Count is 2)

Day 2) Both know the Count is 2

Mark pass (Count is 3)
Rose pass (Count is 4)

Day 3) Both Know the Count is 4

Mark pass (Count is 5)
Rose pass (Count is 6)

Day 4) Both know the Count is 6

Mark can now reason:

> I see 12 bars, and if Rose sees 6 then the Total is 18 and we now have the right answer, but I can't tell if Rose has 6 or 8 bars conclusively at this point.

> I know Rose will know I can't come to a conclusion about if she sees 6 or 8 bars at this point and so I can't answer.

> But, I must say 20 when the Total reaches 20, which will happen if Rose passes because she sees 8 bars.

> Rose can come to the conclusion I will say 20 if she passes because:

> If Rose sees 8 bars Rose will pass to allow the Count to increase to 8, else Rose will answer 18 to prevent the Count from increasing to 8.

Mark pass (Count is 7)

Rose can come to a similar line of reasoning that Mark just did:

> I know that Mark sees 10 or 12 bars but Mark couldn't tell if I have 6 or 8 conclusively and had to pass.

> The Total will be 20 tomorrow if Mark sees 12 bars.

> Mark will say 20 tomorrow if I pass because the Total will be 20 & because I can confirm that I see 6 bars today by saying 18 to prevent the count from increasing to 8.

> Mark expects me to answer 18 today if I only see 6 bars to prevent the Count from increasing to 8.

Rose pass (count is 8)

Day 5)

Mark answers 20 - Freedom.

Mark knows conclusively the Count + the 12 bars he sees = 20

### 2 Day Solution

[Note: We arrived at this by examining the the 5 Day Method and using the Day 4 Count from it on Day 1. We can not jump to this step in logic without first proving the 5 Day Method.]

Day 1) Both know the Count is 6

Mark can now reason:

> I see 12 bars, and if Rose sees 6 then the Total is 18 and we now have the right answer, but I can't tell if Rose has 6 or 8 bars conclusively at this point.

> I know Rose will know I can't come to a conclusion about if she sees 6 or 8 bars at this point and so I can't answer.

> But, I must say 20 when the Total reaches 20, which will happen if Rose passes because she sees 8 bars.

> Rose can come to the conclusion I will say 20 if she passes because:
> If Rose sees 8 bars Rose will pass to allow the Count to increase, else Rose will answer 18.

Mark pass (count is 7)

Rose can come to a similar line of reasoning that Mark just did:

> I know that Mark sees 10 or 12 bars but Mark couldn't tell if I have 6 or 8 conclusively and had to pass.

> The Total will be 20 tomorrow if Mark has 12 bars.

> Mark will say 20 tomorrow if I pass because the Total will be 20 & because I can confirm that I have 6 today by saying 18 to prevent the Count from increasing to 8.

> Mark expects me to answer 18 today if I only see 6 bars to prevent the Count from increasing to 8.

Rose pass (count is 8)

Day 2)

Mark answers 20 - Freedom.

Mark knows conclusively the Count + the 12 bars he sees = 20

• In short, you are applying external knowledge to the problem - that is, when you decide what Mark thinks Rose is thinking, you are applying the knowledge that Rose sees 8. But Mark doesn't know that. Mar 13, 2020 at 2:31
• I have to agree with @GlenO here, "That Rose knows I can only see 10 or 12 bars because Rose can only see 6 or 8 bars.". By saying this you are giving Mark the knowledge that Rose has 8 bars. If Mark doesn't know how many bars Rose has, then he can only come to the conclusion that Rose either knows (a) Mark has 10 or 12 (if she has 8) or (b) Mark has 12 or 14 (if she has 6). Therefore, in Mark's mind, Rose could think either 10, 12 or 14. If you exclude the 14, you are implicitly giving Mark the knowledge about Rose's number of bars. Mar 13, 2020 at 2:52
• @ChristopherTheodore let me ask you this: we are in the same situation, you can see 10 bars in your cell. The Evil Logician asks you if there are a total of 30 or 35 bars. Now tell me how many bars you think that I think you are seeing. Mar 13, 2020 at 11:44
• @ChristopherTheodore well answer my last comment then. Mar 13, 2020 at 12:27
• @MarcoBonelli Crystal clear. Thanks for suffering my obtuseness.. apologies to all. :-D Mar 13, 2020 at 14:15

There seems to be a way that Mark and Rose can solve this problem in just 2 days. Please replace trees with bars. I originally saw this problem where trees were used, instead.

Rose knows that Mark knows she has at least 6 trees. She knows he has 10 or 12 so she knows that he knows she has either 8 or 10 if he has 10 -- and 6 or 8 if he has 12. Regardless, it's at least 6.

Mark knows that Rose knows he has at most 14 trees. He knows she has 6 or 8 so he knows that she knows he either has 12 or 14 if she has 6 -- and 10 or 12 if she has 8. Regardless, it's at most 14.

Thus, we begin communication between the two of them on the same idea that Mark has at most 14 and Rose has at least 6.

### Day One

Mark knows Rose has at least 6 and she knows he has at most 14. If he has 13 or 14 trees he can conclude they add past 18 and there must be 20. Since he has 12, he passes.

Rose knows Mark knows she has at least 6, so Mark passing meant that he had at most 12. If she had 6 or 7 trees then she can conclude they can't add to 20 and there must be 18. Since she has 8, she passes.

### Day Two

At this point, Mark knows he conveyed to Rose he had at most 12 since they eliminated 13 or 14 since the beginning. So Rose passing meant that she could not have had 6 or 7 trees. Since Mark, to start with, knew Rose actually had either 6 or 8, 6 is eliminated and she has 8 trees. Adding, Mark can conclude that there are 20 trees.

Just a thought I had; please correct me if I'm wrong.

• I checked and rechecked and believe it is correct. Why did you post it as a "comment" and not as "solution"? The words "please correct me if I'm wrong" seem to be very unfortunate. Someone else considers this solution correct? Dec 16, 2020 at 23:50
• @kaksi, as Rob mentioned on another similar answer, this is not correct. Because if Rose had 6 bars, she would also not answer on the evening of day one. Therefore Mark won't know whether Rose not answering means she had 6 or 8 bars (since in both cases Rose wouldn't answer on the evening of day one). Jun 22, 2021 at 18:49

The "I know you know that I know..." solution does not need to be very long, depending how much detail is requested.

1. Solving for A=18, B=2 Day 1 A: knows the solution, (18+2)=20

2. Solving for A=16, B=2 Day 1 A: cannot decide between (16+2) and (16+4) Day 1 B: a) (18+2) - Ann would know b) (16+2) - solution

3. Solving for A=16, B=4 Day 1 A: cannot decide between (16+2) and (16+4) Day 1 B: cannot decide between (14+4) and (16+4) Day 2 A: a) B has 2 aa) (18+2) B dismissed, knows I would know (case 1) ab) (16+2) B does not cry victory -> B does not have 2 b) B has 4 -> solution (16+4)

4. Solving for A=14, B=4 Day 2 B: a) (14+4): solution (the other case will be excluded) b) (16+4): Ann would know this morning (case 3)

It can be shortened (at least) to:

A=18, B=2: A on 1st day (immediate solution)

A=16, B=2: B on 1st day (because of the previous case)

A=16, B=4: A on 2nd day (because of the previous case)

A=14, B=4: B on 2nd day (because of the previous case)

A=14, B=6: A on 3rd day (because of the previous case)

A=12, B=6: B on 3rd day (because of the previous case)

A=12, B=8: A on 4th day (because of the previous case)

# The answer

They escape in 4 days

# The explanation

On day one
Mark (M) does not speak. M knows nothing.

Since M did not speak, Rose (R) deduces that he neither have 19 or 18 bars. R does not speak but knows that M $$\in$$ [1;17].

On day 2
Since R did not speak, M knows that she neither have 19 or 18 bars. Also, since he knows she knew he has at most 17 bars, he deduces that she neither have 1 or 2 bars (since 17 + 2 < 20). He does not speak but he knows that R $$\in$$ [3;17].

Since M did not speak and R knows that M knows that R $$\in$$ [3;17] then R deduces that M has at least 3 bars and less than 16 (because 16 + 3 > 18). She does not speak but she knows M $$\in$$ [3;15].

On day 3
The logic is the same. M knows R $$\in$$ [3;17] and he knows that R knows M $$\in$$ [3;15]. She did not speak so M deduces that R neither have 3 or 4 bars (since 15 + 4 < 20) nor 16 or 17 (since 16+3 > 18). He does not speak but he knows that R $$\in$$ [5;15].

Since M did not speak and R knows that M knows that R $$\in$$ [5;15] then she does not speak but deduces that M $$\in$$ [5;13].

On day 4
From a simillar deduction (R cannot have 5 or 6 or she would have said 18. She cannot have 14 or 15 or she would have said 20) M knows that R $$\in$$ [7;13]. Since he has 12 bars he deduces that R has 8 and answer 20 to the evil logician.

## No, they cannot escape.

Mark sees his window with the 12 bars. He can deduce Rose has either 6 or 8 bars in her window. He does not know which. However, he can deduce that Rose will have deduced he has either 10, 12, or 14 bars.

Rose sees her window with the 8 bars. She can deduce Mark has either 10 or 12 bars in his window. She does not know which. However, she can deduce that Mark will have deduced she must have 6, 8, or 10 bars.

The chain of reasoning never starts at the "if the other had only 1 bar / if the other had 19 bars" stage because they both know that to be untrue.

Most importantly, the knowledge that the other has not answered yields no new information, since they already knew the other wouldn't be able to answer.

## Or can they?

However, they both know of the strategy which has been laid out by other answerers. They also realise that if they were to follow that strategy, they would get out, so they do.

• @Sejanus the truth cannot be repeated often enough. :)
– SQB
Nov 15, 2016 at 21:34
• The crux of all of the solutions above is the idea of "common knowledge", which can be somewhat counter-intuitive. Just because both Rose and Mark know a certain fact "X" does not imply that Rose knows that Mark knows that Rose knows "X". This is why hypotheticals that we as the readers can obviously see are false still hold value in solving the problem. en.wikipedia.org/wiki/Common_knowledge_(logic)
– Joe
Nov 15, 2016 at 21:47
• Rules state they are perfect logicians capable of deducing logical conclusions within minutes. Also that they both know the rules. Rose sees her 8, she knows Mark has 12 or 10, she knows Mark thinks she has 6, 8 or 10. She knows Mark cannot know how many exactly so he's gonna stay silent. Mark stays silent as she knew he would. She learns nothing from it. Its not the blue eyes. Nov 15, 2016 at 23:14
• @Sejanus - Continuing your logic Rose sees her 8, she knows Mark has 12 or 10, she knows Mark knows she has 6,8 or 10, she knows Mark knows she knows he has 14,12,10 or 8, she knows Mark knows she knows he knows she has 4,6,8,10 or 12, she knows Mark knows she knows he knows she knows he has 16,14,12,10,8 or 6, she knows Mark knows she knows he knows she knows he knows she knows he has 2,4,6,8,10,12 or 14, she knows Mark knows she knows he knows she knows he knows she knows he has 18,16,14,12,10,8,6 or 4. After each "silence" some of the ends start getting knocked off of those "knows". Nov 16, 2016 at 2:42
• Rose knows that Mark knows she knows he knows she knows he knows she knows he knows she has 18,16,14,12,10,8,6,4, or 2 bars. On day 2 she also knows that Mark knows she knows he knows she knows he knows she knows he knows she does not have 18 or 2 bars. Hence on day 2 Rose knows that Mark knows she knows he knows she knows he knows she knows he knows she has 16,14,12,10,8,6, or 4 bars. Nov 16, 2016 at 14:11

## Release on the second day

I came across this puzzle on MindYourDecisions' Youtube video and am surprised that no one has come up with my solution. Or rather people have thought of the same idea with their two day ideas but I didn't see anyone fixing the problem with those. Originally I proposed a three day solution but I noticed that there is no reason why A's second pass wouldn't hold the exact information as that of B's and therefore the solution was squeezed into two. The solution is the same but A simply doesn't pass for nothing on the second morning, so the comments are still relevant.

I also added a flowchart of the general case at the end.

Here's how it goes:

I'm going to use A for Mark and B for Rose to make me not mix up my original comment and because I find them more clear to work with to begin with.

Since there are either 18 or 20 bars in total:
- A knows that B must have 6 or 8.
- B knows that A must have 10 or 12.
- A also knows that in case B has 6, they must be wondering between 12 and 14, and if 8, between 10 and 12.
- B likewise knows that in A's mind the options for B's bars are either between 8 and 10 or between 6 and 8.

Here are the days:
1a. By passing on the first day A tells B 'In case you did have 6 bars, you can drop the 14 as an option as otherwise I would already know the answer to be 20 (as 14+8>20).'
1b. By passing B tells A 'With this information, in case I did have 6, I should now know the answer and we would be free.'
2a. A realizes that since they are being questioned, B doesn't know the answer which must mean that B has 8 bars so the total must be 20 bars.

So (at the latest) they get released on the second morning!

### General case

Premises:
1. A has a
2. B has b
3. The total is either a+b or a+b+c
4. A knows B has either b or b+c (P1,P3)
5. B knows A has either a or a+c (P2,P3)
6. A knows that B thinks either between a and a+c, or between a and a-c (P2,P3,P4)
7. B knows that A thinks either between b and b+c, or between b and b-c (P1,P3,P5)

Notes:
1. c is non-zero.
2. Both A and be know their respective number for a fact so whenever it's A's turn, a isn't hidden information and vice versa for B.
2a. This information is only used for deciding the very first branching of each turn however.
3. The puzzle is solved whenever there is only one option that fills P3.
3a. If B were to suddenly have b+c after the initial setup, that would go against P2 and would leave them with only one option given P3 and P5.
3b. Similar logic as in 3a in case A were to suddenly have a+c instead.
4. However! When we do get to day two it doesn't matter whether A at this point had a or a+c.
4a. Had they a+c 3b applies and a+b+c is the only sensible solution.
4b. Had they a (as they should), because B is apparently still unsure after having a turn with either one or two possibilities, B must have the one with two options. Since A knows a for certain, they know the sum to be a+b.

I color coded the days and each turn.

• A is going to pass on day 1 regardless of whether they have 12 or 14 bars A having 14 bars isn't a possible premise though. It could be but it would change the whole problem. That is exactly why A wouldn't pass had they 14 bars given that the other premises stand. They would instantly know that B must have 6 in order to get a total of 18 or 20, as demonstrated in the solution. Jun 24, 2021 at 14:10
• No they could not because the premises are A has 12, B has 8 (both omitted as obvious in the solution), A knows B has 6 or 8 and B knows A has 10 or 12. The scenario where B thinks A could have 14 only exists in A's head because they aren't sure whether B has 6 or 8 bars. My solution is the logic for this specific setting and not for the general puzzle. Jun 24, 2021 at 14:48
• I thought we were discussing the A12, B6 case though, since my entire point is that that case is indistinguishable from A12, B8 over the first two days, meaning that in either case A cannot know the answer on day 3. In the A12, B6 case it's absolutely possible to B that A has 14 bars on their window, which means that B knows that A could think it possible that B has 4 bars, meaning that B cannot rule out A having 14 bars just from A passing on day 1. Jun 24, 2021 at 15:01
• A12, B6 is a whole different puzzle with its own set of premises. It doesn't matter what A thinks B could potentially have and where those options would spiral into because at the end of the day B has a fixed number; A just doesn't know which. Thank you for your comments. I was trying to read so hard into them that I almost lost my original train of thought. That is why I ended up doing the general case after all. Please refer to the flowchart in the edited submission. Jun 24, 2021 at 23:17
• The right side of your flowchart has a contradiction in it. a + b + c = a + b + c so A will pass from B thinking a. But also a - c + b != a + b or a + b + c so A also guesses a - c + b from B thinking a - c. A can't be doing both passing and guessing. Jun 25, 2021 at 5:08

For those confused why the two day solution doesn't work please see the below:
Day 1
Mark's perspective
Mark 12
Rose 6 8
Rose knows Mark has one of 10 12 14
If I had 14 I would say 20. If I had 10 I would say 18. I have 12 so pass

Rose perspective
Mark 10 12
Rose 8
Mark knows Rose has one of 6 8 10
If Mark had 14 he would have said 20 so therefore Mark knows if I had 6 I would say 18. By passing I can eliminate 6 from the options he thinks I have. If I had 10 I would say 20. I have 8 so pass.

Day 2
Mark perspective
Mark 12
Rose 8
As Rose passed Mark can eliminate 6 as a possibility and now knows that Rose has 8 so calls 20

If Rose actually had 6 bars then it plays out slightly differently but you seemingly reach the answer in the same amount of time:

Day 1
Mark's perspective
Mark 12
Rose 6 8
Rose knows Mark has one of 10 12 14
If I had 14 I would say 20. If I had 10 I would say 18. I have 12 so pass

Rose's perspective
Mark 12 14
Rose 6
Mark knows Rose has one of 4 6 8
If Mark had 10 he would have said 18 so therefore if I had 8 I would say 20. By passing I can eliminate 8 from the options he thinks I have. If I had 4 I would say 18. I have 6 so pass

Day 2
Mark's perspective
Mark 12
Rose 6
As Rose passed Mark can eliminate 8 as a possibility and now knows that Rose has 6 so calls 18

However, in both instances the actions taken by both parties are the same yet the conclusions reached are different.

# The riddle is impossible to solve with absolute certainty and I can prove it.

I have been spending quite some time on this problem and I honestly don't think it's solvable. I think that the solutions presented here neglect a lot of information which can be logically inferred by the two prisoners with what they already know following perfect logics. If this additional information is accounted for, I honestly don't understand how the problem is solvable.

Unless I am missing something in my framing of the problem (which I will write hereafter), I think that the only reason why the proposed solutions work is because they implicitly assume that the two prisoners follow the same logic presented in the solution, which coincidentally leads to a unique solution deducible by both prisoners. In other words, the reason why the two prisoners can solve the riddle with absolute certainty is not because of pure logics, but because they are unknowingly following a shared strategy by which they are able to exchange useful information to infer each other's number.

I will propose here a perfectly logical and coherent framework by which no solution is possible. The fact that such a possibility exists means that if the any of the two prisoners doesn't follow a strategy, they might in principle follow the logics proposed here, which would in itself make the riddle impossible to solve with pure logics alone.

Please let me know if I am wrong and why. Also, please excuse in advance any weird formalism or jargon: I am not a mathematician, so I am making up words and symbols as I go. I will make sure to define these things to the best of my possibilities though, so that they should be at least clear.

## Setting and basic notation

Let me first start by doing a small change of names: from now on, Mark will be called Alice and Rose will be called Bob. The reason for this change is that Alice and Bob are way more famous logicians than Mark and Rose, and it's well known that Alice always goes before Bob (using M and R I always kept forgetting who was going first, also I use M for "morning" so the original choice of names was confusing to me). So, Alice is the one that can see 12 bars and starts guessing first, Bob is the one who can see 8 bars and guesses for second.

With that being said, let me define a few things just to be on the same page.

Let me call $$k_0$$ this piece of knowledge: Alice and Bob can see all the bars without overlapping and they both will be freed according to procedure X if at least one of them guesses the total number of bars.

For the moment, I prefer to leave the procedure X with which they are freed still undefined: X can be "they are freed immediately" or "they are freed one at a time when the logician visits them" or some other procedure. The reason for leaving X undefined is because although X has implications on how quick Alice and Bob can infer things from what happens to them (e.g. immediately vs the next day, in the evening, etc), it doesn't really change the types of inference that they can make (I promise this will be clearer in a little bit, please bear with me for now).

The other piece of knowledge I want to define is $$k_1$$: there are either 20 or 18 bars in total.

I prefer not to include $$k_1$$ in $$k_0$$ because depending on how we interpret the setup of the problem, $$k_1$$ and $$k_0$$ may actually be given to Alice and Bob at different times: once again, this will have consequences on how quickly Alice and Bob will be able to infer things, but not the things that they will be able to infer.

Finally, I want to define $$a$$ as number of bars that Alice sees and $$b$$ as the number of bars that Bob sees.

The puzzle is indeed solved if either Alice or Bob correctly guess $$a+b$$.

## Logical framework of inferences

Let me now build the logical framing of the problem. In order to make this process as intuitive as possible, I will start with some simple example and then I will generalize. Also, for now I will explicitly disregard the temporal sequence of events and what happens in which day for which prisoner: these details are bound to be different for different interpretations of the setup, i.e. when do Alice and Bob acquire certain pieces of information and for what reason. Instead, I will for now build the logical framework working with "if -> then" conditionals.

Let's start with Alice.

Alice by definition knows how many bars she sees, i.e. she knows $$a$$, which is equal to 12. If she also knows $$k_0$$ and $$k_1$$, she can immediately infer how many bars Bob can see: she will subtract 12 from either 20 or 18, thus inferring that Bob might see either 8 or 6 bars. Let me represent this with the following diagram:

In the above diagram I called $$b_A$$ the value of $$b$$ guessed by Alice. Notice that there are 2 possible values for $$b_A$$, because Alice doesn't know for sure if $$a+b$$ is 18 or 20. In the above diagram you can track which of these assumptions for $$a+b$$ leads to which value of $$b_A$$. I call the collection of all the knowledge and guesses up to $$b_A$$ inferred by Alice as $$I_{A1}$$: this is the first inference that Alice can make based on the basic knowledge $$\{k_0,k_1,a\}$$. Let me represent this fact with the notation

$$\{k_0,k_1,a\} \rightarrow I_{A1}$$

With the above notation I mean that the set of knowledge $$\{k_0,k_1,a\}$$ is both necessary and sufficient to make the inference $$I_{A1}$$.

Similarly if Bob has the set of knowledge $$\{k_0,k_1,b\}$$, he will be able to make his first inference $$I_{B1}$$, by using his basic knowledge to guess how many bars Alice sees, i.e. $$a_B$$. Bob's diagram for $$I_{B1}$$ looks like this:

and corresponds to the rule

$$\{k_0,k_1,b\} \rightarrow I_{B1}$$

So far so good. Now here's a question: can Alice infer anything else if she only knows $$\{k_0,k_1,a\}$$? for example, another thing Alice could try to guess is what Bob might think that the number $$a$$ is, or in other words she might try to guess what $$a_B$$ is. Let me call this quantity $$a_{BA}$$: reading from right to left, this is what Alice thinks that Bob thinks that $$a$$ is. In order for Alice to guess $$a_{BA}$$, in addition to $$\{k_0,k_1,a\}$$ she must also know that Bob is in the position of being able to make an educated guess about the number $$a$$. In other words, in order to guess $$a_{BA}$$, Alice must have the knowledge that the inference $$I_{B1}$$ was made by Bob. If that's the case, Alice's inference diagram expands to the level $$I_{A2}$$, which comprises all the knowledge that Alice has up to her guess of the quantity $$a_{BA}$$:

The knowledge rule for $$I_{A2}$$ can be expressed as

$$\{k_0,k_1,a,[I_{B1}]\} \rightarrow I_{A2}$$

where the notation $$[Y]$$ means "knowledge that $$Y$$ exists". Notice that knowing that $$Y$$ exists doesn't mean knowing what $$Y$$ is: just that $$Y$$ exists. If Alice knows that $$a_B$$ exists in Bob's mind, even if she doesn't know what its value is, she can still try to guess it. If she doesn't know or can't be sure that $$a_B$$ exists in Bob's mind, computing $$a_{BA}$$ would be either futile or impossible.

Notice that there are four possibilities for $$a_{BA}$$ because there were two possibilities for $$b_A$$. In other words, Alice doesn't know how many bars Bob sees: it can be 8 or it can be 6. Therefore she must account for the possibility that Bob might have subtracted 8 or 6 from either 20 or 18. Of these 4 possible values however, 2 of them are are the same: these are the values coming from using the same value of $$a+b$$ to calculate $$b_A$$ and $$a_{BA}$$, which both return the value $$a$$ by definition. Because of this, there are only 3 different possibilities for $$a_{BA}$$.

Similarly, if Bob knows that Alice was in the position to make the inference $$I_{A1}$$, he can make the inference $$I_{B2}$$ according to

$$\{k_0,k_1,a,[I_{A1}]\} \rightarrow I_{B2}$$

Which produces the tree

Notice also that Bob's inference tree for $$I_{B1}$$ is indeed contained in Alice's inference tree for $$I_{A2}$$: since both prisoners are perfect logicians, Alice is definitely capable of accounting for the real guesses that Bob made starting from the true value of $$b=8$$, together with other possibilities that Bob isn't aware of coming from her other guess of $$b$$ being 6, although of course she doesn't know which subset of her tree is Bob's tree. However we - the external observer - know which side of Alice's inference tree corresponds to Bob's inference tree, so for the sake of convenience we can visualize both trees together in the following diagram

where the dashed line marks our knowledge of the true values of $$a$$ and $$b$$ as external observers: the portion under the dashed line corresponds to Bob's inference tree, while the part above it is the part of Alice's tree that Bob cannot know.

At inference level 2 for both Alice and Bob, the overall tree looks like this:

and at inference level 7 for Alice and 6 for Bob the tree looks like this:

The general rule for any of Alice's inferences can be expressed as:

$$\{k_0,k_1,a,[I_{Bn}]\} \rightarrow I_{A(n+1)}$$

and similarly Bob's inferences follow the rule

$$\{k_0,k_1,a,[I_{An}]\} \rightarrow I_{B(n+1)}$$

where $$[I_{B0}]$$ and $$[I_{A0}]$$ are the trivial knowledges of either prisoners that the other one knows their own number of bars.

The above diagram and rules constitute the basic logical framing of the problem. The next steps are figuring out: 1) at which moment in time Alice and Bob are capable of making any of their inferences and 2) which of these inferences, if any, would give either prisoner absolute certainty on the value $$a+b$$.

## Information received over time

Let me first start with the problem of the timing of the inferences.

As I mentioned earlier, the timing at which Alice and Bob receive the necessary information to make any inference depends on the rules of the riddle, which also include the procedure X by which they are freed.

Imagine for example that the logician communicates the rules on their first visit to either prisoner and that the prisoners are freed only when the logician visits them (and not immediately), so that for example Bob needs to wait for the night visit even if Alice guessed correctly during the morning. In addition to that, let's also assume that Alice and Bob don't know in advance when and if the logician will visit each of them again: the logician tells either prisoner that he visited the other prisoner only after the visit has taken place.

In this case it's simple to track what Alice and Bob can infer at each moment in time. Let me call Mj and Nj the morning and night of day j.

According to these rules, at M1 Alice knows $$k_0$$, $$k_1$$ and of course $$a$$, so she can immediately make the inference $$I_{An}$$. Bob However only knows $$b$$ at this point, because the Logician hasn't visited him yet, so he can't make any inference. we can represent this situation in the following table

Time Alice's knowledge Bob's knowledge
M1 $$\{k_0,k_1,a\} \rightarrow I_{A1}$$ $$\{b\} \rightarrow 0$$

At N1, Alice's knowledge doesn't change because she doesn't know whether the the logician is visiting Bob and even if that would be the case, she would not know if Bob had guessed correctly until the next morning (because in this variation of the riddle the logician doesn't free the prisoners immediately but on his next visit). As for Bob, the logician communicates the pieces of knowledge $$k_0$$, $$k_1$$ and the fact that he visited Alice in the morning asking the same question to her. From this last bit of information, now Bob can safely infer that Alice - being a perfect logician - must have made the inference $$I_{A1}$$. He also can be sure that Alice could have not made any further inference, because he knows that Alice cannot possibly know for sure that the logician is visiting him now. Therefore at N1, Bob is capable of directly making the inference $$I_{B2}$$. This adds a new line in our table

Time Alice's knowledge Bob's knowledge
M1 $$\{k_0,k_1,a\} \rightarrow I_{A1}$$ $$\{b\} \rightarrow 0$$
N1 $$\{k_0,k_1,a\} \rightarrow I_{A1}$$ $$\{k_0,k_1,b,[I_{A1}]\} \rightarrow I_{B2}$$

On M2 the logician visits Alice again and tells her he visited Bob the night before. Given that the logician is not freeing Alice, she knows for sure that Bob didn't solve the riddle, however this is a trivial piece of information because she already knows by the nature of the logician's riddle that Bob's guess of $$a$$ must have two choices. She of course doesn't know which two choices out of the three possible guesses she has for $$a_{BA}$$ are Bob's guesses, but at least she can now make the inference $$I_{A2}$$. In addition to that, she also knows that Bob had enough knowledge to make the inference $$I_{B1}$$, so she can directly make the inference $$I_{A3}$$, which already contains $$I_{A2}$$. On the other hand, Bob is oblivious to all this, so he hasn't gained any new piece of knowledge. The summary table now looks like

Time Alice's knowledge Bob's knowledge
M1 $$\{k_0,k_1,a\} \rightarrow I_{A1}$$ $$\{b\} \rightarrow 0$$
N1 $$\{k_0,k_1,a\} \rightarrow I_{A1}$$ $$\{k_0,k_1,b,[I_{A1}]\} \rightarrow I_{B2}$$
M2 $$\{k_0,k_1,a,[I_{B2}]\} \rightarrow I_{A3}$$ $$\{k_0,k_1,b,[I_{A1}]\} \rightarrow I_{B2}$$

On N2 a similar reasoning applies for Bob, which is now aware that Alice made the inference $$I_{A3}$$, so he can make the inference $$I_{B4}$$

Time Alice's knowledge Bob's knowledge
M1 $$\{k_0,k_1,a\} \rightarrow I_{A1}$$ $$\{b\} \rightarrow 0$$
N1 $$\{k_0,k_1,a\} \rightarrow I_{A1}$$ $$\{k_0,k_1,b,[I_{A1}]\} \rightarrow I_{B2}$$
M2 $$\{k_0,k_1,a,[I_{B2}]\} \rightarrow I_{A3}$$ $$\{k_0,k_1,b,[I_{A1}]\} \rightarrow I_{B2}$$
N2 $$\{k_0,k_1,a,[I_{B2}]\} \rightarrow I_{A3}$$ $$\{k_0,k_1,b,[I_{A3}]\} \rightarrow I_{B4}$$

As the logician keeps visiting Alice and Bob, the inference table keeps expanding with the same pattern

Time Alice's knowledge Bob's knowledge
M1 $$\{k_0,k_1,a\} \rightarrow I_{A1}$$ $$\{b\} \rightarrow 0$$
N1 $$\{k_0,k_1,a\} \rightarrow I_{A1}$$ $$\{k_0,k_1,b,[I_{A1}]\} \rightarrow I_{B2}$$
M2 $$\{k_0,k_1,a,[I_{B2}]\} \rightarrow I_{A3}$$ $$\{k_0,k_1,b,[I_{A1}]\} \rightarrow I_{B2}$$
N2 $$\{k_0,k_1,a,[I_{B2}]\} \rightarrow I_{A3}$$ $$\{k_0,k_1,b,[I_{A3}]\} \rightarrow I_{B4}$$
M3 $$\{k_0,k_1,a,[I_{B4}]\} \rightarrow I_{A5}$$ $$\{k_0,k_1,b,[I_{A3}]\} \rightarrow I_{B4}$$
N3 $$\{k_0,k_1,a,[I_{B4}]\} \rightarrow I_{A5}$$ $$\{k_0,k_1,b,[I_{A5}]\} \rightarrow I_{B6}$$
M4 $$\{k_0,k_1,a,[I_{B6}]\} \rightarrow I_{A7}$$ $$\{k_0,k_1,b,[I_{A5}]\} \rightarrow I_{B6}$$

So finally, on the morning of the 4th day, Alice is capable of making the inference $$I_{A7}$$. This inference (together with inference $$I_{A6}$$) is important because it's the first inference in the sequence which contains an impossible value. I will discuss later the consequences of this. For now it's important to notice that the only reason why each passing of morning or night is capable of conveying information to Alice and Bob is because in this version of the puzzle they did not have this information beforehand: they don't know if and when the logician will visit each of them next, and they would not know right away if the other person gave the right answer. They have to wait for the logician's visit to gather the knowledge that the other prisoner got the necessary knowledge to make a guess, and only at that point they can update their next guess, thus advancing along their inference tree.

Now, what would happen if - as it is stated in the riddle - the logician communicates the all the rules to the prisoners (including when he will visit them) right away on day 1? In this case both Alice and Bob will have on day 1 not only the knowledges $$k_0$$, $$k_1$$ and either $$a$$ or $$b$$, but they would also immediately know that the other prisoner has knowledge of all this. In other words, they will be able to compute their respective inference trees at any level with absolute certainty from the moment they are told the rules. In this case, the passing of time and the visits of the logician would not covey any new piece of information that they don't already have, so they won't gain any new information whatsoever on any future day that they don't already have on day 1.

So in the actual version of the puzzle, Alice and Bob are either capable of solving the riddle on day 1, or they will never be able to solve the riddle on any other day.

with that in mind, let's now see if Alice and Bob can solve the riddle with the information they can access.

## Impossibility of solving the riddle

As I mentioned before, inferences $$I_{A6}$$ and $$I_{A7}$$ mark an important milestone in that they are the first inferences which contain an impossible guess. Inference $$I_{A6}$$ contains the guess 18 for the value of $$a_{BABABA}$$ and 0 for the value of $$b_{ABABABA}$$. So, what does that mean?

Before going deeper into the meaning of this, notice that inferences $$I_{A6}$$ and $$I_{A7}$$ having the guesses 18 and 0, made by Alice in the morning of the 4th day echoes the solution given by Joe in his highlighted post. However one problem is that in order to get M4 as the critical day, I had to change the setup of the problem and having the logician withholding a lot of information from the prisoners, so that every visit of the logician would actually convey useful information that the prisoners didn't have beforehand. The other problem is that Joe's solution only accounts for 1 out of either 7 (for $$I_{A6}$$) or 8 (for $$I_{A7}$$) possibilities. Although Alice can indeed safely discard the illogical guesses of 18 or 0, she can't discard all the other equally possible options.

In other words, even being able to make inference $$I_{A6}$$ or $$I_{A7}$$ and discarding one value out of their pools, won't give Alice any certainty on which other value she should keep or discard. Growing the inference tree further would eventually produce more impossible values, in both Alice and Bob's inference trees; at the same time there will always be multiple good values which could all be equally possible.

Because of this, the riddle is not possible to be solved by Alice and Bob using pure logic alone.

The reason why the previously proposed solutions work is because Alice and Bob are unconsciously following a strategy to communicate useful information to each other with every visit of the logician.

Imagine for example that on day 1, after they are told the rules of the riddle but before they know how many bars they will see in their respective cells, Alice and Bob have the possibility to strategize. They can agree that with each of the logician's visit they will count down from either 20 or 18 until they reach the number of bars that they see. In this scenario, every visit of the logician that doesn't result in being freed communicates to the each prisoner information about the number of bars that the other prisoner sees. But this is true ONLY because Alice and Bob decided to follow a precise strategy which they agreed beforehand: the strategy is what assigns a meaningful information to the logician's visit, not pure logic alone.

If Alice an Bob are not allowed to strategize, relying only on pure logic would not grant them to follow any of the strategies proposed by any of the solutions. This is true as long as a coherent and logical framing of this riddle which does not guarantee any solution exists, like the one I proposed here. Unless I committed some logical fallacy in my framing, one must admit that a perfect logician may actually use the same framing as the one I proposed, given that my framing can be obtained by perfect logics alone. Even if the strategies proposed in any of the solutions are also logical, Alice and Bob would not be guaranteed to automatically follow any of them without strategizing first or somehow choosing to follow the same logics by total serendipity.

If there was only a unique strategy that can guarantee a win, or if all the possible strategies that would guarantee a win would have the same outcome (e.g. Alice finding that Bob has 8 bars on the morning of the 4th day), Alice and Bob being perfect logicians would be able to identify and implement this unique strategy (or decide to implement any of the equivalent strategies) without previously agreeing with each other, as this would be the most logical thing to do to be freed. The fact that multiple successful strategies exists to solve the riddle on different days already implies that Alice and Bob can't know for sure which of these strategies the other will implement. One could argue that the strategy which would guarantee the earliest freeing time would be the best choice and should therefore automatically implemented by Alice and Bob. But given that with any of these strategies Alice and Bob gain information over time and don't know in which day they would gather the necessary information to solve the riddle, I argue that it's not possible for them to identify with absolute certainty a strategy that is a priori superior to the others. In addition to that, given that in theory multiple strategies can be devised to solve the problem and given that perfect logicians are not omniscent beings but mere humans, logics suggests that both Alice and Bob needs to account for the possibility that the other person might devise a better strategy than any of the strategy that they are currently thinking about. In other words, blindly deciding to choose a strategy without aligning with the other prisoner first would be the same as making a random choice. Assessing the probability of success of this random choice is also not possible (because Alice and Bob cannot know for sure how many successful strategies the other is thinking about), which means that choosing to follow a strategy may be just as good or possibly even worse than just randomly pick one of the two numbers proposed by the logician. And in any case, even if deciding to blindly follow a strategy would somehow guarantee a better chance of success than randomly picking one of the two numbers, success would still not be guaranteed with absolute certainty.

Because of this, even if Alice and Bob can in principle solve the riddle by strategizing beforehand and making perfectly logical decisions coherently with their chosen strategy, in the most general case of following only pure logic nothing guarantees that they will have enough information to solve the riddle at any point in time.

Therefore the riddle is unsolvable with absolute certainty.

• The important information that is supposed to be gained by visits of the evil logician is that the other captive did not have enough information deduce the answer. For example: Knowing the premise, but before any visit, you agree $a_{BABAB}$ includes 18 -- there is a hypothetical Bob that believes Alice could have 18 bars. But, after Bob learns Alice has been visited and not guessed the answer, this is no longer consistent because that hypothetical Alice would have known there were 20 bars and guessed as such. I don't see any argument against this besides denial. Jan 13 at 11:18
• Yeah, I read this rationale in other comments and honestly I disagree with it. This hypothetical Bob that believes Alice could have 18 bars is simply not a perfect logician, because by following perfect logic Bob can only believe that Alice has either 10 or 12 bars. Any other deduction is just not supported by logics and it's a mere consequence of Alice and Bob following a strategy to keep count of each other's bars Jan 13 at 14:26
• Also, both Alice and Bob already know that the other doesn't have enough information to solve the riddle from the get go just by pure logics. So the visits of the evil logician would not add any more information that they don't already know. Unless of course they are following a strategy where they pretend not to know what they already know, so that they can create artificial information with each visit of the logician. But given that they didn't have the possibility to strategize beforehand, they cannot know for sure which strategy the other is following, if any. Jan 13 at 16:56
• If you are talking about a hypothetical Bob that believes $a_{BABAB}$ is 18, sure: Alice can rule out the existence of this hypothetical Bob. But there are 5 other hypothetical Bobs each believin in a different realistic value of $a_{BABAB}$ and branching from both $a_B$ being 8 or 6. How can Alice figure out which of these other 5 Bobs is the real one? This is a genuine question, I am not sure what kind of denial would I have... can you explain to me why Alice is capable of ruling out 4 of the 5 remaining Bobs and correctly climb the tree back to the right guess of $a_{B}$? Jan 13 at 18:20
• "Bob can only believe that Alice has 10 or 12 bars", yes but only because Bob has 8 bars; the hypothetical Bob in question has 2 bars, so it logical for him to believe Alice could have 18 (or 16) bars. "[They] know the [...] from the get go" -- this is true. But they don't know from the get go that every hypothetical actor doesn't have enough info. There are hypothetical actors, like Alice with 18 bars, that do have enough info. "[A] hypothetical Bob that believes $a_{BABAB}$ is 18;" this not a belief of a hypothetical Bob, but a belief by the real Bob about a hypothetical Bob. Jan 13 at 20:55

They will never escape. From the info they have and can obtain from each other by knowing that the other hasn't answered, they cannot possibly deduce the number of bars the other one has, hence they cannot possibly deduce the total number either.

Explanation:

Neither Mark nor Rose cannot figure the answer without info from the other one. I hope that much is obvious. Now, the only way for them to send a message to each other is by answering or not answering the question. Mark goes first, he knows Rose has either 8 or 6 bars. He does not know how many, so he does not answer. Rose knows, that Mark didn't answer, and that Mark has either 10 or 12, and that Mark must have guessed Rose has 8||10 or 8||6 and in either case Mark wouldn't have answered. So Rose didn't receive absolutely no new information from Mark non answering, and cannot answer herself. Mark in turn didn't get anything new from Rose not answering. They cannot relay any information to each other than they already had before, hence each of them can only guess with 50 % chance. They cannot escape by using logic, and being genius logicians they do know it. The end.

Now about accepted so called answer. It has nothing to do with logic because Roses conclusions do not logically follow from the info she has. It is a wrong answer. Downvote all you like. That answer would maybe, sort of, make some sense if the two were allowed to agree on some sort of code beforehand, but I still doubt it. Besides the point anyway.

• This puzzle has been solved and the accepted answer proves it is possible Nov 15, 2016 at 17:46
• Accepted answer is wrong and proves only that the author of the question does not know the answer themselves. Nov 15, 2016 at 18:04
• @Sejanus You are right. Nov 15, 2016 at 19:49
• This is incorrect. Have you heard of the Blue Eyes Problem? It may shed some light on the issue for you.
– Deusovi
Nov 15, 2016 at 20:18
• @Deusovi Well, it is not the Blue Eyes Problem. If you are so convinced, lets simulate it in chat. Nov 15, 2016 at 20:23

To solve the problem, I had to make two main assumptions.

1. can only be solved from a single point of view, i.e. from the evil (logician) because he is the common denominator. He gave both Rose and Mark just two numbers to choose (18 or 20) bars.
2. Since he is a logician expecting a logical answer, therefore, his question must be logical. He can not ask if they are seeing less than 12 bars. Although Mark sees 8, Rose is seeing 12, so that would be an illogical question.

Now, between Rose and the evil, they both know that Mark must be seeing 8 or 6 (from 20 or 18 minus 12)

Between Mark and the evil, Rose must be seeing 12 or 10 (from 20 or 18 minus 8). Initially Rose don't realize this.

Now its time for Rose to deduce. She knows that Mark has two options: 8 or 6 bars. If she thinks that Mark has 8 bars, then she must be seeing 12 or 10 bars. If she thinks that Mark has 6 bars, then she must be seeing 12 or 14 bars. So Rose will know that all in all Mark actually have three options 10, 12 or 14 bars for her to see. Both Rose and the evil are fully aware that she is not seeing 14. That makes Mark's option to be limited to 10 and 12 bars for Rose, which is exactly the case.

Now here is the catch: It must be a logical question. If Mark is seeing 6 bars, and both Mark and evil knows that Rose had 10 or 12 bars, the evil's question for Mark must NOT be "are there 18 or 20 bars?" Because the more logical question for 6 bars is "are there 16 or 18 bars?"

Because the evil chose the two numbers (18 and 20), the only option for Mark is to see 8 bars, which is exactly the case.

Rose can safely conclude that Mark sees 8 bars, and the total is 20 bars for both.