From The Sunday Times, 25th May 1980 [link]
Large families often have problems, particularly when it comes to deciding who has first choice, etc.
My six brothers and I solved this particular one by devising our own dice game. Each of us in turn would roll a die four times and put the results together in that order to form a four-figure number. (So that, for example: 6 followed by 2, then 3 and 1, gives the number 6231). We would each do this and the one of us getting the highest four-figure number would be declared the winner.
One such game had some very strange results. Each of us got a different prime number, using the same four different digits. The average of the seven primes was a perfect square, to which Jon’s number was the nearest.
The difference between Ron’s and Don’s numbers, multiplied by one of the numbers from the die, gave the difference between Len’s and Ken’s numbers.
Omitting Ben’s score, the total could have been formed by throwing the die five times. And so could the total of the numbers thrown by Len, Ken, Ron and me.
What was my score, and who ate the biggest piece of apple pie?
The originally published version of this puzzle was flawed, so the version above was taken from the book Microteasers (1986), in which it was noted:
There is an interesting postscript to [this] puzzle. When it first appeared, the condition “each of us got a different prime number using the same four different digits” was given as “each of us got a different prime number; two digits never came up”. That allowed numbers like 5651, which was not the intention at all. The odd thing is that all the readers who sent in answers found the intended solution anyway. So perhaps, even if one relaxes the condition about all the primes using four different digits, the teaser still has a unique solution. The keener reader might like to adapt the program to take four digits in turn and see how many primes can be made from those four (but not necessarily using all four each time). Then you have to consider all possible sets of seven from those. We leave this much harder problem as an exercise.
However the original formulation of the puzzle does not give a unique solution.
[teaser931]
Jim Randell 8:43 am on 16 March 2023 Permalink |
We can use the [[
SubstitutedExpression()]] solver from the enigma.py library to find viable allocations of the 9 digits to three 2-digit squares, a 2-digit prime, and the remaining digit. We can then use the [[filter_unique()]] function to select those allocations that are unique by the remaining digit.This Python program runs in 57ms. (Internal runtime is 4.4ms).
Run: [ @replit ]
from enigma import (SubstitutedExpression, irange, filter_unique, item, printf) # squares: AB, CD, EF; prime: GH p = SubstitutedExpression( [ "is_square(AB)", "is_square(CD)", "is_square(EF)", "A < C < E", "is_prime(GH)", ], digits=irange(1, 9), answer="(X, AB, CD, EF, GH)" ) # if we knew X, we could deduce the 2-digit numbers rs = filter_unique(p.answers(verbose=0), item(0)).unique # output solution for (X, sq1, sq2, sq3, pr) in rs: printf("X={X} -> squares = ({sq1}, {sq2}, {sq3}), prime = {pr}")Solution: The four 2-digit numbers were: 16, 25, 49 (squares), and 83 (prime).
So Megan’s house number is 7.
LikeLike
GeoffR 11:56 am on 16 March 2023 Permalink |
from enigma import is_square, is_prime from itertools import permutations from collections import defaultdict nums = defaultdict(list) for p1 in permutations('123456789'): a, b, c, d, e, f, g, h, i = p1 ab, cd, ef = int(a + b), int(c + d), int(e + f) if ab < cd < ef : if is_square(ab) and is_square(cd) and is_square(ef): gh = int(g + h) if is_prime(gh): nums[i] += [(ab, cd, ef, gh)] for k, v in nums.items(): if len(v) == 1: print(f"Megan's house number was {k}.") print(f"Her four 2-digit numbers were {v}.") # Megan's house number was 7. # Her four 2-digit numbers were [(16, 25, 49, 83)].LikeLike
GeoffR 11:41 am on 17 March 2023 Permalink |
The basis of this teaser can be seen by printing the python dictionary in this solution, with the house number as the key. All house numbers, except 7, have multiple solutions for the four 2-digit numbers.
8 [(16, 25, 49, 37), (16, 25, 49, 73), (25, 36, 49, 17), (25, 36, 49, 71)]
7 [(16, 25, 49, 83)]
9 [(25, 36, 81, 47), (25, 64, 81, 37), (25, 64, 81, 73)]
4 [(25, 36, 81, 79), (25, 36, 81, 97)]
6 [(25, 49, 81, 37), (25, 49, 81, 73)]
3 [(25, 49, 81, 67), (25, 64, 81, 79), (25, 64, 81, 97)]
LikeLike