Saturday, November 27, 2021

The Ten Chests

Reasoning about probability can be very difficult. The puzzle herein is a follow-up of the last one I wrote about, which reminded me a bit of the famous Monty Hall problem. I managed to get the right answer to Smullyan's earlier puzzle without any assistance but it could have been because I already knew what to look for. Smullyan himself admitted that the solution is very counterintuitive and offered several separate justifications to combat intuition. Speaking of counterintuitive reasoning and probability, no less a person than the late Paul Erdős was unconvinced of the optimal decision in the Monty Hall problem until he witnessed a numerical simulation! In the same spirit, I will be applying a Monte Carlo simulation to the following more elaborate version of the previous puzzle:
It took Scheherazade quite a bit of time to get the king to accept the correct answer to the last problem, but she finally succeeded.
"I have thought of a related problem," said Scheherazade. "Suppose we have now ten chests instead of three, and each chest has three drawers. Each of the thirty drawers contains either a diamond, an emerald, or a ruby. They are dispersed in the following manner:
  1. D D D
  2. D D E
  3. D D R
  4. D E E
  5. D E R
  6. D R R
  7. E E R
  8. E R R
  9. E E E
  10. R R R
[Of course, D stands for diamond; E for emerald; and R for ruby. So for example, Chest 4 contains one diamond and two emeralds; Chest 7 contains two emeralds and one ruby. There are ten jewels of each of the three types, and they are distributed in all ten possible ways.]
"You open one of the thirty drawers at random and find a diamond. Then you open another drawer of the same chest. What is the probability that it also contains a diamond?"
I will use the power of simulation to attain a nearly perfect answer, like so:

The most recent run outputting 0.5020185586888407 was extremely close to the analytical solution given by the author of ½. Monte Carlo simulations are really something else.

The Three Chests

[Context: the late Raymond Smullyan's The Riddle of Scheherazade: And Other Amazing Puzzles takes place in a setting very like the Thousand and One Nights, except Shahrazad (or whatever Romanization you prefer) has failed to slake the mad king Shahryar's bloodlust and now she has to entertain him with puzzles to save her skin and the kingdom.]
Scheherazade began: "Auspicious King, Abdul the Jeweler has in his home three chests of drawers; each chest contains two drawers. In one of the chests, each drawer contains a ruby. In another of the chests, each drawer contains an emerald, and in the third chest, one drawer contains a ruby and the other drawer contains an emerald. Suppose you pick one of the three chests at random and open one of the drawers and find a ruby. What is the probability that the other drawer in the same chest will also contain a ruby?"
"Let me see now," said the king. "Oh yes, the chances are fifty percent." 
"Why?" asked Scheherazade.
"Because, once you open a drawer and find a ruby, then the chest with both emeralds is ruled out, and so you have either hit the mixed chest, or the chest with the two rubies, and so the chances are even."
Was the king right?

(Source: The Riddle of Scheherazade: And Other Amazing Puzzles by Raymond Smullyan) 

The king was not right but perhaps on the right track. It is true that the chest with two emeralds is ruled out entirely. What he missed is that there are not two but three possible events: one in which the mixed chest has a ruby picked out and two in which one or the other drawer of the chest with only rubies is opened. If that doesn't make immediate sense, consider whether the king's postulated 50% chance would apply if the chest of only rubies had ten drawers instead of only two!

Not A Puzzle for the Health Addict

The answer to this one wasn't quite satisfactory as you'll see below but I felt like solving it anyway because it was pretty funny:
A man buys a carton of 200 cigarettes, and every day he smokes seven cigarettes less than the day before. Eventually the day arrives when his quota is down to one cigarette—which happens to be all that there is left in the original carton. 
How many a day was he smoking he bought the carton?

(Source: Math and Logic Puzzles for the PC Enthusiast by J.J. Clessa)

This puzzle is another one where one has to work backwards. I did it in Python:

Here's the outcome:
Smoked 1 on day 0, with a total of 1
Smoked 8 on day -1, with a total of 9
Smoked 15 on day -2, with a total of 24
Smoked 22 on day -3, with a total of 46
Smoked 29 on day -4, with a total of 75
Smoked 36 on day -5, with a total of 111
Smoked 43 on day -6, with a total of 154
Smoked 50 on day -7, with a total of 204
The last day exceeds 200 a little but the solution towards the end of the book confirms that my figure is correct, stating that "he also had four cigarettes left over from his last packet".

Unrewarded Labor

A man persuaded Weary Willie, with some difficulty, to try to work on a job for thirty dollars at eight dollars a day, on the condition that he would forfeit ten dollars a day for every day that he idled. [1967 US dollars. Ed.] At the end of the month neither owed the other anything, which entirely convinced Willie of the folly of labor. Can you tell just how many days' work he put in and on how many days he idled?
(Source: 536 Curious Problems & Puzzles by Henry Ernest Dudeney, edited by Martin Gardner)

There were two unstated assumptions: it's a 30-day month and fractions of a day's labor or slacking are possible. Anyway this one is pretty easy: solve for $x$ where $x$ is the amount of days he worked during the month:

\begin{align*}8x - 10(30 - x) &= 0 \\
8x - 300 + 10x &= 0 \\
18x &= 300
\end{align*}

Final answer: Willie worked 16⅔ days and idled 13⅓ days during the month.

The Results of Repeated Doubling

A striking example of an exceedingly fast build-up of some small quantity when repeatedly doubled is the famous legend about the award to be given to the discoverer of chess.* Here is [another] example, less famous. [I'm doing the first part only. Ed.]

The infusorian paramecium divides in half on the average every 27 hours. If all newly born infusorians remained alive, how long would it take for the progeny of one paramecium to fill up a volume equal to that of the Sun?

Starting data: the 40th generation of a paramecium, when none perish, occupies one cubic metre; we take the volume of the Sun as equal to 1027 metres.

* See my book Figures for Fun, Mir Publishers, Moscow.

(Source: Algebra Can Be Fun by Yakov Perelman)

The author solved it a bit different but here's what I did. I started with the equation:

\[ 2^x = 10^{27} \]

Where $x$ is the required number of doubling periods, starting from the initial cubic meter volume. I then used logarithms to obtain $x$:

\begin{align*}
\ln(2^x) &= \ln(10^{27}) \\
x \ln(2) &= 27 \ln(10) \\
0.69 x &\approx 62.1 \\
x &\approx 90
\end{align*}
So the required number of doubling periods is almost exactly 90. I added 40 to $x$ to take into consideration the initial growth to cubic meter size then multiplied by $\frac{27}{24}$ to get days and I got a result just a little short of the author's of 146.25 days.

Monday, April 22, 2019

Who Stole What from Whom? (Who Stole What from Whom? Part X)

(N.b. my reasoning differs from that in the solution presented by the author substantially, yet we reach the same conclusion. I am not sure the solution is airtight but it seems pretty solid so I am posting it here anyway.)
“And now, we come to a particularly good puzzle,” I said to the group proudly.
“Three girls—Abigail, Bernice, and Carol—each had a pet; one was a dog, one a cat, and the other a horse, but we are not told which girl owned which pet. One day, our three villains—Mike, Spike, and Slug—each stole a pet from one of the girls, but it was not known who stole what from whom. The case proved extremely baffling, but, fortunately, Inspector Craig of Scotland Yard was visiting the country at the time...”
“Who is Inspector Craig?” asked Barry.
“He is a character from one of my books,” I replied.
“What is the name of this book?” asked Barry.
“You just guessed it!” I said.
“Whatever do you mean?” asked Barry in astonishment.
“I mean just what I said; its name is What Is the Name of This Book?
“Stop kidding us!” said Barry.
“He’s not kidding!” said Alice. “I’ve read the book, and its title really is What Is the Name of This Book?, and it really does contain a whole chapter of cases from the files of Inspector Craig.”
“Anyway,” I intervened, “Inspector Craig was able to find out the following facts, which were enough to solve the case.
  1. The one who stole the horse is a bachelor and is the most dangerous thief of the three.
  2. Abigail is younger than the girl who owns the dog.
  3. Mike’s brother-in-law, Slug, who stole from the eldest of the three girls, is less dangerous than the one who stole the dog.
  4. The man who stole from Abigail is an only child.
  5. Mike did not steal from Bernice.
Who stole what from whom?”
(Source: King Arthur in Search of His Dog and Other Curious Puzzles by Raymond Smullyan)

Slug is revealed to be the brother-in-law of Mike, which means that Mike is married and is therefore not a bachelor and is therefore neither the horse-thief nor the most dangerous of the three. Additionally, Slug has been described as "less dangerous" than one of the other thieves, which leaves only Spike to be the horse-thief.

Since the horse is now (partially) accounted for, it should be pointed out that Slug is compared as "less dangerous" to the one who stole the dog. This leaves only the dog to be stolen by him. And it also means that Mike stole the dog. So far, so good; who stole which pet is already fully accounted for.

Slug (the cat-thief) stole from the eldest of the three girls. Since Abigail is described as younger than the girl who owns the dog these facts mean jointly that she must own the horse.

With the horse now fully accounted for, the fact that Mike (the dog-thief) did not steal from Bernice means that Bernice owns the cat. With only one pet left, Carol must own the dog.

Final answer: Mike stole the dog from Carol; Spike, the horse from Abigail; and Slug, the cat from Bernice.

Who Stole What? (Who Stole from Whom? Part IX)

One day, Mike, Spike, and Slug went to the neighboring town of Middleberg and committed three robberies. One of them stole a rifle, one stole some money, and one stole a book. The three were caught, but it was not known which man stole what. At the trial, they made the following statements:
Mike: Slug stole the book.
Spike: Not so; Slug stole the money.
Slug: Those are both lies. I didn’t steal either!
As it happened, the one who stole the rifle was lying, and the one who stole the book was telling the truth.
Who stole what?
(Source: King Arthur in Search of His Dog and Other Curious Puzzles by Raymond Smullyan)

Mike cannot have stolen the book, because he would have said that he stole the book. Slug cannot have stolen the book for the same reason. Therefore, Spike stole the book, which means that Slug stole the money and Mike stole the rifle.

Who Owns the Goat? (Who Stole from Whom? Part VIII)

The goat belonged to either Farmer White, Farmer Brown, or Farmer Black. Farmer White claimed that the goat was his. Farmer Brown claimed that the goat did belong to Farmer White. Farmer Black either claimed that the goat belonged to him, or he claimed that it belonged to Farmer Brown, but, unfortunately, the court records are confused on this point. At any rate, at least two of the claims were correct.
Who owns the goat?
(Source: King Arthur in Search of His Dog and Other Curious Puzzles by Raymond Smullyan)

If Farmer Brown owned the goat, then Farmer Brown would be lying, as would Farmer White, leaving only one more claim to be possibly true, so Farmer Brown does not own the goat. If Farmer Black owned the goat, then Farmer Brown and Farmer White are still both lying. Therefore Farmer White owns the goat.

Sunday, April 14, 2019

Who Stole the Goat? (Who Stole from Whom? Part VII)

One day a goat was stolen. Naturally, Mike, Spike, and Slug were the suspects, and, in fact, one and only one of them was guilty. Each of the three accused one of the others, and Mike was the only one who lied. Was Mike necessarily guilty?
(Source: King Arthur in Search of His Dog and Other Curious Puzzles by Raymond Smullyan)

Consider the two alternatives: first, if Spike stole the goat, then Spike cannot accuse himself, only one of the others, falsely. The same contradiction applies to Slug. Therefore Mike was necessarily guilty.

Thursday, April 11, 2019

Which Farmer Owned the Horse? (Who Stole What from Whom? Part VI)

The horse was recovered and was to be given back to the rightful owner, who was either Farmer White, Farmer Brown, or Farmer Black. The three farmers each made two statements:

Farmer White:
  1. The horse does not belong to Farmer Brown.
  2. It belongs to me.
Farmer Brown:
  1. The horse does not belong to Farmer Black.
  2. It belongs to Farmer White.
Farmer Black:
  1. The horse does not belong to Farmer White.
  2. It belongs to me.
As it happened, one of the three made two true statements; one made just one true statement; and one made statements that were both false.
Who owns the horse?
(Source: King Arthur in Search of His Dog and Other Curious Puzzles by Raymond Smullyan)

Assume that Farmer White is making two true statements. Accordingly, Farmer Brown is also making two true statements, which is a contradiction. Conversely, the assumption that Farmer Brown is making two true statements is rendered a contradiction by the statements of Farmer White, who would also be required to make two true statements under this assumption. Therefore, only Farmer Black can be making two true statements.

It has now already been established that Farmer Black is the owner of the horse but to complete the puzzle, it should be pointed out that Farmer Brown is making two false statements and Farmer White is making one true and one false statement.

Sunday, April 7, 2019

Who Stole the Horse? (Who Stole What from Whom? Part V)

One day, a horse was stolen. Again, Mike, Spike, and Slug were rounded up for questioning. This time, each one made two statements. None of them made more than one false statement.

Mike:
  1. I did not steal the horse.
  2. The one who stole the horse is Italian.
Slug:
  1. Mike never stole the horse.
  2. The one who stole the horse is German.
Spike:
  1. I never stole the horse.
  2. It was Slug who stole the horse.
Assuming that one of those three men really stole the horse, which one was it?
(Source: King Arthur in Search of His Dog and Other Curious Puzzles by Raymond Smullyan)

Spike cannot have stolen the horse because he would be issuing two false statements. If Mike stole the horse, then his second statement must be true, namely that the one who stole the horse is Italian. But then Slug would be issuing two false statements as was the case with Spike earlier. Accordingly, Slug stole the horse.

Wednesday, April 3, 2019

Who Owns the Cat? (Who Stole What from Whom? Part IV)

The cat belonged to one of three girls—Annabelle, Betsy, or Cynthia. Annabelle claimed that Betsy doesn't own the cat, and Betsy claimed that Cynthia owns the cat. Now, it so happens that the the owner of the cat always tells the truth and is the only one of the three girls who ever tells the truth.
Who owns the cat?
(Source: King Arthur in Search of His Dog and Other Curious Logic Puzzles by Raymond Smullyan)

Suppose that Annabelle is not the owner. This would imply that her claim that Betsy doesn't own the cat is a falsehood. This would in turn imply that Betsy is the owner of the cat and therefore speaks truth. But if Betsy were the owner of the cat and accordingly a truth-teller, she would not claim that Cynthia owns the cat, which is a contradiction. Therefore Annabelle must be the owner of the cat.

Monday, April 1, 2019

Who Stole the Cat? (Who Stole What from Whom? Part III)

One day a cat was stolen. Mike, Spike, and Slug were again rounded up for questioning. Mike claimed that Spike had stolen it, and Spike claimed that Slug had stolen it. Now, it was not certain that any of the three suspects had stolen it, but later investigation showed that no guilty person told the truth and no innocent person lied. Also, the cat was not stolen by more than one person.
Can it be determined who stole the cat?
(Source: King Arthur in Search of His Dog and Other Curious Puzzles by Raymond Smullyan)

If Mike stole the cat then Spike's accusation is false, which is not allowed, letting him off the hook. The same reasoning applies to the possibility of Slug being the thief: Mike is falsely accusing Spike. It can't be the case that no one stole the cat because in this case, not one but two false accusations are being made. Therefore Spike stole the cat.

Who Owned the Dog? (Who Stole What from Whom? Part II)

The dog was recovered. It belonged to one of three boys—Arthur, Bernard, or Charles. They made the following statements:
Arthur: Bernard doesn't own it.
Bernard: That is true.
Charles: Arthur doesn't own it.
As it happened, the real owner was telling the truth, and at least one of the others was lying.
Which boy owns the dog?
(Source: King Arthur in Search of His Dog and Other Curious Puzzles by Raymond Smullyan)

Charles is excluded from being the owner because that makes the other two statements true. Bernard is also excluded because he would be agreeing with a lie (Arthur's statement). Arthur is the only candidate left.

Saturday, March 30, 2019

Who Stole the Dog? (Who Stole What from Whom? Part I)

A certain dog was stolen one day. Three suspects—Mike, Spike, and Slug—were rounded up for questioning. They made the following statements:
Mike: I didn't steal the dog.
Slug: I stole the dog.
Spike: Slug never stole the dog!
As it happened, at most, one of these three statements was true.
Who stole the dog?
(Source: King Arthur in Search of His Dog and Other Curious Puzzles by Raymond Smullyan)

This one actually falls to the first option: if Mike stole the dog, then Spike's statement is the only true statement here.

Tuesday, March 26, 2019

Apples and Oranges

In front of you are three boxes, the first labelled ‘apples’, the second ‘oranges’ and the third ‘apples and oranges’. One box contains apples, one contains oranges, and the other contains apples and oranges. Each label, however, is on the wrong box. Your job is to correctly reassign the labels. You can’t see (or smell) what’s in any of the boxes. But you are allowed to stick your hand in one of them and remove a single piece of fruit.
Which box do you choose, and once you see that piece of fruit how do you deduce the correct contents of all the boxes?
(Source: Can You Solve My Problems? A Casebook of Ingenious, Perplexing and Totally Satisfying Puzzles by Alex Bellos)

Take a fruit from the box labeled "apples and oranges". That box is to be labeled with the sign bearing the name of that fruit. If the first labeled box contains apples then the other two are currently labeled "apples" and "oranges". The box labeled "apples" contains oranges and the box labeled "oranges" contains apples and oranges. If however the first labeled box contains oranges then the box labeled "apples" contains apples and oranges and the box labeled "oranges" contains "apples and oranges".

St Dunderhead's

St. Dunderhead’s School at Fogwell has a high reputation for hockey – but not so high a reputation for veracity. The First XI played a match at Diddleham recently, after which the girls were allowed to go to a concert. Miss Pry, the mistress in charge, collected the team afterwards; she saw ten girls emerge from the concert hall and one from the cinema next door. When she asked who had been to the cinema, the members of the team replied as follows:
Joan Juggins: ‘It was Joan Twigg.’
Gertie Gass: ‘It was I.’
Bessie Blunt: ‘Gertie Gass is a liar.’
Sally Sharp: ‘Gertie Gass is a liar, and so is Joan Juggins.’
Mary Smith: ‘It was Bessie Blunt.’
Dorothy Smith: ‘It was neither Bessie nor I.’
Kitty Smith: ‘It wasn’t any of us Smith girls.’
Joan Twigg: ‘It was either Bessie Blunt or Sally Sharp.’
Joan Forsyte: ‘Both of the other Joans are telling lies.’
Laura Lamb: ‘Only one of the Smith girls is telling the truth.’
Flora Flummery: ‘No, two of the Smith girls are telling the truth.’

Given that, of these eleven assertions, at least seven are untrue, who went to the cinema?
(Source: Can You Solve My Problems? A Casebook of Ingenious, Perplexing and Totally Satisfying Puzzles by Alex Bellos)

It isn't necessary to go through every possibility. After evaluating the statements for the first two girls I noticed a lot of the statements have to do with the Smith girls, so a lot would hinge on one of them having gone to the cinema. And in fact it was Dorothy. Checking this is trivial, so I will omit a full solution.

Friday, March 15, 2019

Darklands Puzzle #33

The path is blocked by a grim iron door. Carved overhead are the words:
EACH STATUE SPEAKS EITHER ALL TRUTH OR ALL LIES.
PUSH A STATUE TO PASS.
Standing by on the door are two statues: one of a dwarf, the other of a kobold.
The dwarf statue says, "The statue which opens the door always lies."
Which statue should you push? A mistake could (will. ed.) release a trap! You think carefully, then press...
...the dwarf statue.
...the kobold statue.
(Source: Darklands cluebook by MicroProse Software)

If the dwarf is lying then one must press the kobold statue, as the dwarf statue would be telling the truth if pressing it opened the door. If, on the other hand, the dwarf is telling the truth then one must still press the kobold statue, as the dwarf statue would be implicating itself as a liar if pressing it opened the door, which is not possible.

Darklands Puzzle #32

A grim iron door blocks your way. Above the door is carved:
EACH FACE SPEAKS EITHER WHOLLY TRUTH OR ALL LIES.
PRESS ONE OF THE FACES TO OPEN THE DOOR.
Two embossed faces, one gold, one silver, hang near the door. They speak.
Gold: "Press Silver to open the door."
Silver: "Exactly one of us speaks the truth."
The wrong face probably (certainly. ed.) triggers a trap. After careful calculation you press...
...the gold face.
...the silver face.
(Source: Darklands cluebook by MicroProse Software)

If Silver is telling the truth then Gold is lying and one must touch the Gold face. On the other hand if Silver is lying then the only option is that no one is telling the truth, because the alternative of both of them telling the truth would result in a contradiction. In this case Gold is still lying and one must still touch the Gold face.

Darklands Puzzle #30

A door blocks your path. An inscription reads:
Ooo, ooo, aaah? Is this some type of dwarf joke? In any case, five metal knobs are on the door, each bearing a number. Pressing the wrong knob may (will. ed.) spring a trap! You ponder, then press...
...0.
...2.
...4.
...6.
...8.
(Source: Darklands cluebook by MicroProse Software)

The leftmost digit, "A", must be one, as established in the solution to Darklands puzzle #2. The fact that the rightmost column, where "O" is added to itself, results in "H" in this instance, but that the same addition results in "A" in all other instances, indicates that carrying is taking place. The smallest number which, when added to itself, results in a carry operation is five. It is also the correct one. In other words, the decrypted addition is $555 + 555 = 1110$. This means that one must touch the knob labeled zero.