Teaser 2857: Significant errors
From The Sunday Times, 25th June 2017 [link] [link]
Last year George and Martha were going to visit one of their daughters. Her house number was a two-figure number but unfortunately Martha wrote the number incorrectly by making the first digit less than it should be. When George discovered the error he commented that the incorrect number was a whole number percentage of the correct one. If you knew that percentage then you should be able to work out their daughter’s house number.
Then the daughter moved to a different two-figure house number, Martha again wrote the number incorrectly by making the first digit less than it should be, and again the incorrect number was a whole number percentage of the correct one. If you knew that percentage then you should be able to work out their daughter’s new house number.
What was the daughter’s original house number, and what is the new one?
[teaser2857]
Jim Randell 8:46 am on 21 April 2022 Permalink |
This Python program collects possible (house-number, wrong-number, percentage-reduction) values, and then uses the [[
filter_unique()]] function from the enigma.py library to find the required values for the first and second house numbers.It runs in 55ms. (Internal runtime is 333µs).
Run: [ @replit ]
from enigma import (irange, div, filter_unique, unpack, printf) # record (n, w, p) results rs = list() # consider two digit house numbers for n in irange(20, 99): # consider different numbers with the first digit less than the # correct digit, but the second digit is correct for w in irange(10 + (n % 10), n - 1, step=10): # calculate the percentage w / n p = div(100 * w, n) if p is None: continue rs.append((n, w, p)) # if you knew the percentage you would know the correct house number fn_n = unpack(lambda n, w, p: n) fn_p = unpack(lambda n, w, p: p) for (n1, w1, p1) in filter_unique(rs, fn_p, fn_n).unique: printf("p1={p1}% -> n1={n1} w1={w1}") # look for results with a different house number rs1 = filter(unpack(lambda n2, w2, p2: n2 != n1), rs) for (n2, w2, p2) in filter_unique(rs1, fn_p, fn_n).unique: printf(" p2={p2}% -> n2={n2} w2={w2}") printf()Solution: The first house number was 50. The second house number was 75.
There are two possible scenarios:
But in both cases the first house number is 50 and the second house number is 75.
Here are the 15 possible (house number, wrong number) pairs, grouped by percentage:
From which we see the only values with a unique percentage are:
Both cases give a first house number of 50.
If we remove pairs with a first house number of 50 from those listed above we get:
And we see there is only one value with a unique percentage:
And so the second house number is 75.
LikeLike