FAILURE MAP
← Case archive

FA-57881 / Double-entry ledger accounting / Open access

Trial balance columns: abnormal balance flag · case 01

Every liability and revenue account is flagged as abnormal.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Abnormal means any credit balance instead of a balance on the side opposite the normal side.

VERIFIED REPAIR

Flag an account when its column differs from its normal side.

Unsuccessful approach: Restricting to debit-normal accounts misses liabilities or revenue carrying a debit balance.

Case contract

x = [[account_code (digit string), type, total_debits, total_credits], ...]. Net = debits - credits. Zero-net accounts are omitted. A positive net goes in the debit column, a negative net (as a positive number) in the credit column. Rows are ordered by numeric account code. An account is abnormal when its column differs from its normal side (asset, expense, dividend debit-normal; others credit-normal). Return {'rows': [[code, debit, credit]], 'totals': [debits, credits], 'balanced': totals equal exactly, 'abnormal': codes in numeric order}.

Why this case matters

Ledger software must keep debits equal to credits and apply normal-balance, period and cutoff rules exactly; small sign or boundary slips silently misstate financial statements.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    debit_normal = ('asset', 'expense', 'dividend')
    rows = []
    td = tc = 0
    abnormal = []
    for acct, kind, dr, cr in x:
        net = dr - cr
        if net == 0:
            continue
        if net > 0:
            rows.append([acct, net, 0])
            td += net
        else:
            rows.append([acct, 0, -net])
            tc += -net
        if net < 0:
            abnormal.append(acct)
    rows.sort(key=lambda r: int(r[0]))
    return {'rows': rows, 'totals': [td, tc], 'balanced': td == tc, 'abnormal': sorted(abnormal, key=int)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: abnormal balance flag', [['4000', 'dividend', 250, 0], ['7200', 'dividend', 5000, 0], ['1500', 'equity', 0, 1]], {'rows': [['1500', 0, 1], ['4000', 250, 0], ['7200', 5000, 0]], 'totals': [5250, 1], 'balanced': False, 'abnormal': []}], ['regression: abnormal balance flag, partial-repair probe', [['99', 'expense', 0, -1], ['205', 'asset', 5000, 0], ['510', 'liability', 1234, 100]], {'rows': [['99', 1, 0], ['205', 5000, 0], ['510', 1134, 0]], 'totals': [6135, 0], 'balanced': False, 'abnormal': ['510']}], ['control 1', [['150', 'liability', 1234, 1234], ['101', 'asset', 0, -1], ['205', 'equity', 0, 0], ['7200', 'dividend', 900, 250]], {'rows': [['101', 1, 0], ['7200', 650, 0]], 'totals': [651, 0], 'balanced': False, 'abnormal': []}], ['control 2', [['2100', 'revenue', 0, 0], ['4000', 'revenue', 0, 0], ['99', 'equity', 5000, 5000], ['510', 'asset', 0, 0]], {'rows': [], 'totals': [0, 0], 'balanced': True, 'abnormal': []}], ['control 3', [['30', 'dividend', 1234, 1234], ['150', 'asset', 0, 250], ['4000', 'dividend', 1234, 0], ['101', 'dividend', 900, 0]], {'rows': [['101', 900, 0], ['150', 0, 250], ['4000', 1234, 0]], 'totals': [2134, 250], 'balanced': False, 'abnormal': ['150']}], ['control 4', [['510', 'asset', 250, 251], ['99', 'asset', 0, 5000], ['7200', 'equity', 900, 900], ['1500', 'asset', 0, 250], ['2100', 'asset', 900, 899]], {'rows': [['99', 0, 5000], ['510', 0, 1], ['1500', 0, 250], ['2100', 1, 0]], 'totals': [1, 5251], 'balanced': False, 'abnormal': ['99', '510', '1500']}], ['control 5', [['1010', 'dividend', 0, 100], ['205', 'liability', 5000, 5000], ['510', 'asset', 0, 0], ['1500', 'expense', 250, 1234]], {'rows': [['1010', 0, 100], ['1500', 0, 984]], 'totals': [0, 1084], 'balanced': False, 'abnormal': ['1010', '1500']}]], [['regression: abnormal balance flag', [['6', 'expense', 0, 0], ['30', 'asset', 250, 249], ['7200', 'expense', 5000, 5000], ['150', 'expense', 100, 100], ['2100', 'dividend', 900, 901], ['205', 'equity', 100, 101]], {'rows': [['30', 1, 0], ['205', 0, 1], ['2100', 0, 1]], 'totals': [1, 2], 'balanced': False, 'abnormal': ['2100']}], ['regression: abnormal balance flag, partial-repair probe', [['150', 'liability', 5000, 250], ['2100', 'dividend', 1234, 250], ['4000', 'asset', 250, 1234], ['99', 'equity', 900, 100], ['101', 'equity', 1234, 1233]], {'rows': [['99', 800, 0], ['101', 1, 0], ['150', 4750, 0], ['2100', 984, 0], ['4000', 0, 984]], 'totals': [6535, 984], 'balanced': False, 'abnormal': ['99', '101', '150', '4000']}], ['control 1', [['510', 'expense', 900, 5000], ['6', 'dividend', 0, 0], ['150', 'expense', 1234, 1234]], {'rows': [['510', 0, 4100]], 'totals': [0, 4100], 'balanced': False, 'abnormal': ['510']}], ['control 2', [['150', 'asset', 5000, 0], ['30', 'expense', 100, 100], ['1010', 'expense', 900, 900], ['99', 'dividend', 1234, 1233], ['4000', 'asset', 1234, 1235]], {'rows': [['99', 1, 0], ['150', 5000, 0], ['4000', 0, 1]], 'totals': [5001, 1], 'balanced': False, 'abnormal': ['4000']}], ['control 3', [['99', 'asset', 100, 250], ['4000', 'dividend', 100, 0], ['6', 'dividend', 1234, 0]], {'rows': [['6', 1234, 0], ['99', 0, 150], ['4000', 100, 0]], 'totals': [1334, 150], 'balanced': False, 'abnormal': ['99']}], ['control 4', [['7200', 'asset', 5000, 4999], ['205', 'asset', 1234, 5000], ['1500', 'dividend', 0, 0]], {'rows': [['205', 0, 3766], ['7200', 1, 0]], 'totals': [1, 3766], 'balanced': False, 'abnormal': ['205']}], ['control 5', [['1010', 'asset', 250, 0], ['510', 'expense', 5000, 1234], ['7200', 'dividend', 100, 100]], {'rows': [['510', 3766, 0], ['1010', 250, 0]], 'totals': [4016, 0], 'balanced': False, 'abnormal': []}]], [['regression: abnormal balance flag', [['2100', 'expense', 100, 5000], ['7200', 'liability', 5000, 100], ['6', 'dividend', 250, 1234], ['99', 'dividend', 0, 1234], ['205', 'expense', 5000, 5001], ['101', 'equity', 0, 1234], ['4000', 'revenue', 250, 5000]], {'rows': [['6', 0, 984], ['99', 0, 1234], ['101', 0, 1234], ['205', 0, 1], ['2100', 0, 4900], ['4000', 0, 4750], ['7200', 4900, 0]], 'totals': [4900, 13103], 'balanced': False, 'abnormal': ['6', '99', '205', '2100', '7200']}], ['control 1', [['7200', 'revenue', 250, 250], ['99', 'asset', 1234, 250], ['205', 'asset', 5000, 0]], {'rows': [['99', 984, 0], ['205', 5000, 0]], 'totals': [5984, 0], 'balanced': False, 'abnormal': []}], ['control 2', [['150', 'asset', 5000, 900], ['205', 'expense', 0, 1234], ['7200', 'asset', 0, 5000]], {'rows': [['150', 4100, 0], ['205', 0, 1234], ['7200', 0, 5000]], 'totals': [4100, 6234], 'balanced': False, 'abnormal': ['205', '7200']}], ['control 3', [['2100', 'dividend', 1234, 0], ['99', 'revenue', 5000, 5000], ['205', 'dividend', 5000, 5001]], {'rows': [['205', 0, 1], ['2100', 1234, 0]], 'totals': [1234, 1], 'balanced': False, 'abnormal': ['205']}], ['control 4', [['6', 'dividend', 0, 5000], ['1500', 'asset', 100, 100], ['30', 'expense', 900, 250], ['510', 'expense', 1234, 0], ['101', 'asset', 5000, 5001], ['4000', 'asset', 0, 5000]], {'rows': [['6', 0, 5000], ['30', 650, 0], ['101', 0, 1], ['510', 1234, 0], ['4000', 0, 5000]], 'totals': [1884, 10001], 'balanced': False, 'abnormal': ['6', '101', '4000']}], ['control 5', [['4000', 'equity', 250, 250], ['1010', 'expense', 1234, 1233], ['30', 'dividend', 100, 100], ['510', 'asset', 250, 0], ['7200', 'liability', 0, 0]], {'rows': [['510', 250, 0], ['1010', 1, 0]], 'totals': [251, 0], 'balanced': False, 'abnormal': []}], ['control 6', [['1500', 'expense', 5000, 100], ['205', 'dividend', 900, 5000], ['2100', 'revenue', 0, 0], ['1010', 'expense', 0, 900]], {'rows': [['205', 0, 4100], ['1010', 0, 900], ['1500', 4900, 0]], 'totals': [4900, 5000], 'balanced': False, 'abnormal': ['205', '1010']}]], [['regression: abnormal balance flag', [['99', 'liability', 1234, 1233], ['30', 'dividend', 5000, 900], ['150', 'liability', 1234, 1234], ['1010', 'liability', 250, 1234], ['510', 'liability', 100, 0], ['4000', 'expense', 100, 100]], {'rows': [['30', 4100, 0], ['99', 1, 0], ['510', 100, 0], ['1010', 0, 984]], 'totals': [4201, 984], 'balanced': False, 'abnormal': ['99', '510']}], ['control 1', [['30', 'asset', 5000, 0], ['510', 'expense', 100, 100], ['6', 'dividend', 100, 900]], {'rows': [['6', 0, 800], ['30', 5000, 0]], 'totals': [5000, 800], 'balanced': False, 'abnormal': ['6']}], ['control 2', [['99', 'expense', 900, 100], ['4000', 'dividend', 5000, 0], ['2100', 'expense', 250, 250], ['510', 'expense', 900, 5000], ['6', 'expense', 5000, 250], ['1500', 'liability', 0, 0]], {'rows': [['6', 4750, 0], ['99', 800, 0], ['510', 0, 4100], ['4000', 5000, 0]], 'totals': [10550, 4100], 'balanced': False, 'abnormal': ['510']}], ['control 3', [['6', 'asset', 5000, 900], ['30', 'asset', 100, 0], ['1500', 'liability', 100, 100]], {'rows': [['6', 4100, 0], ['30', 100, 0]], 'totals': [4200, 0], 'balanced': False, 'abnormal': []}], ['control 4', [['2100', 'expense', 0, 100], ['1010', 'expense', 100, 99], ['101', 'expense', 900, 5000], ['7200', 'dividend', 1234, 900], ['205', 'liability', 0, 0], ['4000', 'revenue', 900, 900]], {'rows': [['101', 0, 4100], ['1010', 1, 0], ['2100', 0, 100], ['7200', 334, 0]], 'totals': [335, 4200], 'balanced': False, 'abnormal': ['101', '2100']}], ['control 5', [['150', 'dividend', 100, 0], ['6', 'dividend', 900, 0], ['1500', 'revenue', 1234, 1234], ['30', 'equity', 100, 100]], {'rows': [['6', 900, 0], ['150', 100, 0]], 'totals': [1000, 0], 'balanced': False, 'abnormal': []}], ['control 6', [['101', 'dividend', 5000, 4999], ['99', 'asset', 100, 100], ['30', 'expense', 250, 249]], {'rows': [['30', 1, 0], ['101', 1, 0]], 'totals': [2, 0], 'balanced': False, 'abnormal': []}]], [['regression: abnormal balance flag', [['4000', 'revenue', 0, 1], ['30', 'expense', 250, 250], ['2100', 'asset', 900, 100]], {'rows': [['2100', 800, 0], ['4000', 0, 1]], 'totals': [800, 1], 'balanced': False, 'abnormal': []}], ['regression: abnormal balance flag, partial-repair probe', [['99', 'liability', 5000, 0], ['30', 'liability', 0, 0], ['4000', 'expense', 0, 900], ['205', 'revenue', 900, 5000], ['1010', 'liability', 0, 250]], {'rows': [['99', 5000, 0], ['205', 0, 4100], ['1010', 0, 250], ['4000', 0, 900]], 'totals': [5000, 5250], 'balanced': False, 'abnormal': ['99', '4000']}], ['control 1', [['510', 'asset', 0, 1234], ['1500', 'asset', 1234, 1233], ['99', 'expense', 0, 1], ['101', 'asset', 900, 900], ['30', 'expense', 1234, 1234]], {'rows': [['99', 0, 1], ['510', 0, 1234], ['1500', 1, 0]], 'totals': [1, 1235], 'balanced': False, 'abnormal': ['99', '510']}], ['control 2', [['30', 'asset', 100, 0], ['205', 'dividend', 250, 249], ['6', 'asset', 250, 900], ['150', 'expense', 0, 1234]], {'rows': [['6', 0, 650], ['30', 100, 0], ['150', 0, 1234], ['205', 1, 0]], 'totals': [101, 1884], 'balanced': False, 'abnormal': ['6', '150']}], ['control 3', [['7200', 'expense', 250, 251], ['150', 'expense', 5000, 1234], ['30', 'asset', 100, 99]], {'rows': [['30', 1, 0], ['150', 3766, 0], ['7200', 0, 1]], 'totals': [3767, 1], 'balanced': False, 'abnormal': ['7200']}], ['control 4', [['1500', 'asset', 0, 5000], ['1010', 'equity', 5000, 5000], ['99', 'asset', 250, 249]], {'rows': [['99', 1, 0], ['1500', 0, 5000]], 'totals': [1, 5000], 'balanced': False, 'abnormal': ['1500']}], ['control 5', [['150', 'expense', 100, 0], ['101', 'liability', 250, 250], ['99', 'liability', 100, 100], ['205', 'equity', 100, 100], ['510', 'expense', 100, 0], ['7200', 'asset', 5000, 5000]], {'rows': [['150', 100, 0], ['510', 100, 0]], 'totals': [200, 0], 'balanced': False, 'abnormal': []}]]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'raised ' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: abnormal balance flag{'abnormal': ['1500'], 'balanced': False, 'rows': [['1500', 0, 1], ['4000', 250, 0], ['7200', 5000, 0]], 'totals': [5250, 1]}{'abnormal': [], 'balanced': False, 'rows': [['1500', 0, 1], ['4000', 250, 0], ['7200', 5000, 0]], 'totals': [5250, 1]}Failed
regression: abnormal balance flag, partial-repair probe{'abnormal': [], 'balanced': False, 'rows': [['99', 1, 0], ['205', 5000, 0], ['510', 1134, 0]], 'totals': [6135, 0]}{'abnormal': ['510'], 'balanced': False, 'rows': [['99', 1, 0], ['205', 5000, 0], ['510', 1134, 0]], 'totals': [6135, 0]}Failed
control 1{'abnormal': [], 'balanced': False, 'rows': [['101', 1, 0], ['7200', 650, 0]], 'totals': [651, 0]}{'abnormal': [], 'balanced': False, 'rows': [['101', 1, 0], ['7200', 650, 0]], 'totals': [651, 0]}Passed
control 2{'abnormal': [], 'balanced': True, 'rows': [], 'totals': [0, 0]}{'abnormal': [], 'balanced': True, 'rows': [], 'totals': [0, 0]}Passed
control 3{'abnormal': ['150'], 'balanced': False, 'rows': [['101', 900, 0], ['150', 0, 250], ['4000', 1234, 0]], 'totals': [2134, 250]}{'abnormal': ['150'], 'balanced': False, 'rows': [['101', 900, 0], ['150', 0, 250], ['4000', 1234, 0]], 'totals': [2134, 250]}Passed
control 4{'abnormal': ['99', '510', '1500'], 'balanced': False, 'rows': [['99', 0, 5000], ['510', 0, 1], ['1500', 0, 250], ['2100', 1, 0]], 'totals': [1, 5251]}{'abnormal': ['99', '510', '1500'], 'balanced': False, 'rows': [['99', 0, 5000], ['510', 0, 1], ['1500', 0, 250], ['2100', 1, 0]], 'totals': [1, 5251]}Passed
control 5{'abnormal': ['1010', '1500'], 'balanced': False, 'rows': [['1010', 0, 100], ['1500', 0, 984]], 'totals': [0, 1084]}{'abnormal': ['1010', '1500'], 'balanced': False, 'rows': [['1010', 0, 100], ['1500', 0, 984]], 'totals': [0, 1084]}Passed

SHA-256 / 3db3903f2c4ed3aec8e78174a9395c028e9a44a3da50fa25025181a6424206ce

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    debit_normal = ('asset', 'expense', 'dividend')
    rows = []
    td = tc = 0
    abnormal = []
    for acct, kind, dr, cr in x:
        net = dr - cr
        if net == 0:
            continue
        if net > 0:
            rows.append([acct, net, 0])
            td += net
        else:
            rows.append([acct, 0, -net])
            tc += -net
        if net < 0 and kind in debit_normal:
            abnormal.append(acct)
    rows.sort(key=lambda r: int(r[0]))
    return {'rows': rows, 'totals': [td, tc], 'balanced': td == tc, 'abnormal': sorted(abnormal, key=int)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: abnormal balance flag', [['4000', 'dividend', 250, 0], ['7200', 'dividend', 5000, 0], ['1500', 'equity', 0, 1]], {'rows': [['1500', 0, 1], ['4000', 250, 0], ['7200', 5000, 0]], 'totals': [5250, 1], 'balanced': False, 'abnormal': []}], ['regression: abnormal balance flag, partial-repair probe', [['99', 'expense', 0, -1], ['205', 'asset', 5000, 0], ['510', 'liability', 1234, 100]], {'rows': [['99', 1, 0], ['205', 5000, 0], ['510', 1134, 0]], 'totals': [6135, 0], 'balanced': False, 'abnormal': ['510']}], ['control 1', [['150', 'liability', 1234, 1234], ['101', 'asset', 0, -1], ['205', 'equity', 0, 0], ['7200', 'dividend', 900, 250]], {'rows': [['101', 1, 0], ['7200', 650, 0]], 'totals': [651, 0], 'balanced': False, 'abnormal': []}], ['control 2', [['2100', 'revenue', 0, 0], ['4000', 'revenue', 0, 0], ['99', 'equity', 5000, 5000], ['510', 'asset', 0, 0]], {'rows': [], 'totals': [0, 0], 'balanced': True, 'abnormal': []}], ['control 3', [['30', 'dividend', 1234, 1234], ['150', 'asset', 0, 250], ['4000', 'dividend', 1234, 0], ['101', 'dividend', 900, 0]], {'rows': [['101', 900, 0], ['150', 0, 250], ['4000', 1234, 0]], 'totals': [2134, 250], 'balanced': False, 'abnormal': ['150']}], ['control 4', [['510', 'asset', 250, 251], ['99', 'asset', 0, 5000], ['7200', 'equity', 900, 900], ['1500', 'asset', 0, 250], ['2100', 'asset', 900, 899]], {'rows': [['99', 0, 5000], ['510', 0, 1], ['1500', 0, 250], ['2100', 1, 0]], 'totals': [1, 5251], 'balanced': False, 'abnormal': ['99', '510', '1500']}], ['control 5', [['1010', 'dividend', 0, 100], ['205', 'liability', 5000, 5000], ['510', 'asset', 0, 0], ['1500', 'expense', 250, 1234]], {'rows': [['1010', 0, 100], ['1500', 0, 984]], 'totals': [0, 1084], 'balanced': False, 'abnormal': ['1010', '1500']}]], [['regression: abnormal balance flag', [['6', 'expense', 0, 0], ['30', 'asset', 250, 249], ['7200', 'expense', 5000, 5000], ['150', 'expense', 100, 100], ['2100', 'dividend', 900, 901], ['205', 'equity', 100, 101]], {'rows': [['30', 1, 0], ['205', 0, 1], ['2100', 0, 1]], 'totals': [1, 2], 'balanced': False, 'abnormal': ['2100']}], ['regression: abnormal balance flag, partial-repair probe', [['150', 'liability', 5000, 250], ['2100', 'dividend', 1234, 250], ['4000', 'asset', 250, 1234], ['99', 'equity', 900, 100], ['101', 'equity', 1234, 1233]], {'rows': [['99', 800, 0], ['101', 1, 0], ['150', 4750, 0], ['2100', 984, 0], ['4000', 0, 984]], 'totals': [6535, 984], 'balanced': False, 'abnormal': ['99', '101', '150', '4000']}], ['control 1', [['510', 'expense', 900, 5000], ['6', 'dividend', 0, 0], ['150', 'expense', 1234, 1234]], {'rows': [['510', 0, 4100]], 'totals': [0, 4100], 'balanced': False, 'abnormal': ['510']}], ['control 2', [['150', 'asset', 5000, 0], ['30', 'expense', 100, 100], ['1010', 'expense', 900, 900], ['99', 'dividend', 1234, 1233], ['4000', 'asset', 1234, 1235]], {'rows': [['99', 1, 0], ['150', 5000, 0], ['4000', 0, 1]], 'totals': [5001, 1], 'balanced': False, 'abnormal': ['4000']}], ['control 3', [['99', 'asset', 100, 250], ['4000', 'dividend', 100, 0], ['6', 'dividend', 1234, 0]], {'rows': [['6', 1234, 0], ['99', 0, 150], ['4000', 100, 0]], 'totals': [1334, 150], 'balanced': False, 'abnormal': ['99']}], ['control 4', [['7200', 'asset', 5000, 4999], ['205', 'asset', 1234, 5000], ['1500', 'dividend', 0, 0]], {'rows': [['205', 0, 3766], ['7200', 1, 0]], 'totals': [1, 3766], 'balanced': False, 'abnormal': ['205']}], ['control 5', [['1010', 'asset', 250, 0], ['510', 'expense', 5000, 1234], ['7200', 'dividend', 100, 100]], {'rows': [['510', 3766, 0], ['1010', 250, 0]], 'totals': [4016, 0], 'balanced': False, 'abnormal': []}]], [['regression: abnormal balance flag', [['2100', 'expense', 100, 5000], ['7200', 'liability', 5000, 100], ['6', 'dividend', 250, 1234], ['99', 'dividend', 0, 1234], ['205', 'expense', 5000, 5001], ['101', 'equity', 0, 1234], ['4000', 'revenue', 250, 5000]], {'rows': [['6', 0, 984], ['99', 0, 1234], ['101', 0, 1234], ['205', 0, 1], ['2100', 0, 4900], ['4000', 0, 4750], ['7200', 4900, 0]], 'totals': [4900, 13103], 'balanced': False, 'abnormal': ['6', '99', '205', '2100', '7200']}], ['control 1', [['7200', 'revenue', 250, 250], ['99', 'asset', 1234, 250], ['205', 'asset', 5000, 0]], {'rows': [['99', 984, 0], ['205', 5000, 0]], 'totals': [5984, 0], 'balanced': False, 'abnormal': []}], ['control 2', [['150', 'asset', 5000, 900], ['205', 'expense', 0, 1234], ['7200', 'asset', 0, 5000]], {'rows': [['150', 4100, 0], ['205', 0, 1234], ['7200', 0, 5000]], 'totals': [4100, 6234], 'balanced': False, 'abnormal': ['205', '7200']}], ['control 3', [['2100', 'dividend', 1234, 0], ['99', 'revenue', 5000, 5000], ['205', 'dividend', 5000, 5001]], {'rows': [['205', 0, 1], ['2100', 1234, 0]], 'totals': [1234, 1], 'balanced': False, 'abnormal': ['205']}], ['control 4', [['6', 'dividend', 0, 5000], ['1500', 'asset', 100, 100], ['30', 'expense', 900, 250], ['510', 'expense', 1234, 0], ['101', 'asset', 5000, 5001], ['4000', 'asset', 0, 5000]], {'rows': [['6', 0, 5000], ['30', 650, 0], ['101', 0, 1], ['510', 1234, 0], ['4000', 0, 5000]], 'totals': [1884, 10001], 'balanced': False, 'abnormal': ['6', '101', '4000']}], ['control 5', [['4000', 'equity', 250, 250], ['1010', 'expense', 1234, 1233], ['30', 'dividend', 100, 100], ['510', 'asset', 250, 0], ['7200', 'liability', 0, 0]], {'rows': [['510', 250, 0], ['1010', 1, 0]], 'totals': [251, 0], 'balanced': False, 'abnormal': []}], ['control 6', [['1500', 'expense', 5000, 100], ['205', 'dividend', 900, 5000], ['2100', 'revenue', 0, 0], ['1010', 'expense', 0, 900]], {'rows': [['205', 0, 4100], ['1010', 0, 900], ['1500', 4900, 0]], 'totals': [4900, 5000], 'balanced': False, 'abnormal': ['205', '1010']}]], [['regression: abnormal balance flag', [['99', 'liability', 1234, 1233], ['30', 'dividend', 5000, 900], ['150', 'liability', 1234, 1234], ['1010', 'liability', 250, 1234], ['510', 'liability', 100, 0], ['4000', 'expense', 100, 100]], {'rows': [['30', 4100, 0], ['99', 1, 0], ['510', 100, 0], ['1010', 0, 984]], 'totals': [4201, 984], 'balanced': False, 'abnormal': ['99', '510']}], ['control 1', [['30', 'asset', 5000, 0], ['510', 'expense', 100, 100], ['6', 'dividend', 100, 900]], {'rows': [['6', 0, 800], ['30', 5000, 0]], 'totals': [5000, 800], 'balanced': False, 'abnormal': ['6']}], ['control 2', [['99', 'expense', 900, 100], ['4000', 'dividend', 5000, 0], ['2100', 'expense', 250, 250], ['510', 'expense', 900, 5000], ['6', 'expense', 5000, 250], ['1500', 'liability', 0, 0]], {'rows': [['6', 4750, 0], ['99', 800, 0], ['510', 0, 4100], ['4000', 5000, 0]], 'totals': [10550, 4100], 'balanced': False, 'abnormal': ['510']}], ['control 3', [['6', 'asset', 5000, 900], ['30', 'asset', 100, 0], ['1500', 'liability', 100, 100]], {'rows': [['6', 4100, 0], ['30', 100, 0]], 'totals': [4200, 0], 'balanced': False, 'abnormal': []}], ['control 4', [['2100', 'expense', 0, 100], ['1010', 'expense', 100, 99], ['101', 'expense', 900, 5000], ['7200', 'dividend', 1234, 900], ['205', 'liability', 0, 0], ['4000', 'revenue', 900, 900]], {'rows': [['101', 0, 4100], ['1010', 1, 0], ['2100', 0, 100], ['7200', 334, 0]], 'totals': [335, 4200], 'balanced': False, 'abnormal': ['101', '2100']}], ['control 5', [['150', 'dividend', 100, 0], ['6', 'dividend', 900, 0], ['1500', 'revenue', 1234, 1234], ['30', 'equity', 100, 100]], {'rows': [['6', 900, 0], ['150', 100, 0]], 'totals': [1000, 0], 'balanced': False, 'abnormal': []}], ['control 6', [['101', 'dividend', 5000, 4999], ['99', 'asset', 100, 100], ['30', 'expense', 250, 249]], {'rows': [['30', 1, 0], ['101', 1, 0]], 'totals': [2, 0], 'balanced': False, 'abnormal': []}]], [['regression: abnormal balance flag', [['4000', 'revenue', 0, 1], ['30', 'expense', 250, 250], ['2100', 'asset', 900, 100]], {'rows': [['2100', 800, 0], ['4000', 0, 1]], 'totals': [800, 1], 'balanced': False, 'abnormal': []}], ['regression: abnormal balance flag, partial-repair probe', [['99', 'liability', 5000, 0], ['30', 'liability', 0, 0], ['4000', 'expense', 0, 900], ['205', 'revenue', 900, 5000], ['1010', 'liability', 0, 250]], {'rows': [['99', 5000, 0], ['205', 0, 4100], ['1010', 0, 250], ['4000', 0, 900]], 'totals': [5000, 5250], 'balanced': False, 'abnormal': ['99', '4000']}], ['control 1', [['510', 'asset', 0, 1234], ['1500', 'asset', 1234, 1233], ['99', 'expense', 0, 1], ['101', 'asset', 900, 900], ['30', 'expense', 1234, 1234]], {'rows': [['99', 0, 1], ['510', 0, 1234], ['1500', 1, 0]], 'totals': [1, 1235], 'balanced': False, 'abnormal': ['99', '510']}], ['control 2', [['30', 'asset', 100, 0], ['205', 'dividend', 250, 249], ['6', 'asset', 250, 900], ['150', 'expense', 0, 1234]], {'rows': [['6', 0, 650], ['30', 100, 0], ['150', 0, 1234], ['205', 1, 0]], 'totals': [101, 1884], 'balanced': False, 'abnormal': ['6', '150']}], ['control 3', [['7200', 'expense', 250, 251], ['150', 'expense', 5000, 1234], ['30', 'asset', 100, 99]], {'rows': [['30', 1, 0], ['150', 3766, 0], ['7200', 0, 1]], 'totals': [3767, 1], 'balanced': False, 'abnormal': ['7200']}], ['control 4', [['1500', 'asset', 0, 5000], ['1010', 'equity', 5000, 5000], ['99', 'asset', 250, 249]], {'rows': [['99', 1, 0], ['1500', 0, 5000]], 'totals': [1, 5000], 'balanced': False, 'abnormal': ['1500']}], ['control 5', [['150', 'expense', 100, 0], ['101', 'liability', 250, 250], ['99', 'liability', 100, 100], ['205', 'equity', 100, 100], ['510', 'expense', 100, 0], ['7200', 'asset', 5000, 5000]], {'rows': [['150', 100, 0], ['510', 100, 0]], 'totals': [200, 0], 'balanced': False, 'abnormal': []}]]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'raised ' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: abnormal balance flag{'abnormal': [], 'balanced': False, 'rows': [['1500', 0, 1], ['4000', 250, 0], ['7200', 5000, 0]], 'totals': [5250, 1]}{'abnormal': [], 'balanced': False, 'rows': [['1500', 0, 1], ['4000', 250, 0], ['7200', 5000, 0]], 'totals': [5250, 1]}Passed
regression: abnormal balance flag, partial-repair probe{'abnormal': [], 'balanced': False, 'rows': [['99', 1, 0], ['205', 5000, 0], ['510', 1134, 0]], 'totals': [6135, 0]}{'abnormal': ['510'], 'balanced': False, 'rows': [['99', 1, 0], ['205', 5000, 0], ['510', 1134, 0]], 'totals': [6135, 0]}Failed
control 1{'abnormal': [], 'balanced': False, 'rows': [['101', 1, 0], ['7200', 650, 0]], 'totals': [651, 0]}{'abnormal': [], 'balanced': False, 'rows': [['101', 1, 0], ['7200', 650, 0]], 'totals': [651, 0]}Passed
control 2{'abnormal': [], 'balanced': True, 'rows': [], 'totals': [0, 0]}{'abnormal': [], 'balanced': True, 'rows': [], 'totals': [0, 0]}Passed
control 3{'abnormal': ['150'], 'balanced': False, 'rows': [['101', 900, 0], ['150', 0, 250], ['4000', 1234, 0]], 'totals': [2134, 250]}{'abnormal': ['150'], 'balanced': False, 'rows': [['101', 900, 0], ['150', 0, 250], ['4000', 1234, 0]], 'totals': [2134, 250]}Passed
control 4{'abnormal': ['99', '510', '1500'], 'balanced': False, 'rows': [['99', 0, 5000], ['510', 0, 1], ['1500', 0, 250], ['2100', 1, 0]], 'totals': [1, 5251]}{'abnormal': ['99', '510', '1500'], 'balanced': False, 'rows': [['99', 0, 5000], ['510', 0, 1], ['1500', 0, 250], ['2100', 1, 0]], 'totals': [1, 5251]}Passed
control 5{'abnormal': ['1010', '1500'], 'balanced': False, 'rows': [['1010', 0, 100], ['1500', 0, 984]], 'totals': [0, 1084]}{'abnormal': ['1010', '1500'], 'balanced': False, 'rows': [['1010', 0, 100], ['1500', 0, 984]], 'totals': [0, 1084]}Passed

SHA-256 / 370c22a2c6f0ec688defc4cd10aec8c645f5908f04f3880a107ed37399f826bf

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    debit_normal = ('asset', 'expense', 'dividend')
    rows = []
    td = tc = 0
    abnormal = []
    for acct, kind, dr, cr in x:
        net = dr - cr
        if net == 0:
            continue
        if net > 0:
            rows.append([acct, net, 0])
            td += net
        else:
            rows.append([acct, 0, -net])
            tc += -net
        if (net > 0) != (kind in debit_normal):
            abnormal.append(acct)
    rows.sort(key=lambda r: int(r[0]))
    return {'rows': rows, 'totals': [td, tc], 'balanced': td == tc, 'abnormal': sorted(abnormal, key=int)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: abnormal balance flag', [['4000', 'dividend', 250, 0], ['7200', 'dividend', 5000, 0], ['1500', 'equity', 0, 1]], {'rows': [['1500', 0, 1], ['4000', 250, 0], ['7200', 5000, 0]], 'totals': [5250, 1], 'balanced': False, 'abnormal': []}], ['regression: abnormal balance flag, partial-repair probe', [['99', 'expense', 0, -1], ['205', 'asset', 5000, 0], ['510', 'liability', 1234, 100]], {'rows': [['99', 1, 0], ['205', 5000, 0], ['510', 1134, 0]], 'totals': [6135, 0], 'balanced': False, 'abnormal': ['510']}], ['control 1', [['150', 'liability', 1234, 1234], ['101', 'asset', 0, -1], ['205', 'equity', 0, 0], ['7200', 'dividend', 900, 250]], {'rows': [['101', 1, 0], ['7200', 650, 0]], 'totals': [651, 0], 'balanced': False, 'abnormal': []}], ['control 2', [['2100', 'revenue', 0, 0], ['4000', 'revenue', 0, 0], ['99', 'equity', 5000, 5000], ['510', 'asset', 0, 0]], {'rows': [], 'totals': [0, 0], 'balanced': True, 'abnormal': []}], ['control 3', [['30', 'dividend', 1234, 1234], ['150', 'asset', 0, 250], ['4000', 'dividend', 1234, 0], ['101', 'dividend', 900, 0]], {'rows': [['101', 900, 0], ['150', 0, 250], ['4000', 1234, 0]], 'totals': [2134, 250], 'balanced': False, 'abnormal': ['150']}], ['control 4', [['510', 'asset', 250, 251], ['99', 'asset', 0, 5000], ['7200', 'equity', 900, 900], ['1500', 'asset', 0, 250], ['2100', 'asset', 900, 899]], {'rows': [['99', 0, 5000], ['510', 0, 1], ['1500', 0, 250], ['2100', 1, 0]], 'totals': [1, 5251], 'balanced': False, 'abnormal': ['99', '510', '1500']}], ['control 5', [['1010', 'dividend', 0, 100], ['205', 'liability', 5000, 5000], ['510', 'asset', 0, 0], ['1500', 'expense', 250, 1234]], {'rows': [['1010', 0, 100], ['1500', 0, 984]], 'totals': [0, 1084], 'balanced': False, 'abnormal': ['1010', '1500']}]], [['regression: abnormal balance flag', [['6', 'expense', 0, 0], ['30', 'asset', 250, 249], ['7200', 'expense', 5000, 5000], ['150', 'expense', 100, 100], ['2100', 'dividend', 900, 901], ['205', 'equity', 100, 101]], {'rows': [['30', 1, 0], ['205', 0, 1], ['2100', 0, 1]], 'totals': [1, 2], 'balanced': False, 'abnormal': ['2100']}], ['regression: abnormal balance flag, partial-repair probe', [['150', 'liability', 5000, 250], ['2100', 'dividend', 1234, 250], ['4000', 'asset', 250, 1234], ['99', 'equity', 900, 100], ['101', 'equity', 1234, 1233]], {'rows': [['99', 800, 0], ['101', 1, 0], ['150', 4750, 0], ['2100', 984, 0], ['4000', 0, 984]], 'totals': [6535, 984], 'balanced': False, 'abnormal': ['99', '101', '150', '4000']}], ['control 1', [['510', 'expense', 900, 5000], ['6', 'dividend', 0, 0], ['150', 'expense', 1234, 1234]], {'rows': [['510', 0, 4100]], 'totals': [0, 4100], 'balanced': False, 'abnormal': ['510']}], ['control 2', [['150', 'asset', 5000, 0], ['30', 'expense', 100, 100], ['1010', 'expense', 900, 900], ['99', 'dividend', 1234, 1233], ['4000', 'asset', 1234, 1235]], {'rows': [['99', 1, 0], ['150', 5000, 0], ['4000', 0, 1]], 'totals': [5001, 1], 'balanced': False, 'abnormal': ['4000']}], ['control 3', [['99', 'asset', 100, 250], ['4000', 'dividend', 100, 0], ['6', 'dividend', 1234, 0]], {'rows': [['6', 1234, 0], ['99', 0, 150], ['4000', 100, 0]], 'totals': [1334, 150], 'balanced': False, 'abnormal': ['99']}], ['control 4', [['7200', 'asset', 5000, 4999], ['205', 'asset', 1234, 5000], ['1500', 'dividend', 0, 0]], {'rows': [['205', 0, 3766], ['7200', 1, 0]], 'totals': [1, 3766], 'balanced': False, 'abnormal': ['205']}], ['control 5', [['1010', 'asset', 250, 0], ['510', 'expense', 5000, 1234], ['7200', 'dividend', 100, 100]], {'rows': [['510', 3766, 0], ['1010', 250, 0]], 'totals': [4016, 0], 'balanced': False, 'abnormal': []}]], [['regression: abnormal balance flag', [['2100', 'expense', 100, 5000], ['7200', 'liability', 5000, 100], ['6', 'dividend', 250, 1234], ['99', 'dividend', 0, 1234], ['205', 'expense', 5000, 5001], ['101', 'equity', 0, 1234], ['4000', 'revenue', 250, 5000]], {'rows': [['6', 0, 984], ['99', 0, 1234], ['101', 0, 1234], ['205', 0, 1], ['2100', 0, 4900], ['4000', 0, 4750], ['7200', 4900, 0]], 'totals': [4900, 13103], 'balanced': False, 'abnormal': ['6', '99', '205', '2100', '7200']}], ['control 1', [['7200', 'revenue', 250, 250], ['99', 'asset', 1234, 250], ['205', 'asset', 5000, 0]], {'rows': [['99', 984, 0], ['205', 5000, 0]], 'totals': [5984, 0], 'balanced': False, 'abnormal': []}], ['control 2', [['150', 'asset', 5000, 900], ['205', 'expense', 0, 1234], ['7200', 'asset', 0, 5000]], {'rows': [['150', 4100, 0], ['205', 0, 1234], ['7200', 0, 5000]], 'totals': [4100, 6234], 'balanced': False, 'abnormal': ['205', '7200']}], ['control 3', [['2100', 'dividend', 1234, 0], ['99', 'revenue', 5000, 5000], ['205', 'dividend', 5000, 5001]], {'rows': [['205', 0, 1], ['2100', 1234, 0]], 'totals': [1234, 1], 'balanced': False, 'abnormal': ['205']}], ['control 4', [['6', 'dividend', 0, 5000], ['1500', 'asset', 100, 100], ['30', 'expense', 900, 250], ['510', 'expense', 1234, 0], ['101', 'asset', 5000, 5001], ['4000', 'asset', 0, 5000]], {'rows': [['6', 0, 5000], ['30', 650, 0], ['101', 0, 1], ['510', 1234, 0], ['4000', 0, 5000]], 'totals': [1884, 10001], 'balanced': False, 'abnormal': ['6', '101', '4000']}], ['control 5', [['4000', 'equity', 250, 250], ['1010', 'expense', 1234, 1233], ['30', 'dividend', 100, 100], ['510', 'asset', 250, 0], ['7200', 'liability', 0, 0]], {'rows': [['510', 250, 0], ['1010', 1, 0]], 'totals': [251, 0], 'balanced': False, 'abnormal': []}], ['control 6', [['1500', 'expense', 5000, 100], ['205', 'dividend', 900, 5000], ['2100', 'revenue', 0, 0], ['1010', 'expense', 0, 900]], {'rows': [['205', 0, 4100], ['1010', 0, 900], ['1500', 4900, 0]], 'totals': [4900, 5000], 'balanced': False, 'abnormal': ['205', '1010']}]], [['regression: abnormal balance flag', [['99', 'liability', 1234, 1233], ['30', 'dividend', 5000, 900], ['150', 'liability', 1234, 1234], ['1010', 'liability', 250, 1234], ['510', 'liability', 100, 0], ['4000', 'expense', 100, 100]], {'rows': [['30', 4100, 0], ['99', 1, 0], ['510', 100, 0], ['1010', 0, 984]], 'totals': [4201, 984], 'balanced': False, 'abnormal': ['99', '510']}], ['control 1', [['30', 'asset', 5000, 0], ['510', 'expense', 100, 100], ['6', 'dividend', 100, 900]], {'rows': [['6', 0, 800], ['30', 5000, 0]], 'totals': [5000, 800], 'balanced': False, 'abnormal': ['6']}], ['control 2', [['99', 'expense', 900, 100], ['4000', 'dividend', 5000, 0], ['2100', 'expense', 250, 250], ['510', 'expense', 900, 5000], ['6', 'expense', 5000, 250], ['1500', 'liability', 0, 0]], {'rows': [['6', 4750, 0], ['99', 800, 0], ['510', 0, 4100], ['4000', 5000, 0]], 'totals': [10550, 4100], 'balanced': False, 'abnormal': ['510']}], ['control 3', [['6', 'asset', 5000, 900], ['30', 'asset', 100, 0], ['1500', 'liability', 100, 100]], {'rows': [['6', 4100, 0], ['30', 100, 0]], 'totals': [4200, 0], 'balanced': False, 'abnormal': []}], ['control 4', [['2100', 'expense', 0, 100], ['1010', 'expense', 100, 99], ['101', 'expense', 900, 5000], ['7200', 'dividend', 1234, 900], ['205', 'liability', 0, 0], ['4000', 'revenue', 900, 900]], {'rows': [['101', 0, 4100], ['1010', 1, 0], ['2100', 0, 100], ['7200', 334, 0]], 'totals': [335, 4200], 'balanced': False, 'abnormal': ['101', '2100']}], ['control 5', [['150', 'dividend', 100, 0], ['6', 'dividend', 900, 0], ['1500', 'revenue', 1234, 1234], ['30', 'equity', 100, 100]], {'rows': [['6', 900, 0], ['150', 100, 0]], 'totals': [1000, 0], 'balanced': False, 'abnormal': []}], ['control 6', [['101', 'dividend', 5000, 4999], ['99', 'asset', 100, 100], ['30', 'expense', 250, 249]], {'rows': [['30', 1, 0], ['101', 1, 0]], 'totals': [2, 0], 'balanced': False, 'abnormal': []}]], [['regression: abnormal balance flag', [['4000', 'revenue', 0, 1], ['30', 'expense', 250, 250], ['2100', 'asset', 900, 100]], {'rows': [['2100', 800, 0], ['4000', 0, 1]], 'totals': [800, 1], 'balanced': False, 'abnormal': []}], ['regression: abnormal balance flag, partial-repair probe', [['99', 'liability', 5000, 0], ['30', 'liability', 0, 0], ['4000', 'expense', 0, 900], ['205', 'revenue', 900, 5000], ['1010', 'liability', 0, 250]], {'rows': [['99', 5000, 0], ['205', 0, 4100], ['1010', 0, 250], ['4000', 0, 900]], 'totals': [5000, 5250], 'balanced': False, 'abnormal': ['99', '4000']}], ['control 1', [['510', 'asset', 0, 1234], ['1500', 'asset', 1234, 1233], ['99', 'expense', 0, 1], ['101', 'asset', 900, 900], ['30', 'expense', 1234, 1234]], {'rows': [['99', 0, 1], ['510', 0, 1234], ['1500', 1, 0]], 'totals': [1, 1235], 'balanced': False, 'abnormal': ['99', '510']}], ['control 2', [['30', 'asset', 100, 0], ['205', 'dividend', 250, 249], ['6', 'asset', 250, 900], ['150', 'expense', 0, 1234]], {'rows': [['6', 0, 650], ['30', 100, 0], ['150', 0, 1234], ['205', 1, 0]], 'totals': [101, 1884], 'balanced': False, 'abnormal': ['6', '150']}], ['control 3', [['7200', 'expense', 250, 251], ['150', 'expense', 5000, 1234], ['30', 'asset', 100, 99]], {'rows': [['30', 1, 0], ['150', 3766, 0], ['7200', 0, 1]], 'totals': [3767, 1], 'balanced': False, 'abnormal': ['7200']}], ['control 4', [['1500', 'asset', 0, 5000], ['1010', 'equity', 5000, 5000], ['99', 'asset', 250, 249]], {'rows': [['99', 1, 0], ['1500', 0, 5000]], 'totals': [1, 5000], 'balanced': False, 'abnormal': ['1500']}], ['control 5', [['150', 'expense', 100, 0], ['101', 'liability', 250, 250], ['99', 'liability', 100, 100], ['205', 'equity', 100, 100], ['510', 'expense', 100, 0], ['7200', 'asset', 5000, 5000]], {'rows': [['150', 100, 0], ['510', 100, 0]], 'totals': [200, 0], 'balanced': False, 'abnormal': []}]]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'raised ' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: abnormal balance flag{'abnormal': [], 'balanced': False, 'rows': [['1500', 0, 1], ['4000', 250, 0], ['7200', 5000, 0]], 'totals': [5250, 1]}{'abnormal': [], 'balanced': False, 'rows': [['1500', 0, 1], ['4000', 250, 0], ['7200', 5000, 0]], 'totals': [5250, 1]}Passed
regression: abnormal balance flag, partial-repair probe{'abnormal': ['510'], 'balanced': False, 'rows': [['99', 1, 0], ['205', 5000, 0], ['510', 1134, 0]], 'totals': [6135, 0]}{'abnormal': ['510'], 'balanced': False, 'rows': [['99', 1, 0], ['205', 5000, 0], ['510', 1134, 0]], 'totals': [6135, 0]}Passed
control 1{'abnormal': [], 'balanced': False, 'rows': [['101', 1, 0], ['7200', 650, 0]], 'totals': [651, 0]}{'abnormal': [], 'balanced': False, 'rows': [['101', 1, 0], ['7200', 650, 0]], 'totals': [651, 0]}Passed
control 2{'abnormal': [], 'balanced': True, 'rows': [], 'totals': [0, 0]}{'abnormal': [], 'balanced': True, 'rows': [], 'totals': [0, 0]}Passed
control 3{'abnormal': ['150'], 'balanced': False, 'rows': [['101', 900, 0], ['150', 0, 250], ['4000', 1234, 0]], 'totals': [2134, 250]}{'abnormal': ['150'], 'balanced': False, 'rows': [['101', 900, 0], ['150', 0, 250], ['4000', 1234, 0]], 'totals': [2134, 250]}Passed
control 4{'abnormal': ['99', '510', '1500'], 'balanced': False, 'rows': [['99', 0, 5000], ['510', 0, 1], ['1500', 0, 250], ['2100', 1, 0]], 'totals': [1, 5251]}{'abnormal': ['99', '510', '1500'], 'balanced': False, 'rows': [['99', 0, 5000], ['510', 0, 1], ['1500', 0, 250], ['2100', 1, 0]], 'totals': [1, 5251]}Passed
control 5{'abnormal': ['1010', '1500'], 'balanced': False, 'rows': [['1010', 0, 100], ['1500', 0, 984]], 'totals': [0, 1084]}{'abnormal': ['1010', '1500'], 'balanced': False, 'rows': [['1010', 0, 100], ['1500', 0, 984]], 'totals': [0, 1084]}Passed

SHA-256 / 37e49703df15e2373c2cd2e7c1a4424e4632672a487fc04ed49ac49fb6052211

Verification & scope

A deterministic bounded teaching model with stipulated toy bookkeeping rules stated in the contract; amounts are integer cents; it makes no claim of conformance to any accounting standard or product. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:46:21.361682+00:00.

Case digest / 66cf0595ae1d814aedeca834d38e05a982c0833a4f1e242b3c8be6ce54156fa3