From The Sunday Times, 22nd September 1974 [link]
Ashley, Bill, Charles, David, and Edward are (not necessarily in that order), a dustman, a grocer, a miner, a blacksmith, and an artist, and all live on the right hand side of Strife Lane, in even numbered houses. All five are of different ages and no man has reached the age of retirement (65). All of course are upright and honest citizens, and never tell lies. However, I had forgotten what job each man did, where he lived, and how old he was, and so, to help me, each man volunteered the following statements:
Ashley:
(1) The artist lives at No. 10, next to Charles;
(2) Nobody lives next to the grocer, although Bill is only two doors away.
Bill:
(3) I am the only man whose age is indivisible by 9;
(4) I am 4 years older than Ashley;
Charles:
(5) The blacksmith’s age is 5 times his house number;
David:
(6) The miner lives 4 houses higher up the road from me;
(7) The miner’s age is 3 times the dustman’s house number, but he is two-thirds the dustman’s age;
Edward:
(8) The dustman is twice as old as David;
(9) I am the oldest man in the street.
At what number does Ashley live?
How old is the grocer?
Who is the artist?
This puzzle is included in the book The Sunday Times Book of Brain-Teasers: Book 1 (1980). The puzzle text above is taken from the book.
[teaser688]
Jim Randell 8:48 am on 4 March 2021 Permalink |
This Python program runs in 47ms.
Run: [ @repl.it ]
from enigma import divf, irange, printf # percentage a/b to the nearest whole number percent = lambda a, b: divf(200 * a + b, 2 * b) # total number of people expected (including aunt) for n in irange(2, 100): # consider number of vegetarians for v in irange(1, n): # percentage vegetarians (to nearest whole number) p = percent(v, n) if p > 9: break # and if aunt doesn't come, is percentage the same? if percent(v - 1, n - 1) == p: # output solution printf("{n} total; {v} veg [{p}% veg]")Solution: If the aunt comes there will be 95 people in total. 9 of them vegetarian.
In this case the percentage of vegetarians is 9/95 ≈ 9.47%, which rounds down to 9%.
But if the aunt doesn’t come both the number of guests and the number of vegetarians is reduced by 1, giving a percentage of 8/94 ≈ 8.51%, which rounds up to 9%.
Note that Python 3’s built-in [[
round()]] function might not do what you expect:The
decimalmodule allows more control over rounding behaviour.To keep things predictable, in my program I avoided float approximations by keeping the calculations in the integer domain, and I used the common “round half up” rule.
LikeLike