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.