"""Recompute every simple binary step "a op b = c" written in a solution. Returns the list of wrong steps (empty if all check out). Times (10:20), ratios (3:4) and fractions written inside larger expressions are skipped rather than misread.""" import re NUM = r"\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?" STEP = re.compile(rf"(? 1e-6 and abs(round(v, 2) - c) < 0.006: continue # rounded quotient if c == int(a // b): continue # whole-number quotient (remainder stated separately) if abs(v - c) > 1e-6 * max(1, abs(v)) and abs(round(v, 2) - c) > 1e-9: bad.append(m.group(0)) return bad