From The Sunday Times, 22nd December 2024 [link] [link]
In Cluedo, one “room” card (from nine possible ones), one “person” card (from six) and one “weapon” card (from six) are placed in a murder bag. The remaining 18 cards are shared out (four or five per player). Players take turns to suggest the contents of the murder bag. If wrong, another player shows the suggester a card, eliminating one possibility. The first person to know the contents of the murder bag will immediately [reveal their solution and] claim victory.
My brothers and I are playing, in the order Michael-John-Mark-Simon. After several completed rounds, we all know the murder was committed in the Study. Michael and I know the murderer was Miss Scarlet with one of four weapons. Mark and Simon know the weapon and have narrowed it down to four people. Being new to Cluedo, we don’t learn from others’ suggestions.
From this point on, what are Michael’s chances of winning (as a fraction in its lowest terms)?
To clarify the wording, the intention is that once a player has deduced the contents of the murder bag, they reveal their solution, and do not have to wait for their next turn.
[teaser3248]
Jim Randell 7:07 am on 12 January 2025 Permalink |
It is straightforward to test all 3-digit numbers for the required property, and then look for (proper) subsets of the numbers found, to find a subset with a prime sum.
This Python program runs in 65ms. (Internal runtime is 1.1ms).
from enigma import (irange, nsplit, subsets, is_prime, diff, printf) # find 3-digit numbers that are the sum of the cube of their digits cb = list(d**3 for d in irange(0, 9)) ns = list(n for n in irange(100, 999) if n == sum(cb[d] for d in nsplit(n))) printf("numbers = {ns}") # find (proper) subsets that sum to a prime for ss in subsets(ns, min_size=1, max_size=len(ns) - 1): t = sum(ss) if not is_prime(t): continue # output solution missing = diff(ns, ss) printf("sum{ss} = {t}; missing = {missing}")Solution: The numbers not found are: 371, 407.
There are only four such numbers (if leading zeros are disallowed):
And the only strict subset of these with a prime sum is:
If all four numbers had been found, the sum would also have been prime:
LikeLike
Frits 2:56 pm on 12 January 2025 Permalink |
from itertools import combinations def is_prime(n): if n < 4: return n > 1 if n % 2 == 0 or n % 3 == 0: return False # all primes > 3 are of the form 6n +/- 1 # start with f=5 (which is prime) and test f, f+2 for being prime f, r = 5, int(n**0.5) while f <= r: if n % f == 0: return False if n % (f + 2) == 0: return False f += 6 return True nums = [] for a in range(1, 10): a3 = a * a * a for b in range(10): a3b3 = a3 + b * b * b for c in range(10): t = a3b3 + c * c * c if t // 100 != a: continue if t % 10 != c: continue if (t % 100) // 10 != b: continue nums += [t] sum_nums = sum(nums) print("answer(s):") for k in range(1, len(nums)): # pick <k> numbers from <ns> she has missed for s in combinations(nums, k): # she gave me a prime number if is_prime(sum_nums - sum(s)): print(s)LikeLike
ruudvanderham 12:09 pm on 13 January 2025 Permalink |
Rather straightforward:
import istr istr.repr_mode("str") solutions = {i for i in istr(range(100, 1000)) if sum(digit**3 for digit in i) == i} print(*list(f"missing: {solutions - set(x)}" for r in range(1, len(solutions)) for x in istr.combinations(solutions, r=r) if sum(x).is_prime()))LikeLike