"""Proof-reading fixes to the new Sections 8-9 of article/sim_numerics.md (exact, counted). python -u apply_article_fixes_8_9.py """ from __future__ import annotations PATH = "article/sim_numerics.md" REPL = [ ("### 8.4 Four more readings", "### 8.4 Five more readings", 1), ("the exit) and the four readings of §8.4", "the exit) and the five readings of §8.4", 1), ("On the wide-bracket families it is ahead on eight of nine; the ninth is `fun9`, 65 against 55.", "On the wide-bracket families it is ahead on seven of nine, level on `fun7` (the scoring " "artefact of §7.3) and behind on `fun9`, 65 against 55.", 1), ("Removing both would change A′ by a few tenths of a per cent;", "Removing both would change A′'s total by under one per cent (117 of 13032 evaluations);", 1), ("and ahead problem by problem on five of six.", "and ahead problem by problem on all six, significantly on five.", 1), ] def main(): with open(PATH, encoding="utf8") as fh: text = fh.read() bad = [(o, n, text.count(o)) for o, _new, n in REPL if text.count(o) != n] if bad: for o, n, got in bad: print(f"expected {n}, found {got}: {o[:80]}") raise SystemExit("aborted, nothing written") for o, new, _n in REPL: text = text.replace(o, new) with open(PATH, "w", encoding="utf8") as fh: fh.write(text) print("fixed") if __name__ == "__main__": main()