From The Sunday Times, 21st January 1962 [link]
This unusual instrument is operated by selecting one of the four switch positions: A, B, C, D, and turning the power on. The effects are:
A: The pratching valve glows and the queech obulates;
B: The queech obulates and the urfer curls up, but the rumption does not get hot;
C: The sneeveling rod turns clockwise, the pratching valve glows and the queech fails to obulate;
D: The troglodyser gives off hydrogen but the urfer does not curl up.
Whenever the pratching valve glows, the rumption gets hot. Unless the sneeveling rod turns clockwise, the queech cannot obulate, but if the sneeveling rod is turning clockwise the troglodyser will not emit hydrogen. If the urfer does not curl up, you may be sure that the rumption is not getting hot.
In order to get milk chocolate from the machine, you must ensure:
(a) that the sneeveling rod is turning clockwise AND;
(b) that if the troglodyser is not emitting hydrogen, the queech is not obulating.
1. Which switch position would you select to get milk chocolate?
If, tiring of chocolate, you wish to receive the Third Programme, you must take care:
(a) that the rumption does not get hot AND;
(b) either that the urfer doesn’t curl and the queech doesn’t obulate or that the pratching valve glows and the troglodyser fails to emit hydrogen.
2. Which switch position gives you the Third Programme?
No setter was given for this puzzle.
This puzzle crops up in several places on the web. (Although maybe it’s just because it’s easy to search for: “the queech obulates” doesn’t show up in many unrelated pages).
And it is sometimes claimed it “appeared in a national newspaper in the 1930s” (although the BBC Third Programme was only broadcast from 1946 to 1967 (after which it became BBC Radio 3)), but the wording always seems to be the same as the wording in this puzzle, so it seems likely this is the original source (at least in this format).
“Omnibombulator” is also the title of a 1995 book by Dick King-Smith.
[teaser44]
Jim Randell 9:04 am on 20 December 2020 Permalink |
We can use the [[ SubstitutedExpression ]] solver from the enigma.py library to solve this puzzle.
The following run file executes in 95ms.
Run: [ @replit ]
Solution: CHRISTMAS = 489051765.
LikeLike
GeoffR 9:16 am on 20 December 2020 Permalink |
LikeLike
GeoffR 10:57 am on 20 December 2020 Permalink |
Another solution using the digits only in the multiple numbers.
LikeLike
Frits 2:26 pm on 20 December 2020 Permalink |
Without using modulo and with the Walrus assignment (not possible to run with PyPy).
from enigma import SubstitutedExpression # the alphametic puzzle p = SubstitutedExpression( [ # all words are odd multiples of 9 (and don't start with zero) # digits M,E,S,T,R are odd and A,N,I,C,H are even # SAM digits: one odd, 2 even; so sum is even and multiple of 18 # so A >= 2 (max(S+M) is 16), max(A) is 8 so M + S >= 10 "M + S > 9", "S+A+M = 18", # even "S+E+T = 9", # odd (9 or 27) "N+I+C+E = 9", # odd, 27 not possible as # max(N+I+C) = 14) and A is 6 or 8 (see below) # C+H+R+I+S+T+M+A+S equals C+H+R+I+S+T plus S+A+M "C+H+R+I+S+T == 27", # odd (9, 27 or 45) # T+E+A+S+E+R equals S+E+T plus A+E+R (so A+E+R is even) # max(A) is 8 so E + R >= 10 "E+R > 9", "A+E+R = 18", # even # E + R >= 10 and M + S >= 10 so T <= 5 # (A + E + R) mod 18 == 0 and (S + A + M) mod 18 == 0 # so E + R must be equal to M + S --> T is 1 or 5 and A is 6 or 8 # and THREE is a multiple of 3 # THREE contains one even digit and 4 odd digits # so sum must be even and a multiple of 6 "(tot := T+H+R+E+E) == 18 or tot == 24", ], answer="(C,H,R,I,S,T,M,A,S), E,N", # A is 6 or 8, T is 1 or 5 d2i=dict([(0, "MTESRACN")] + \ [(2, "MTESRA")] + \ [(3, "ANICHT")] + \ [(4, "MTESRA")] + \ [(7, "ANICHT")] + \ [(9, "ANICHT")] + \ [(k, "ANICH") for k in {1, 5}] + \ [(k, "MTESR") for k in {6, 8}]), distinct="CHRISTMAEN", reorder=0, verbose=0) # print answers for (_, ans) in p.solve(): print(f"{ans}") # ((4, 8, 9, 0, 5, 1, 7, 6, 5), 3, 2)LikeLike
Jim Randell 11:17 pm on 20 December 2020 Permalink |
@Frits: You could just use [[
"T+H+R+E+E in (18, 24)"]] to eliminate the “walrus” operator.LikeLike
Frits 11:26 am on 21 December 2020 Permalink |
@Jim: Thanks. “T+H+R+E+E in {18, 24}” doesn’t work in combination with SubstitutedExpression. However, “T+H+R+E+E in set((18, 24))” works.
As N+I+C+E = 9 we can also further analyze that I = 0.
Some benchmark tests on lists, sets and tuples. In one case an in_test for sets is slower than for lists and tuples.
import time from timeit import timeit from datetime import datetime # See https://stackoverflow.com/questions/2831212/python-sets-vs-lists # https://www.nuomiphp.com/eplan/en/92679.html # Determine if an object is present def in_test(iterable): for i in range(1000): if i in iterable: pass # Iterating def iter_test(iterable): for i in iterable: pass # Determine if an object is present print("# in_test") print("# set ", timeit( "in_test(iterable)", setup="from __main__ import in_test; iterable = set(range(1000))", number=10000)) print("# list ",timeit( "in_test(iterable)", setup="from __main__ import in_test; iterable = list(range(1000))", number=10000)) print("# tuple ", timeit( "in_test(iterable)", setup="from __main__ import in_test; iterable = tuple(range(1000))", number=10000)) print() # Iterating print("# iter_test") print("# set ", timeit( "iter_test(iterable)", setup="from __main__ import iter_test; iterable = set(range(10000))", number=100000)) print("# list ", timeit( "iter_test(iterable)", setup="from __main__ import iter_test; iterable = list(range(10000))", number=100000)) print("# tuple ", timeit( "iter_test(iterable)", setup="from __main__ import iter_test; iterable = tuple(range(10000))", number=100000)) print() def in_test1(): for i in range(1000): if i in (314, 628): pass def in_test2(): for i in range(1000): if i in [314, 628]: pass def in_test3(): for i in range(1000): if i in {314, 628}: pass def in_test4(): for i in range(1000): if i == 314 or i == 628: pass print("# Another in_test") print("# tuple", end=" ") print(timeit("in_test1()", setup="from __main__ import in_test1", number=100000)) print("# list ", end=" ") print(timeit("in_test2()", setup="from __main__ import in_test2", number=100000)) print("# set ", end=" ") print(timeit("in_test3()", setup="from __main__ import in_test3", number=100000)) print("# or ", end=" ") print(timeit("in_test4()", setup="from __main__ import in_test4", number=100000)) print() l = list(range(10000000)) t = tuple(range(10000000)) s = set(range(10000000)) start = time.perf_counter() -1 in l elapsed = time.perf_counter() e = elapsed - start print("# Time spent in list is: ", e) start = time.perf_counter() -1 in s elapsed = time.perf_counter() e = elapsed - start print("# Time spent in set is: ", e) start = time.perf_counter() -1 in t elapsed = time.perf_counter() e = elapsed - start print("# Time spent in tuple is: ", e) print() # Running with PyPy # # in_test # set 0.081273 # list 1.5676623 # tuple 4.0899722 # iter_test # set 3.432239 # list 3.486127399999999 # tuple 2.8504029000000006 # Another in_test # tuple 0.1158544999999993 # list 0.11811669999999985 # set 0.8540392000000008 # or 0.12334350000000072 # Time spent in list is: 0.0029356000000007043 # Time spent in set is: 4.600000000465343e-06 # Time spent in tuple is: 0.014147899999997549 # # Running with Python 3.9.0 # # in_test # set 0.4714717 # list 51.8807992 # tuple 48.01474160000001 # iter_test # set 11.122311100000005 # list 7.8272695 # tuple 8.692177200000003 # Another in_test # tuple 4.704576400000008 # list 4.779769200000004 # set 3.6342248999999924 # or 4.508794999999992 # Time spent in list is: 0.09308849999999325 # Time spent in set is: 3.800000001774606e-06 # Time spent in tuple is: 0.09272150000001034LikeLike
GeoffR 9:05 am on 22 December 2020 Permalink |
A Python 3 permutation solution.
from itertools import permutations digits = set('0123456789') for P1 in permutations(digits, 4): T, H, R, E = P1 if T == '0': continue if int(T) % 2 != 1: continue if int(E) % 2 != 1: continue THREE = int(T + H + R + E + E) if THREE % 3 != 0: continue Q1 = digits.difference(P1) # permute remaining digits for P2 in permutations(Q1): C, I, S, M, A, N = P2 if '0' in (C, S, N): continue if (int(M) % 2 != 1 or int(S) % 2 != 1 or int(R) % 2 != 1): continue SAM, SET = int(S + A + M), int(S + E + T) if SAM % 9 != 0 or SET % 9 != 0: continue NICE = int(N + I + C + E) TEASER = int(T + E + A + S + E + R) if NICE % 9 != 0 or TEASER % 9 != 0: continue CHRISTMAS = int(C + H + R + I + S + T + M + A + S) if CHRISTMAS % 9 == 0: print(f"CHRISTMAS = {CHRISTMAS}")LikeLike
John Crabtree 3:16 am on 24 December 2020 Permalink |
E, M, R, S and T are odd, and A, C, H, I and N are even
S+E+T is odd, = 9 = (1, 3, 5), and so M, R = (7, 9)
N+I+C+E is odd, = 9 = (0, 2, 4, 3) or (0, 2, 6, 1)
T+E+A+S+E+R is odd, = 27 and so A+E+R = 18
C+H+R+I+S+T is odd, = 27, and so N+A+M+E (remaining letters) = 18 = A+E+R, and so R = M+N
And so R = 9, M = 7, N = 2, and as C > 0, I = 0 and C + E = 7
From N+A+M+E = 18 = S+A+M, S = E + 2, and so C + S = 9
(C+H+R+I+S+T) – (T+H+R+E+E) = C + S – 2E = E mod 3 = 0 mod 3
And so E = 3, A = 6; C = 4, S = 5; and T = 1, H = 8.
CHRISTMAS = 489051765
LikeLike