#!/usr/bin/env python3 """Verify stroke/symbol counts across raw tallies, Egyptian bundling, Roman numerals, and base-10 digits.""" ROMAN_TABLE = [ (1000, "M"), (900, "CM"), (500, "D"), (400, "CD"), (100, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] def to_roman(n: int) -> str: rem, out = n, [] for val, sym in ROMAN_TABLE: while rem >= val: out.append(sym) rem -= val return "".join(out) def egyptian_marks(n: int) -> int: """In ancient Egyptian additive base-10 bundling, each digit d requires d drawings of that scale's glyph.""" return sum(int(ch) for ch in str(n)) def main() -> None: quantities = [7, 47, 388, 1999] print(f"{'quantity':>8} {'tally':>5} {'egyptian_marks':>14} {'roman_numeral (chars)':<21} {'modern_digits':>13}") for q in quantities: rom = to_roman(q) rom_col = f"{rom} ({len(rom)})" print(f"{q:8d} {q:5d} {egyptian_marks(q):14d} {rom_col:<21} {len(str(q)):13d}") # Also check worst Egyptian mark count under 1000 worst = max(range(1, 1000), key=egyptian_marks) print(f"\nworst_under_1000 = {worst} ({egyptian_marks(worst)} marks)") if __name__ == "__main__": main()