Teaser 2899: Base jumping
From The Sunday Times, 15th April 2018 [link] [link]
In written multiplication tests Jay always calculated correct answers, but, quirkily, wrote the digits of any two-figure answers in reverse order. A completed test sheet (pre-printed with ordered triplets of single-figure positive integers to multiply, e.g., 1×2×2=? and 3×5×9=?) included a question and his two-figure written answer that would be right when thought of in a number base other than “base 10” (any numerals keeping their usual values). Jay told Kay about this, but didn’t give the question or answer. Kay asked whether one of that question’s numbers to multiply was a particular value and from the reply knew both the question and the answer Jay had written.
What was Jay’s written answer to that question?
[teaser2899]
Jim Randell 8:35 am on 17 July 2019 Permalink |
This Python program collects the possible multiplications where a reversed answer would be correct in a non-decimal base. It then uses the [[
filter_unique()]] function (from the enigma.py library) to find situations where the answer for a specific digit indicate a unique multiplication question.This Python program runs in 60ms. (Internal runtime is 673µs).
Run: [ @replit ]
from enigma import (subsets, irange, multiply, div, unpack, filter_unique, printf) # collect possible questions ss = list() # consider triples composed of single digits (i, j, k) for t in subsets(irange(1, 9), size=3, select='R'): n = multiply(t) if not (9 < n < 100): continue # n = 10x + y = by + x (x, y) = divmod(n, 10) if x == y or y == 0: continue b = div(n - x, y) if b is None: continue if not (x < b and y < b and b != 10): continue # record tuples (<triple>, <product>, <tens digit>, <units digit>, <base>) printf("[{n} (base 10) = {y}{x} (base {b}), {n} -> {t}]") ss.append((t, n, x, y, b)) # K asks if one of the numbers in the triple is a particular value k for k in irange(1, 9): # K asks if the digit k is (at least) one of the digits in the question # and from the answer can determine both the question and J's answer f = unpack(lambda t, n, x, y, b: k in t) g = unpack(lambda t, n, x, y, b: (t, n)) rs = filter_unique(ss, f, g).unique # output unique solutions for r in rs: (t, n, x, y, b) = r printf("[k={k} -> {z}] question: {t[0]}x{t[1]}x{t[2]} (= {n}), jay's answer: {y}{x} (in base {b} = {n})", z=f(r))Solution: Jay’s answer was 48.
It is odd that the setter asks for Jay’s written answer, which can refer to multiple possible written questions, rather than the three digits of the written question, which are unique.
There are 9 possible multiplications where a reversed answer would be correct in a non-decimal base:
Kay asks if the question includes the digit 4, and receives the answer “Yes”, this narrows the question down to a single possibility:
This is the only digit/answer combination which gives a unique answer for the question.
However, if Kay had asked about the digit 7, and received a “No” answer, there would have been two possible questions, but he would still be able to work out Jay’s answer:
LikeLike
GeoffR 8:18 pm on 23 July 2019 Permalink |
% A Solution in MiniZinc include "globals.mzn"; % triplets of single value positive integers var 1..9: i; var 1..9: j; var 1..9: k; % the correct two digit result in base 10 var 9..99: nbr; % tens and units digits of the result var 1..9: t; var 1..9: u; % the number base for reversed digits var 11..99: b; % order triplet digits constraint i <= j /\ j <= k; constraint nbr = i * j * k; % find tens and units digits of 2-digit number constraint t = nbr div 10 /\ u == nbr mod 10; % number is correct in base b if digits are reversed constraint nbr == 10*t + u /\ nbr == b*u + t; solve satisfy; output [show(i) ++ " * " ++ show(j) ++ " * " ++ show(k) ++ " == " ++show(nbr) ++ " (base 10) == " ++ show(u) ++ show(t) ++ " (base " ++ show(b) ++ ")"] % 1 * 3 * 7 == 21 (base 10) == 12 (base 19) % 3 * 3 * 9 == 81 (base 10) == 18 (base 73) % 1 * 9 * 9 == 81 (base 10) == 18 (base 73) % 1 * 6 * 7 == 42 (base 10) == 24 (base 19) % 2 * 3 * 7 == 42 (base 10) == 24 (base 19) % 3 * 3 * 7 == 63 (base 10) == 36 (base 19) % 1 * 7 * 9 == 63 (base 10) == 36 (base 19) % Jay's answer - digit 4 gives a unique result % 3 * 4 * 7 == 84 (base 10) == 48 (base 19) <<< % 2 * 6 * 7 == 84 (base 10) == 48 (base 19) % ---------- % ==========LikeLike