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:55 am on 21 February 2021 Permalink |
1s = 12d.
Working in half-pennies (hp) the total amount to distribute is 100 d = 200 hp.
And we are told:
And the difference between two of the numbers is a square number of half pennies.
The following Python program runs in 53ms.
Run: [ @repl.it ]
from enigma import irange, is_square, div, printf # solve the equations def solution(middle, AB, AC, BC): A = div(AB + AC - BC, 2) B = div(AB + BC - AC, 2) C = div(AC + BC - AB, 2) if not any(x is None or x < 0 for x in (A, B, C)): # output solution printf("A={A} hp, B={B} hp, C={C} hp; middle = {middle}") # A + C is some multiple of 19 for AC in irange(19, 200, step=19): # B + C is some multiple of 13 for BC in irange(13, 200, step=13): # A + B is some multiple of 11 # and (A + B) + (B + C) + (A + C) = 2(A + B + C) = 400 AB = 400 - (AC + BC) if AB % 11 > 0: continue # one of the differences is a square # B - C = (A + B) - (A + C) if is_square(abs(AB - AC)): solution('A', AB, AC, BC) # A - C = (A + B) - (B + C) if is_square(abs(AB - BC)): solution('B', AB, AC, BC) # A - B = (A + C) - (B + C) if is_square(abs(AC - BC)): solution('C', AB, AC, BC)Solution: The middle son was Clive. His share was 45d = (3s 9d).
The shares are:
And we see:
And the difference between the eldest and the youngest is: B − A = 10² hp.
LikeLike
Frits 11:53 am on 21 February 2021 Permalink |
from enigma import SubstitutedExpression, is_square, peek # the alphametic puzzle p = SubstitutedExpression( [# A = AST, B = BVW, C = CYZ # start with the most restrictive constraint # A + C is some multiple of 19 "(AST + CYZ) % 19 == 0", # divide 200 half-pennies over 3 sons "200 - AST - CYZ = BVW", # B + C is some multiple of 13 "(BVW + CYZ) % 13 == 0", # A + B is some multiple of 11 "(AST + BVW) % 11 == 0", # difference between the eldest and youngest was a perfect square "peek(2 - i for (i, (x, y)) in \ enumerate(zip([AST, CYZ, BVW], [BVW, AST, CYZ])) \ if is_square(abs(x - y))) = I", ], answer="I, [AST, BVW, CYZ][I]", d2i=dict([(2, "ABC")] + [(k, "ABCI") for k in range(3, 10)]), distinct="", reorder=0, verbose=0) for (_, ans) in p.solve(): print(f"{['Alan', 'Bob', 'Clive'][ans[0]]} with share {ans[1]} half-pennies")LikeLike
Jim Randell 12:49 pm on 21 February 2021 Permalink |
Here’s an alternative solution using the [[
SubstitutedExpression()]] solver:from enigma import (SubstitutedExpression, subsets, is_square, printf) # find candidate (A, B, C) values p = SubstitutedExpression( [ "A + B + C == 200", "(A + B) % 11 = 0", "(B + C) % 13 = 0", "(A + C) % 19 = 0" ], base=201, distinct=(), answer="(A, B, C)", template="", ) # look at possible (A, B, C) values for (_, vs) in p.solve(verbose=0): # the values for the eldest and youngest differ by a square number for ((i, x), (j, y)) in subsets(enumerate(vs), size=2): if is_square(abs(x - y)): # identify the middle son m = "ABC"[3 - i - j] printf("A={vs[0]} hp, B={vs[1]} hp, C={vs[2]} hp; middle={m}")LikeLike
Hugh Casement 1:51 pm on 21 February 2021 Permalink |
Theoretically Alan and Clive could each have received 57 ha’pence and Bob 86.
Zero is also a square number! However, I doubt that is the intended solution.
LikeLike
Jim Randell 2:02 pm on 21 February 2021 Permalink |
@Hugh: Well spotted!
In my programs, both
0andNoneevaluate to false, so using the return value from [[is_square()]] as a boolean value will reject 0. (It also doesn’t consider 0 to be allowed as a multiple of 11, 13, 19).You can explicitly check [[
is_square(...) is not None]], or just import [[is_square_p()]] instead which returns a boolean.And if you do that you do indeed get two solutions:
The published solution is: “Clive, 3s 9d”.
Perhaps the setter intended the shares to be three different values.
LikeLike
John Crabtree 6:58 pm on 22 February 2021 Permalink |
Working in 1/2d, then A + B + C = 200
A + B = 11p, p ≤ 18
B + C = 13q, q ≤ 15
A + C = 19r, r ≤ 10
Summing the three gives 400 = 11p + 13q + 19r
Using r as a variable as it has the fewest possible values:
B = 200 – 19r, p = 8 + 3r mod 13, q = 3 + 7r mod 11 which leads to
A = 31 + 52r mod 143
C = 112 + 110r mod 143
It is then straightforward to manually generate a table of values for A, B and C for each r. r = 1, 2 and 4 give A+B+C = 343. r = 3 and r = 5 to 10 give A+B+C = 200 and include the two solutions noted by Jim.
LikeLike