Brain-Teaser 895: Sum mistake
From The Sunday Times, 1st October 1978 [link]
Margaret was demonstrating the use of a pocket calculator to her grandfather. (Keyboard shown above). It was of the type having algebraic logic, which does continuous mixed calculations (e.g. 5 + 2 × 3 = 21). She also demonstrated that keying two consecutive operations results in the second taking preference (e.g. 5 +× 2 = 10).
Margaret asked grandfather to calculate 80 × 5 + 40 − 10; but unfortunately grandfather’s hands were a little shaky and he was prone to strike keys horizontally oг vertically adjacent to the correct one.
Having entered the sum grandfather was about to press the = key (fortunately he hadn’t pressed it before) when Margaret stopped him.
“You have made just two errors so far, and they were consecutive”, she said, “but don’t worry, if you divide by your age on your next birthday, then press the = key, you will get the correct answer to the calculation”.
Grandfather completed the calculation and correctly pressed the = key.
“Wrong again”, said Margaret, “interesting answer though — if you deduct grandmother’s age, and take the cube root of the remainder, you will get the sum of your age, and mine, on our last birthdays”.
How old are Margaret, grandmother and grandfather?
Another early calculator-based puzzle.
This puzzle is included in the book The Sunday Times Book of Brain-Teasers: Book 2 (1981). The puzzle text above is taken from the book.
[teaser895]






Jim Randell 3:25 pm on 16 September 2026 Permalink |
The following Python program codes an evaluator for the rules obeyed by the calculator, and then determines which two consecutive errors in the original sum would result in a the specified correction (which gives the grandfather’s age). It then looks for additional errors entered during the correction, and from viable results determines the ages for grandmother and Martha.
It runs in 69ms. (Internal runtime is 1.1ms).
import re from enigma import (defaultdict, irange, subsets, tuples, cproduct, update, fdiv, iroot, snapf, printf) # return (icbrt(n), remainder) def icbrtrem(n): r = iroot(n, 3) return (r, n - r * r * r) # an evaluator for a sequence of key presses on the calculator: # operators and functions implementing them ops = { '+': (lambda x, y: x + y), '-': (lambda x, y: x - y), '*': (lambda x, y: x * y), '/': fdiv, } # evaluate the sequence of keys in <s> def evaluate(s, r=0): # split the string on operators bits = re.split(r"([\+\-\*\/]+)", s) # evaluate the bits op = None while bits: b = bits.pop(0) if not b: continue fn = ops.get(b[-1]) if fn: op = fn else: # b is a number b = float(b) # apply any pending operation r = (op(r, b) if op else b) op = None return (r if not op else None) # check the given expressions assert evaluate("5+2*3") == 21 assert evaluate("5+*2") == 10 # target expression, and value tgt = "80*5+40-10" val = evaluate(tgt) # 4x4 layout of the keys (bottom to top) layout = ["0.-=", "123+", "456/", "789*"] # map keys to potential misses miss = defaultdict(set) for (i, j) in subsets(irange(4), size=2, select='M'): k = layout[i][j] if i > 0: miss[k].add(layout[i - 1][j]) if i < 3: miss[k].add(layout[i + 1][j]) if j > 0: miss[k].add(layout[i][j - 1]) if j < 3: miss[k].add(layout[i][j + 1]) # make 2 errors in the target expression for (i, j) in tuples(irange(len(tgt)), 2): for (x, y) in cproduct(miss[tgt[k]] for k in (i, j)): expr = update(tgt, [i, j], [x, y]) # '=' is not pressed until the end if '=' in expr: continue try: r = evaluate(expr) # compute required age to correct the sum age = snapf(fdiv(r, val)) except ValueError: continue if not (40 < age < 125): continue printf("{expr} -> {r}; age = {age}") # keys to correct expr extra = "/" + str(age) # additional mistakes are made in the extra keys for ks in subsets(irange(len(extra)), min_size=1): for vs in cproduct(miss[extra[k]] for k in ks): expr2 = expr + update(extra, ks, vs) try: r2 = evaluate(expr2) r2 = snapf(r2) except ValueError: continue # find the perfect cube, and calculate the ages (x, gm) = icbrtrem(r2) gf = age - 1 m = x - gf if not (0 < m < gm < 125): continue printf(" {expr2} -> {r2} -> gf = {gf}, gm = {gm}, m = {m}")Solution: Margaret is 53. Grandmother is 99. Grandfather is 96.
The correct result of the sum is:
The sequence initially entered by grandfather was:
The consecutive errors (underlined) being “0” → “1”, “−” → “3” (in both cases striking the key above the intended one).
The result of this calculation would be 41710, which when divided by 97 gives the original result of 430.
So grandfathers age at his next birthday is 97, hence his current age is 96.
Three additional mistakes are made in entering “÷ 97” giving the following sum:
The additional errors (also underlined) are “÷” → “6”, “9” → “×”, “7” → “8”.
The result of the completed sum (on pressing =) is 3308048.
And calculating the closest perfect cube below this gives:
Hence grandmother is 99, and Martha’s age is (149 − 96) = 53.
LikeLike