Teaser 3253: Romanesque Numerals
From The Sunday Times, 26th January 2025 [link] [link]
Equations in an archaic number system have been discovered:
BBC + BC = CBA
ABA#AB + ABAACA = ССВ
АСААС × ААС = ACAABABAOne letter (shown as #) is unclear, and could be either A or B. Letters basically represented different positive whole numbers; they might appear in any order in a string, but could contribute positively or negatively. The letter that was rightmost counted as a plus, but otherwise its basic value was compared with that of its right neighbour: if larger, it would count as plus; if smaller, as minus; if the same, then the same sign as that neighbour. (This works for interpreting Roman numerals too, e.g., VII = 5 + 1 + 1 = 7, and XLIX = −10 + 50 − 1 + 10 = 49).
What are the basic values of A, B & C, in that order?
[teaser3253]






Jim Randell 2:17 am on 26 January 2025 Permalink |
This Python program runs in 73ms. (Internal runtime is 4.9ms).
from enigma import (irange, inf, decompose, tuples, rev, printf) # evaluate string <s> for symbol assignments <d> def val(s, d): # process the values in reverse order vs = rev(d[x] for x in s) # start with the rightmost rs = vs[0:1] # and process the rest in pairs for (x, y) in tuples(vs, 2): if y > x: rs.append(y) elif y < x: rs.append(-y) else: rs.append(rs[-1]) return sum(rs) # evaluate strings <ss> for symbol assignments <d> def vals(ss, d): return list(val(s, d) for s in ss) # consider increasing totals for A + B + C for (A, B, C) in decompose(irange(6, inf), 3, increasing=0, sep=1, min_v=1): d = dict(A=A, B=B, C=C) # evaluate the given expressions: # [1] BBC + BC = CBA (a1, a2, a3) = vals(["BBC", "BC", "CBA"], d) if not (a1 + a2 == a3): continue # [2] (ABAAAB | ABABAB) + ABAACA = CCB" (b1a, b1b, b2, b3) = vals(["ABAAAB", "ABABAB", "ABAACA", "CCB"], d) if not (b1a + b2 == b3 or b1b + b2 == b3): continue # [3] ACAAC * AAC = ACAABABA (c1, c2, c3) = vals(["ACAAC", "AAC", "ACAABABA"], d) if not (c1 * c2 == c3): continue # output solution printf("A={A} B={B} C={C}") break # we only need the first solutionSolution: A=4; B=3; C=10.
We have:
Note that these are not necessarily the simplest way to write these numbers. For example in the first sum 4 is denoted by BBC, when it would be simpler to use A.
More compact forms of the sums are:
LikeLike
Jim Randell 1:29 pm on 3 February 2025 Permalink |
If we relax the condition on the values being positive integers, we can find further solutions using (non-zero) rational numbers.
For example:
gives:
Other rational values that work are:
LikeLike
Ruud 12:21 pm on 26 January 2025 Permalink |
import sys import itertools expressions = """\ BBC + BC == CBA ABAXAB + ABAACA == CCB ACAAC * AAC == ACAABABA """.splitlines() def calc(s): l = [-1] + [globals()[ch] for ch in reversed(s)] result = 0 for value, value_right in zip(l[1:], l): if value_right > value: sign = -1 if value_right < value: sign = 1 result += sign * value return str(result) def eval_expression(expression): return eval("".join(part if set(part) - set("ABCX") else calc(part) for part in expression.split())) for n in itertools.count(4): for A, B, C in itertools.permutations(range(20), 3): for X in (A, B, C): if all(eval_expression(expression) for expression in expressions): print(f"{A=} {B=} {C=}") sys.exit()LikeLike
Ruud 6:42 pm on 27 January 2025 Permalink |
I see now that # (X in my code) can only be A or B.
So the second for loop should read
for X in (A, B)
It doesn’t change the solution, by the way.
LikeLike
Frits 8:37 am on 3 February 2025 Permalink |
From the first expression we can deduce that B may not be greater than A and C.
From the last expression we can deduce that A and C are both even.
LikeLike