#!/usr/bin/env python3 """job 2775: cross-check sweep2775b.json against return #1804's sweep2785.json (both P=30). python3 xcheck2775b.py sweep2775b.json sweep2785.json Rows present in both (same R, p) must have equal A and B. stdout is the artifact. """ import json, sys a = json.load(open(sys.argv[1])) b = json.load(open(sys.argv[2])) mine = {(tuple(r["R"]), r["p"]): (r["A"], r["B"]) for r in a["rows"]} theirs = {(tuple(r["R"]), r["p"]): (r["A"], r["B"]) for r in b["rows"]} common = sorted(set(mine) & set(theirs)) bad = [{"R": list(k[0]), "p": k[1], "2775b": mine[k], "1804": theirs[k]} for k in common if mine[k] != theirs[k]] by_n = {} for k in common: by_n[len(k[0])] = by_n.get(len(k[0]), 0) + 1 print(json.dumps({"common_rows": len(common), "common_by_nR": by_n, "mismatches": bad}, sort_keys=True))