The Reichenbach Reckoning: Sherlock Holmes’ Mathematical Mysteries
These quests are infused with the atmosphere of Victorian mystery, deductive reasoning, and the intrigue of 221B Baker Street. The problems are now framed as cases or puzzles Holmes and Watson might encounter, requiring clever twists and contextual reasoning.
Written Problems
1. The Seating of the Diogenes Club
Sherlock Holmes investigates a clandestine meeting at the Diogenes Club, where 10 distinct members must sit in a row under strict protocols:
a. If no rules bind their arrangement, how many ways can the silent gentlemen be seated?
The number of ways to arrange 10 distinct individuals in a row, considering that each individual can be chosen only once, is simply the factorial of the number of people. That is
b. Suppose Mycroft Holmes and his aide, bound by mutual distrust, must sit side-by-side to monitor each other—how many arrangements are possible?
There are 9 ways to arrange Mycroft Holmes and his aide so that they are seated side by side. For each of these arrangements, the remaining 8 seats can be filled in
c. If 5 are seasoned inspectors and 5 are novice constables, and no two of the same rank may sit adjacent (lest rivalries flare), how many seating orders hold?
There are two possible starting ranks (inspector or constable), each leading to
d. If the 10 form 5 pairs of informants and handlers, each pair inseparable due to whispered secrets, how many arrangements emerge?
We can consider the 5 pairs as single entity, so the number of arrangements of them is
2. The Cipher Arrays of Irene Adler
Irene Adler hides messages in sorted arrays of k distinct integers, each from 1 to n (e.g.,
To recap, the arrays are strictly increasing sequences of
3. The Paths of the Hound
A mechanical hound roams an
a. With no bounds, how many trails can it leave?
To go from
b. If it must first lurch right (a faulty gear), how many paths remain?
If it must first lurch right, the mechanical hound must move down exactly
c. If it switches direction exactly thrice (right-to-down or down-to-right), how many routes obey?
Having exactly three switches means that the grid must be at least 3 in size.
Having said that, we have 2 cases in which it can happen to have three switches.
Let us start with the first case, i.e. when the hound starts to go right.
One of the two patterns will necessarily be the following:
- the hound makes
moves to the right, then - the hound makes
moves downwards, then - the hound makes
moves to the right, then - the hound makes
moves downwards
Let's calculate how many ways the hound can go right. How many combinations can we make with
Similarly, how many combinations can we make with
Thus, if the hound starts with the right, he can make
The other pattern will be as follows (if the hound starts downwards):
- the hound makes
moves downwards, then - the hound performs
moves to the right, then - the hound makes
moves downwards - the hound makes
moves to the right
Let's calculate how many ways the hound can go down. How many combinations can we make with
Similarly, how many combinations can we make with
Thus, if the hound starts with down, it can make $(n-2) ´many times (m-2)´ possible moves by changing direction exactly three times.
Putting everything together, if the hound changes direction exactly three times, it can make
4. The Poker Game at Reichenbach
Holmes faces Moriarty at a poker table, where all five-card hands from a 52-card deck are equally likely:
a. What is the probability of a flush (all of the same suit), including a royal flush?
A flush requires 5 cards of the same suit. There are 4 suits, each with 13 cards. The number of flushes is
b. What is the probability of two pairs (a, a, b, b, c, distinct values)?
The total number of possible hands is
To form a two-pair hand, we have
c. What is the probability of four pairs (a, a, a, b, distinct)?
The total number of possible hands is
To get four of a colour we have 13 different combinations and then we are left with 48 cards to choose from. The probability of getting a four of a colour is therefore equal to
5. The Binary Telegram of Baskerville
A telegraph sends M 0’s and N 1’s in random order. What’s the chance the first r bits hold exactly k 1’s, as if decoding a hound’s howl?
Let us proceed in order. The total number of ways to arrange M zeros and N ones is
6. The Menagerie of Moriarty
Holmes uncovers Professor Moriarty’s scheme to display 3 bird species and 3 reptile species, selected from 8 birds and 6 reptiles, in a sinister zoo:
a. If Moriarty chooses freely, how many exhibits can he craft?
Moriarty can freely select 3 birds from 8 and 3 reptiles from 6. The number of exhibits is
b. Two birds—one a hawk with a piercing cry, the other a raven with a deadly glare—cannot coexist without chaos. How many exhibits avoid this peril?
We only have to remove the combinations in which the hawk and the raven appear, which are exactly 6 (2 positions are already fixed for the hawk and the raven, and for the third one 6 birds remain).
The number of exhibits is
c. A venomous parrot and a cobra, when paired, unleash a toxic fog. How many exhibits dodge this trap?
Like point b, just remove all combinations in which the parrot and cobra appear from the total. The combinations in which the parrot does not appear are
7. The Investments of Baker Street
Holmes secures £20 million to fund 4 shadowy enterprises, investing in £1 million units, each with a minimum stake: £1M, £2M, £3M, £4M.
a. If all 4 must be funded to foil Moriarty’s network, how many strategies exist?
(Having no idea how to approach such a problem, I googled and discovered the existence of the combinatorial counting technique stars and bars, which is fundamental to solving problems of this type).
Since each enterprise has a minimum investment requirement, we first need to subtract the minimum required amounts from 20, that is
means that we give 2M to the first enterprise, 3M to the first enterprise, 4M to the third enterprise and 1M to the fourth enterprise. In this way the millions available will always be 10 but using the barriers we can calculate all possible ways to distribute them. It is therefore a matter of calculating all possible positions where I can put barriers on 13 available positions (10 (balls) + 3 (barriers)). Therefore, there are exactly
b. If at least 3 must be backed (to keep the web intact), how many plans work?
In order to calculate all the ways there are to distribute the 20 million among the 4 enterprises by ensuring that at least 3 enterprises receive the financing, it is sufficient to add up the cases in which all 4 enterprises are financed and the cases in which exactly 3 enterprises are financed. We have already calculated the first one in the previous exercise, i.e.
We start by excluding the first one. If enterprise 1 is removed, we have 11 million that we can distribute among the other three. We then use the same tactic as above, taking into account that this time we have 2 barriers. If firm 1 is removed, we have
If firm 2 is removed, we have 12M which we can distribute among the other 3 firms. We then have
If firm 3 is removed, we have 13M which we can distribute among the other 3 firms. We then have
If firm 4 is removed, we have 14M which we can distribute among the other 3 firms. We then have
Finally, if at least 3 must be supported, there are
8. The Coding Conundrum of Scotland Yard
Holmes probes a cryptography school where 100 agents study 3 courses—Java, C++, Python—under Lestrade’s watch:
Java: 27 agents; C++: 28; Python: 20.
12 crack Java and C++; 5 master Java and Python; 8 excel in C++ and Python.
2 prodigies conquer all three.
a. What’s the chance a random agent has evaded all courses, lurking in the shadows?
To compute the chance a random agent has evaded all courses, it's sufficient to calculate
The chance a random agent has evaded all courses
b. What’s the chance an agent studies exactly one, avoiding the others’ scrutiny?
To compute the chance an agent studies exactly one course, it's sufficient to calculate
The chance an agent studies exactly one course is
c. If two agents are nabbed, what’s the odds at least one knows a course? Give a final number.
To calculate the odd at least one of two agents know a course it's sufficient to compute the probability that both of them evade all courses and then making
9. The Passwords of the Naval Treaty
A spy tackles n distinct passwords, one unlocking a treaty:
a. Trying randomly and discarding failures, what’s the chance the k-th attempt succeeds?
If the k-th attempt succeeds, it means the
In addition, we can see that every numerator simplifies with the. next denominator, hence the final result simplifies to
b. Trying randomly without discarding, stopping at success, what’s the chance the k-th try wins?
The reasoning is similar of the precedent point, but this time every event is indipendent, thus we do not have to decrease the total of password at each fail.
The chance the k-th try wins is:
10. The Dice of the Speckled Band
Holmes rolls a six-sided die six times to crack a gypsy code:
a. What’s the chance two numbers appear thrice each (e.g., three 4s, three 6s)?
First, we have to compute how many ways there are that two numbers (that will appear three times each) appear twice. There are
b. What’s the chance exactly one number hits thrice, no more, no less?
First, there are 6 possible numbers on the die. Let's take for example the case where the number 1 has to hit exactly thrice. The numbers of ways it can appear exactly 3 times in 6 throws is
11. The Letters of the Red-Headed League
Holmes dispatches 20 distinct letters to 12 unique informants, each landing randomly. What’s the chance 4 get exactly 2 letters and 3 get exactly 4, the rest empty-handed?
Each of the 20 distinct letters can go to any of the 12 informants, then the total combinations are
First, let's compute the number of ways we can partition the 12 informants into 3 groups of 4,3 and 5 informants, that is is
12. The Buckets of Bohemia
m clues are hashed into N buckets by a rogue algorithm, all N^m outcomes equal. What’s the chance exactly k land in the first bucket?
Each of the m clues can independently go into any of the N buckets, then the chance exactly k land in the first bucket is simply the Probability Mass Function of the binomial:
13. Coding (Sherlock Holmes Edition)
- The Game of the Final Problem
Holmes and Moriarty duel with a device spitting integers from 1 to 100. Holmes adds to S (from 0) until S > 100, noting his last number x. Moriarty resumes, adding until S > 200, noting y. The higher wins. Simulate 100,000 rounds in Python 3 and estimate Moriarty’s victory odds.
Here's the code.
import random
moriarty_wins = 0
simulations = 100000
for _ in range(simulations):
# Holmes' turn
s = h = m = 0
# keep summing the generated number to s until it exceeds 100
while h <= 100:
num = random.randint(1, 100)
s += num
if s > 100:
h = num
break
# Moriarty's turn
# keep summing the generated number to s until it exceeds 200
while m <= 200:
num = random.randint(1, 100)
s += num
if s > 200:
m = num
break
if m > h:
moriarty_wins += 1
victory_prob = moriarty_wins / simulations
print("Moriarty's victory probability: " + str(victory_prob))