Teaser 2675: Should old acquaintance …
From The Sunday Times, 29th December 2013 [link] [link]
I have given each letter of the alphabet a different whole number value from 1 to 26 (for instance, A has the value 5 and B has the value 24). In this way I can work out the value of any word by adding up the values of its letters. Looking at the values of the words:
SHOULD
OLD
ACQUAINTANCEI find that the value of OLD is the average of the other two values.
I also find that NEW and YEAR have the same value as each other – and it is like the value of OLD but with its two digits in the reverse order. It is possible from all this information to work out the values of N, E and W, but all we want to know is…
… what is the value of NEW?
I replaced “for example” in the original puzzle text by “for instance” to make it clear these are the actual values that are being given. In the book The Sunday Times Brain Teasers 2 (2020), the values are simply given as “(eg, A=5 and B=24)”, which I think is more ambiguous than the original text.
[teaser2675]















Jim Randell 9:16 am on 18 April 2023 Permalink |
From:
we determine:
And A = 5, so the smallest possible value for OLD is: 3×5 + 2×(1 + 2 + 3) + (4 + 6 + 7 + 8 + 9 + 10) = 71.
And this is enough to give us a way to attack the problem programatically.
This Python program runs in 81ms. (Internal runtime is 23.5ms).
Run: [ @replit ]
from enigma import (irange, subsets, group, diff, nreverse, cproduct, intersect, singleton, printf) # given values A = 5 B = 24 # collect sums of 3 digit values for OLD, NEW, YER g = group(subsets(diff(irange(1, 26), {A, B}), size=3), by=sum) # find 2-digit keys with whose reverse is also a key for OLD in g.keys(): if OLD < 71: continue NEW = nreverse(OLD) if NEW < 10 or NEW == OLD or NEW not in g: continue YER = NEW - A if YER not in g: continue # NEW and YER must have E in common (but nothing else) for (vNEW, vYER) in cproduct([g[NEW], g[YER]]): E = singleton(intersect([vNEW, vYER])) if E is None: continue # OLD has no letters in common with them vs = vNEW + vYER for vOLD in g[OLD]: if intersect([vOLD, vs]): continue # find a value for N (which also gives W) for N in diff(vNEW, {E}): # calculate remaining amount for 2CU + HIQST r = OLD - (3*A + E + 2*N) ns = diff(irange(1, 26), {A, B}, vs, vOLD) # can we make this from the remaining values? if r < sum(ns[0:2]) + sum(ns[0:7]): continue # output solution printf("OLD={OLD} NEW={NEW} YER={YER} -> E={E} NEW={vNEW} YER={vYER} OLD={vOLD} -> N={N} {ns}", ns=ns[0:7])Solution: NEW has a value of 37.
And we can determine: N = 3, E = 11, W = 23
OLD has a value of 73, so the individual letters have values 22, 25, 26 (in some order).
And Y and R are 9 and 12 (in some order).
To complete the given letters, U and C can be 1 and 2 (in some order).
And H, I, Q, S, T can be 4, 6, 7, 8, 10 (in some order).
LikeLike
GeoffR 1:56 pm on 18 April 2023 Permalink |
The Chuffed Solver took about 1 sec to run, but the Geocode Solver took about 40 sec.
LikeLike
Frits 1:05 pm on 19 April 2023 Permalink |
Not as fast as my version of Brian’s program.
[https://brg.me.uk/?page_id=1756#comment-3740]
from enigma import SubstitutedExpression # invalid digit / symbol assignments d2i = dict() for d in range(0, 27): vs = set() if d == 0: vs.update('ABCDEHILNOQRSTUWY') # 71 <= OLD <= 74 # 3A + 2CNU + EHIQST = OLD # 3×5 + 2×(1 + 2 + 3) + (4 + 6 + 7 + 8 + 9 + x) <= 74 # so x <= 13 if d > 13: vs.update('NECUHIQST') if d < 20: vs.update('OLD') if d < 21: vs.update('LD') if d < 22: vs.update('D') if d > 24: vs.update('O') if d > 25: vs.update('OL') d2i[d] = vs # the alphametic puzzle p = SubstitutedExpression( [ # order not important "O < L < D", # order not important # NEW is like the value of OLD with digits in the reverse order "(10 * ((old := O + L + D) % 10) + old // 10) - N - E = W", "C < U", # order not important # 3×5 + 2×(C + N + U) + (1 + 2 + 3 + 4 + 6 + 7) <= 74 # thus the maximum of C + N + U is 18 "(cnu := C + N + U) <= 18", # 3A + 2CNU + EHIQST = OLD, determine value of HIQST # check if remaining numbers are too high for making target HIQST "(hiqst := old - 3 * A - 2 * cnu - E) >= 16", "hiqst >= sum(sorted(set(range(1, 14)) - {A, C, E, N, U})[:5])", "H < I < Q < T", # order not important # OLD is the average of the values SHOULD and ACQUAINTANCE "old - (H+U + A+C+Q+U+A+I+N+T+A+N+C+E) = S", "Q < S < T", # order not important # NEW and YEAR have the same value "N + W - Y - A = R", "R < Y", # order not important ], answer="N + E + W", base=27, d2i=d2i, s2d=dict(A=5, B=24), reorder=0, verbose=0, # use 256 to see the generated code ) # print answers for (_, ans) in p.solve(): print(f"{ans}")LikeLike