1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from collections import defaultdict # accumulate results by (<divisor>, <answer>) pairs s = defaultdict(list) # consider triples composed of single digits (i, j, k) for i in range(1, 10): for j in range(i, 10): for k in range(j, 10): n = i * j * k if n > 99: break (x, y) = divmod(n, 10) if x == y or y == 0: continue # n = 10x + y = by + x (b, r) = divmod(n - x, y) if r != 0 or not(x < b and y < b): continue # record tuples t = (i, j, k) print(f"[{n} (base 10) = {y}{x} (base {b}), {n} -> {t}]") for d in range(1, 10): s[(d, d in t)].append((n, t, x, y, b)) # look for keys (divisors) that give unique sums for (k, v) in s.items(): if len(v) > 1: continue (n, t, x, y, b) = v[0] print(f"question: {t[0]}x{t[1]}x{t[2]} (= {n}), jay's answer: {y}{x} (in base {b} = {n}) [k={k}]") |

In the end there is only one possible solution, where Kay asks about the digit 4, and receives a “Yes” answer.

I found it curious that we are asked to submit Jay’s written answer, which can refer to multiple possible written questions, rather than the three digits of the written question, which are unique (and from which we can determine Jay’s answer).

]]>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from itertools import combinations_with_replacement from collections import defaultdict # index solutions on each of their multipliers n2s = defaultdict(list) # consider all combinations of three (possibly repeated) # ordered single digits for i, j, k in combinations_with_replacement(range(1, 10), 3): # find the tens and units digits in decimal notation t, u = divmod(i * j * k, 10) # consider only two digit results (in either base) if 0 < t < 10 and 0 < u < 10: # now find a base in which reversing the decimal digits # gives a correct answer (i.e. u * b + t = 10 * t + u) b, r = divmod(9 * t + u, u) # the digits must be less than the base if not r and max(t, u) < b: # save the result indexed on each of the three multipliers tu = ((i, j, k), t, u, b) n2s[i].append(tu) n2s[j].append(tu) n2s[k].append(tu) # now look for a multiplier for which the result is unique for key in n2s.keys(): ((i, j, k), t, u, b), *r = n2s[key] if not r: print(f'{u}{t} ({i} x {j} x {k} = {t}{u} base 10 = {u}{t} base {b}).') |