#!/usr/bin/env python3 """Pair up per-problem achieved-depth (final iterated depth reached before the node-count budget ran out) from two sn=N ECM stdout logs (same input file, same order) and report win/loss/tie counts plus median depth delta. """ import re import statistics import sys TELL_RE = re.compile(r"tellothers d(\d+),") def parse(path): """Return list of achieved-depth ints, one per completed problem, in order.""" depths = [] with open(path) as f: for line in f: m = TELL_RE.search(line) if m: depths.append(int(m.group(1))) return depths def main(): base_path, cand_path = sys.argv[1], sys.argv[2] base = parse(base_path) cand = parse(cand_path) n = min(len(base), len(cand)) base, cand = base[:n], cand[:n] deltas = [c - b for b, c in zip(base, cand)] wins = sum(1 for d in deltas if d > 0) losses = sum(1 for d in deltas if d < 0) ties = sum(1 for d in deltas if d == 0) print(f"Paired problems: {n}") print(f" candidate deeper: {wins}") print(f" candidate shallower: {losses}") print(f" tied depth: {ties}") print(f" median depth delta (candidate - baseline): {statistics.median(deltas):+.1f}") print(f" mean depth delta: {statistics.mean(deltas):+.3f}") print(f" sum of depth delta: {sum(deltas):+d}") if __name__ == "__main__": main()