broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    bank = x['bank']
    book = x['book']
    entries = []
    for item in x['items']:
        kind = item[0]
        if kind == 'deposit_in_transit':
            bank += item[1]
        elif kind == 'outstanding_check':
            bank -= item[1]
        elif kind == 'bank_error':
            bank += item[1]
        else:
            if kind == 'bank_fee':
                adj = -item[1]
            elif kind == 'interest' or kind == 'nsf':
                adj = item[1]
            elif kind == 'collection':
                adj = item[1] - item[2]
            elif kind == 'check_error':
                adj = item[1] - item[2]
            else:
                continue
            book += adj
            entries.append([kind, adj])
    return {'adjusted_bank': bank, 'adjusted_book': book, 'reconciled': bank == book, 'entries': entries}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: nsf check direction', {'bank': 10000, 'book': 10000, 'items': [['bank_fee', 90], ['interest', 15], ['bank_error', 1200], ['nsf', 1200], ['memo', 250], ['memo', 1200]]}, {'adjusted_bank': 11200, 'adjusted_book': 8725, 'reconciled': False, 'entries': [['bank_fee', -90], ['interest', 15], ['nsf', -1200]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['interest', 15], ['bank_fee', 400], ['check_error', 2100, 450]]}, {'adjusted_bank': 8000, 'adjusted_book': 10265, 'reconciled': False, 'entries': [['interest', 15], ['bank_fee', -400], ['check_error', 1650]]}], ['control 2', {'bank': 8000, 'book': 9000, 'items': [['memo', 15], ['check_error', 540, 450], ['bank_error', 400], ['interest', 15], ['bank_fee', 90]]}, {'adjusted_bank': 8400, 'adjusted_book': 9015, 'reconciled': False, 'entries': [['check_error', 90], ['interest', 15], ['bank_fee', -90]]}], ['control 3', {'bank': 10000, 'book': 10000, 'items': [['deposit_in_transit', 1200], ['deposit_in_transit', 400], ['bank_fee', 90], ['bank_fee', 1200], ['deposit_in_transit', 400]]}, {'adjusted_bank': 12000, 'adjusted_book': 8710, 'reconciled': False, 'entries': [['bank_fee', -90], ['bank_fee', -1200]]}], ['control 4', {'bank': 8000, 'book': 9000, 'items': [['interest', 1200], ['bank_error', 400], ['interest', 400], ['bank_error', 250], ['interest', 400]]}, {'adjusted_bank': 8650, 'adjusted_book': 11000, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 400], ['interest', 400]]}], ['control 5', {'bank': 8000, 'book': 10000, 'items': [['bank_fee', 250], ['deposit_in_transit', 250], ['check_error', 2100, 450], ['deposit_in_transit', 90], ['check_error', 540, 2010], ['deposit_in_transit', 90], ['collection', 2500, 15]]}, {'adjusted_bank': 8430, 'adjusted_book': 12415, 'reconciled': False, 'entries': [['bank_fee', -250], ['check_error', 1650], ['check_error', -1470], ['collection', 2485]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['collection', 12000, 0], ['check_error', 1200, 1020]]}, {'adjusted_bank': 12750, 'adjusted_book': 21180, 'reconciled': False, 'entries': [['collection', 12000], ['check_error', 180]]}]], [['regression: nsf check direction', {'bank': 12500, 'book': 9000, 'items': [['nsf', 400], ['bank_error', -90], ['bank_fee', 90]]}, {'adjusted_bank': 12410, 'adjusted_book': 8510, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -90]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 400], ['outstanding_check', 400], ['memo', 15], ['outstanding_check', 250], ['memo', 1200], ['deposit_in_transit', 250]]}, {'adjusted_bank': 8000, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 2', {'bank': 8000, 'book': 11800, 'items': [['memo', 400], ['bank_fee', 1200], ['interest', 90], ['memo', 400], ['interest', 15], ['bank_error', -400], ['memo', 250]]}, {'adjusted_bank': 7600, 'adjusted_book': 10705, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 90], ['interest', 15]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['bank_fee', 1200], ['interest', 250], ['bank_error', -1200]]}, {'adjusted_bank': 6800, 'adjusted_book': 10850, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 250]]}], ['control 4', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -250], ['interest', 250], ['check_error', 1200, 1209], ['bank_fee', 90], ['bank_error', -400]]}, {'adjusted_bank': 11850, 'adjusted_book': 9151, 'reconciled': False, 'entries': [['interest', 250], ['check_error', -9], ['bank_fee', -90]]}], ['control 5', {'bank': 12500, 'book': 9000, 'items': [['bank_error', 90], ['deposit_in_transit', 400], ['bank_error', -400], ['outstanding_check', 400]]}, {'adjusted_bank': 12190, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['bank_error', 90], ['check_error', 2100, 2010], ['bank_fee', 1200], ['bank_error', 90], ['bank_fee', 250], ['memo', 250]]}, {'adjusted_bank': 12680, 'adjusted_book': 7640, 'reconciled': False, 'entries': [['check_error', 90], ['bank_fee', -1200], ['bank_fee', -250]]}]], [['regression: nsf check direction', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['interest', 250], ['nsf', 250], ['outstanding_check', 400], ['deposit_in_transit', 15], ['collection', 12000, 0]]}, {'adjusted_bank': 10815, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['interest', 250], ['nsf', -250], ['collection', 12000]]}], ['control 1', {'bank': 10000, 'book': 11800, 'items': [['collection', 4000, 15], ['outstanding_check', 1200], ['bank_error', 400], ['bank_fee', 1200], ['bank_error', 400]]}, {'adjusted_bank': 9600, 'adjusted_book': 14585, 'reconciled': False, 'entries': [['collection', 3985], ['bank_fee', -1200]]}], ['control 2', {'bank': 10000, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['check_error', 450, 459], ['check_error', 540, 450], ['bank_error', 15]]}, {'adjusted_bank': 11215, 'adjusted_book': 11881, 'reconciled': False, 'entries': [['check_error', -9], ['check_error', 90]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['check_error', 450, 450], ['outstanding_check', 1200], ['bank_error', -400], ['check_error', 2100, 2010]]}, {'adjusted_bank': 6400, 'adjusted_book': 11890, 'reconciled': False, 'entries': [['check_error', 0], ['check_error', 90]]}], ['control 4', {'bank': 10000, 'book': 10000, 'items': [['interest', 90], ['memo', 250], ['memo', 15], ['check_error', 540, 540], ['bank_fee', 400]]}, {'adjusted_bank': 10000, 'adjusted_book': 9690, 'reconciled': False, 'entries': [['interest', 90], ['check_error', 0], ['bank_fee', -400]]}], ['control 5', {'bank': 12500, 'book': 11800, 'items': [['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 15], ['deposit_in_transit', 90], ['bank_error', 250], ['check_error', 540, 540]]}, {'adjusted_bank': 13150, 'adjusted_book': 23785, 'reconciled': False, 'entries': [['collection', 11985], ['check_error', 0]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 250], ['interest', 15], ['bank_error', 90], ['interest', 90], ['collection', 150, 0], ['outstanding_check', 400]]}, {'adjusted_bank': 12440, 'adjusted_book': 10255, 'reconciled': False, 'entries': [['interest', 15], ['interest', 90], ['collection', 150]]}]], [['regression: nsf check direction', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 15], ['bank_error', -15], ['nsf', 90], ['collection', 2500, 25], ['outstanding_check', 90], ['collection', 900, 0]]}, {'adjusted_bank': 12410, 'adjusted_book': 13285, 'reconciled': False, 'entries': [['nsf', -90], ['collection', 2475], ['collection', 900]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['collection', 4000, 0], ['bank_error', 400], ['check_error', 450, 459]]}, {'adjusted_bank': 12900, 'adjusted_book': 15791, 'reconciled': False, 'entries': [['collection', 4000], ['check_error', -9]]}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['bank_error', 90]]}, {'adjusted_bank': 12750, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 400], ['deposit_in_transit', 1200], ['memo', 90], ['interest', 250], ['check_error', 540, 540], ['check_error', 2100, 2109], ['interest', 250]]}, {'adjusted_bank': 9600, 'adjusted_book': 10491, 'reconciled': False, 'entries': [['interest', 250], ['check_error', 0], ['check_error', -9], ['interest', 250]]}], ['control 4', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 90], ['bank_error', 15], ['collection', 4000, 0], ['interest', 250]]}, {'adjusted_bank': 8105, 'adjusted_book': 14250, 'reconciled': False, 'entries': [['collection', 4000], ['interest', 250]]}], ['control 5', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -1200], ['memo', 15], ['bank_fee', 15], ['outstanding_check', 400], ['outstanding_check', 400]]}, {'adjusted_bank': 10500, 'adjusted_book': 8985, 'reconciled': False, 'entries': [['bank_fee', -15]]}], ['control 6', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 0]]}, {'adjusted_bank': 8560, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['collection', 12000]]}]], [['regression: nsf check direction', {'bank': 12500, 'book': 11800, 'items': [['nsf', 400], ['bank_fee', 250], ['bank_error', 250]]}, {'adjusted_bank': 12750, 'adjusted_book': 11150, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -250]]}], ['control 1', {'bank': 12500, 'book': 10000, 'items': [['outstanding_check', 250], ['collection', 4000, 25], ['check_error', 2100, 450], ['outstanding_check', 250], ['bank_fee', 90], ['interest', 1200], ['outstanding_check', 15]]}, {'adjusted_bank': 11985, 'adjusted_book': 16735, 'reconciled': False, 'entries': [['collection', 3975], ['check_error', 1650], ['bank_fee', -90], ['interest', 1200]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['outstanding_check', 90], ['memo', 250], ['bank_fee', 15], ['interest', 1200], ['memo', 250], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9925, 'adjusted_book': 11185, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 1200]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['check_error', 450, 459], ['outstanding_check', 400], ['interest', 1200]]}, {'adjusted_bank': 7600, 'adjusted_book': 10191, 'reconciled': False, 'entries': [['check_error', -9], ['interest', 1200]]}], ['control 4', {'bank': 10000, 'book': 11800, 'items': [['bank_error', -250], ['deposit_in_transit', 250], ['bank_fee', 250]]}, {'adjusted_bank': 10000, 'adjusted_book': 11550, 'reconciled': False, 'entries': [['bank_fee', -250]]}], ['control 5', {'bank': 8000, 'book': 10000, 'items': [['bank_fee', 15], ['deposit_in_transit', 15], ['outstanding_check', 250]]}, {'adjusted_bank': 7765, 'adjusted_book': 9985, 'reconciled': False, 'entries': [['bank_fee', -15]]}], ['control 6', {'bank': 10000, 'book': 11800, 'items': [['bank_fee', 15], ['memo', 400], ['bank_error', -1200], ['interest', 15], ['outstanding_check', 250]]}, {'adjusted_bank': 8550, 'adjusted_book': 11800, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 15]]}]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    bank = x['bank']
    book = x['book']
    entries = []
    for item in x['items']:
        kind = item[0]
        if kind == 'deposit_in_transit':
            bank += item[1]
        elif kind == 'outstanding_check':
            bank -= item[1]
        elif kind == 'bank_error':
            bank += item[1]
        else:
            if kind == 'bank_fee':
                adj = -item[1]
            elif kind == 'interest':
                adj = item[1]
            elif kind == 'collection':
                adj = item[1] - item[2]
            elif kind == 'check_error':
                adj = item[1] - item[2]
            else:
                continue
            book += adj
            entries.append([kind, adj])
    return {'adjusted_bank': bank, 'adjusted_book': book, 'reconciled': bank == book, 'entries': entries}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: nsf check direction', {'bank': 10000, 'book': 10000, 'items': [['bank_fee', 90], ['interest', 15], ['bank_error', 1200], ['nsf', 1200], ['memo', 250], ['memo', 1200]]}, {'adjusted_bank': 11200, 'adjusted_book': 8725, 'reconciled': False, 'entries': [['bank_fee', -90], ['interest', 15], ['nsf', -1200]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['interest', 15], ['bank_fee', 400], ['check_error', 2100, 450]]}, {'adjusted_bank': 8000, 'adjusted_book': 10265, 'reconciled': False, 'entries': [['interest', 15], ['bank_fee', -400], ['check_error', 1650]]}], ['control 2', {'bank': 8000, 'book': 9000, 'items': [['memo', 15], ['check_error', 540, 450], ['bank_error', 400], ['interest', 15], ['bank_fee', 90]]}, {'adjusted_bank': 8400, 'adjusted_book': 9015, 'reconciled': False, 'entries': [['check_error', 90], ['interest', 15], ['bank_fee', -90]]}], ['control 3', {'bank': 10000, 'book': 10000, 'items': [['deposit_in_transit', 1200], ['deposit_in_transit', 400], ['bank_fee', 90], ['bank_fee', 1200], ['deposit_in_transit', 400]]}, {'adjusted_bank': 12000, 'adjusted_book': 8710, 'reconciled': False, 'entries': [['bank_fee', -90], ['bank_fee', -1200]]}], ['control 4', {'bank': 8000, 'book': 9000, 'items': [['interest', 1200], ['bank_error', 400], ['interest', 400], ['bank_error', 250], ['interest', 400]]}, {'adjusted_bank': 8650, 'adjusted_book': 11000, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 400], ['interest', 400]]}], ['control 5', {'bank': 8000, 'book': 10000, 'items': [['bank_fee', 250], ['deposit_in_transit', 250], ['check_error', 2100, 450], ['deposit_in_transit', 90], ['check_error', 540, 2010], ['deposit_in_transit', 90], ['collection', 2500, 15]]}, {'adjusted_bank': 8430, 'adjusted_book': 12415, 'reconciled': False, 'entries': [['bank_fee', -250], ['check_error', 1650], ['check_error', -1470], ['collection', 2485]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['collection', 12000, 0], ['check_error', 1200, 1020]]}, {'adjusted_bank': 12750, 'adjusted_book': 21180, 'reconciled': False, 'entries': [['collection', 12000], ['check_error', 180]]}]], [['regression: nsf check direction', {'bank': 12500, 'book': 9000, 'items': [['nsf', 400], ['bank_error', -90], ['bank_fee', 90]]}, {'adjusted_bank': 12410, 'adjusted_book': 8510, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -90]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 400], ['outstanding_check', 400], ['memo', 15], ['outstanding_check', 250], ['memo', 1200], ['deposit_in_transit', 250]]}, {'adjusted_bank': 8000, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 2', {'bank': 8000, 'book': 11800, 'items': [['memo', 400], ['bank_fee', 1200], ['interest', 90], ['memo', 400], ['interest', 15], ['bank_error', -400], ['memo', 250]]}, {'adjusted_bank': 7600, 'adjusted_book': 10705, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 90], ['interest', 15]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['bank_fee', 1200], ['interest', 250], ['bank_error', -1200]]}, {'adjusted_bank': 6800, 'adjusted_book': 10850, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 250]]}], ['control 4', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -250], ['interest', 250], ['check_error', 1200, 1209], ['bank_fee', 90], ['bank_error', -400]]}, {'adjusted_bank': 11850, 'adjusted_book': 9151, 'reconciled': False, 'entries': [['interest', 250], ['check_error', -9], ['bank_fee', -90]]}], ['control 5', {'bank': 12500, 'book': 9000, 'items': [['bank_error', 90], ['deposit_in_transit', 400], ['bank_error', -400], ['outstanding_check', 400]]}, {'adjusted_bank': 12190, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['bank_error', 90], ['check_error', 2100, 2010], ['bank_fee', 1200], ['bank_error', 90], ['bank_fee', 250], ['memo', 250]]}, {'adjusted_bank': 12680, 'adjusted_book': 7640, 'reconciled': False, 'entries': [['check_error', 90], ['bank_fee', -1200], ['bank_fee', -250]]}]], [['regression: nsf check direction', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['interest', 250], ['nsf', 250], ['outstanding_check', 400], ['deposit_in_transit', 15], ['collection', 12000, 0]]}, {'adjusted_bank': 10815, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['interest', 250], ['nsf', -250], ['collection', 12000]]}], ['control 1', {'bank': 10000, 'book': 11800, 'items': [['collection', 4000, 15], ['outstanding_check', 1200], ['bank_error', 400], ['bank_fee', 1200], ['bank_error', 400]]}, {'adjusted_bank': 9600, 'adjusted_book': 14585, 'reconciled': False, 'entries': [['collection', 3985], ['bank_fee', -1200]]}], ['control 2', {'bank': 10000, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['check_error', 450, 459], ['check_error', 540, 450], ['bank_error', 15]]}, {'adjusted_bank': 11215, 'adjusted_book': 11881, 'reconciled': False, 'entries': [['check_error', -9], ['check_error', 90]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['check_error', 450, 450], ['outstanding_check', 1200], ['bank_error', -400], ['check_error', 2100, 2010]]}, {'adjusted_bank': 6400, 'adjusted_book': 11890, 'reconciled': False, 'entries': [['check_error', 0], ['check_error', 90]]}], ['control 4', {'bank': 10000, 'book': 10000, 'items': [['interest', 90], ['memo', 250], ['memo', 15], ['check_error', 540, 540], ['bank_fee', 400]]}, {'adjusted_bank': 10000, 'adjusted_book': 9690, 'reconciled': False, 'entries': [['interest', 90], ['check_error', 0], ['bank_fee', -400]]}], ['control 5', {'bank': 12500, 'book': 11800, 'items': [['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 15], ['deposit_in_transit', 90], ['bank_error', 250], ['check_error', 540, 540]]}, {'adjusted_bank': 13150, 'adjusted_book': 23785, 'reconciled': False, 'entries': [['collection', 11985], ['check_error', 0]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 250], ['interest', 15], ['bank_error', 90], ['interest', 90], ['collection', 150, 0], ['outstanding_check', 400]]}, {'adjusted_bank': 12440, 'adjusted_book': 10255, 'reconciled': False, 'entries': [['interest', 15], ['interest', 90], ['collection', 150]]}]], [['regression: nsf check direction', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 15], ['bank_error', -15], ['nsf', 90], ['collection', 2500, 25], ['outstanding_check', 90], ['collection', 900, 0]]}, {'adjusted_bank': 12410, 'adjusted_book': 13285, 'reconciled': False, 'entries': [['nsf', -90], ['collection', 2475], ['collection', 900]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['collection', 4000, 0], ['bank_error', 400], ['check_error', 450, 459]]}, {'adjusted_bank': 12900, 'adjusted_book': 15791, 'reconciled': False, 'entries': [['collection', 4000], ['check_error', -9]]}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['bank_error', 90]]}, {'adjusted_bank': 12750, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 400], ['deposit_in_transit', 1200], ['memo', 90], ['interest', 250], ['check_error', 540, 540], ['check_error', 2100, 2109], ['interest', 250]]}, {'adjusted_bank': 9600, 'adjusted_book': 10491, 'reconciled': False, 'entries': [['interest', 250], ['check_error', 0], ['check_error', -9], ['interest', 250]]}], ['control 4', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 90], ['bank_error', 15], ['collection', 4000, 0], ['interest', 250]]}, {'adjusted_bank': 8105, 'adjusted_book': 14250, 'reconciled': False, 'entries': [['collection', 4000], ['interest', 250]]}], ['control 5', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -1200], ['memo', 15], ['bank_fee', 15], ['outstanding_check', 400], ['outstanding_check', 400]]}, {'adjusted_bank': 10500, 'adjusted_book': 8985, 'reconciled': False, 'entries': [['bank_fee', -15]]}], ['control 6', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 0]]}, {'adjusted_bank': 8560, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['collection', 12000]]}]], [['regression: nsf check direction', {'bank': 12500, 'book': 11800, 'items': [['nsf', 400], ['bank_fee', 250], ['bank_error', 250]]}, {'adjusted_bank': 12750, 'adjusted_book': 11150, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -250]]}], ['control 1', {'bank': 12500, 'book': 10000, 'items': [['outstanding_check', 250], ['collection', 4000, 25], ['check_error', 2100, 450], ['outstanding_check', 250], ['bank_fee', 90], ['interest', 1200], ['outstanding_check', 15]]}, {'adjusted_bank': 11985, 'adjusted_book': 16735, 'reconciled': False, 'entries': [['collection', 3975], ['check_error', 1650], ['bank_fee', -90], ['interest', 1200]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['outstanding_check', 90], ['memo', 250], ['bank_fee', 15], ['interest', 1200], ['memo', 250], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9925, 'adjusted_book': 11185, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 1200]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['check_error', 450, 459], ['outstanding_check', 400], ['interest', 1200]]}, {'adjusted_bank': 7600, 'adjusted_book': 10191, 'reconciled': False, 'entries': [['check_error', -9], ['interest', 1200]]}], ['control 4', {'bank': 10000, 'book': 11800, 'items': [['bank_error', -250], ['deposit_in_transit', 250], ['bank_fee', 250]]}, {'adjusted_bank': 10000, 'adjusted_book': 11550, 'reconciled': False, 'entries': [['bank_fee', -250]]}], ['control 5', {'bank': 8000, 'book': 10000, 'items': [['bank_fee', 15], ['deposit_in_transit', 15], ['outstanding_check', 250]]}, {'adjusted_bank': 7765, 'adjusted_book': 9985, 'reconciled': False, 'entries': [['bank_fee', -15]]}], ['control 6', {'bank': 10000, 'book': 11800, 'items': [['bank_fee', 15], ['memo', 400], ['bank_error', -1200], ['interest', 15], ['outstanding_check', 250]]}, {'adjusted_bank': 8550, 'adjusted_book': 11800, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 15]]}]]]
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)

prompt:
A bounced customer check increases the adjusted cash balance.

x = {'bank': statement balance, 'book': ledger cash balance, 'items': [[kind, ...]]}. Bank side: deposit_in_transit adds, outstanding_check subtracts, bank_error adds its signed correction. Book side (each produces an adjusting entry [kind, signed amount] in input order): bank_fee and nsf subtract, interest adds, collection [kind, face, fee] adds face - fee, check_error [kind, recorded, actual] adds recorded - actual. Other kinds are ignored. Return {'adjusted_bank', 'adjusted_book', 'reconciled', 'entries'}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    bank = x['bank']
    book = x['book']
    entries = []
    for item in x['items']:
        kind = item[0]
        if kind == 'deposit_in_transit':
            bank += item[1]
        elif kind == 'outstanding_check':
            bank -= item[1]
        elif kind == 'bank_error':
            bank += item[1]
        else:
            if kind == 'bank_fee' or kind == 'nsf':
                adj = -item[1]
            elif kind == 'interest':
                adj = item[1]
            elif kind == 'collection':
                adj = item[1] - item[2]
            elif kind == 'check_error':
                adj = item[2] - item[1]
            else:
                continue
            book += adj
            entries.append([kind, adj])
    return {'adjusted_bank': bank, 'adjusted_book': book, 'reconciled': bank == book, 'entries': entries}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: check recording error sign', {'bank': 8000, 'book': 9000, 'items': [['interest', 15], ['bank_fee', 400], ['check_error', 2100, 450]]}, {'adjusted_bank': 8000, 'adjusted_book': 10265, 'reconciled': False, 'entries': [['interest', 15], ['bank_fee', -400], ['check_error', 1650]]}], ['control 1', {'bank': 10000, 'book': 10000, 'items': [['bank_fee', 90], ['interest', 15], ['bank_error', 1200], ['nsf', 1200], ['memo', 250], ['memo', 1200]]}, {'adjusted_bank': 11200, 'adjusted_book': 8725, 'reconciled': False, 'entries': [['bank_fee', -90], ['interest', 15], ['nsf', -1200]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['deposit_in_transit', 1200], ['deposit_in_transit', 400], ['bank_fee', 90], ['bank_fee', 1200], ['deposit_in_transit', 400]]}, {'adjusted_bank': 12000, 'adjusted_book': 8710, 'reconciled': False, 'entries': [['bank_fee', -90], ['bank_fee', -1200]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['interest', 1200], ['bank_error', 400], ['interest', 400], ['bank_error', 250], ['interest', 400]]}, {'adjusted_bank': 8650, 'adjusted_book': 11000, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 400], ['interest', 400]]}], ['control 4', {'bank': 12500, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['bank_fee', 250], ['bank_error', -1200], ['bank_fee', 1200]]}, {'adjusted_bank': 12500, 'adjusted_book': 10350, 'reconciled': False, 'entries': [['bank_fee', -250], ['bank_fee', -1200]]}], ['control 5', {'bank': 10000, 'book': 9000, 'items': [['outstanding_check', 15], ['interest', 1200], ['interest', 1200], ['collection', 12000, 0], ['collection', 4000, 15], ['outstanding_check', 90]]}, {'adjusted_bank': 9895, 'adjusted_book': 27385, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 1200], ['collection', 12000], ['collection', 3985]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['interest', 250], ['bank_fee', 90], ['memo', 15], ['bank_error', -15], ['collection', 4000, 15]]}, {'adjusted_bank': 12485, 'adjusted_book': 14145, 'reconciled': False, 'entries': [['interest', 250], ['bank_fee', -90], ['collection', 3985]]}]], [['regression: check recording error sign', {'bank': 10000, 'book': 11800, 'items': [['check_error', 2100, 540], ['nsf', 15], ['interest', 400], ['outstanding_check', 400], ['bank_error', -400], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9215, 'adjusted_book': 13745, 'reconciled': False, 'entries': [['check_error', 1560], ['nsf', -15], ['interest', 400]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 400], ['outstanding_check', 400], ['memo', 15], ['outstanding_check', 250], ['memo', 1200], ['deposit_in_transit', 250]]}, {'adjusted_bank': 8000, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['nsf', 400], ['bank_error', -90], ['bank_fee', 90]]}, {'adjusted_bank': 12410, 'adjusted_book': 8510, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -90]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['memo', 400], ['bank_fee', 1200], ['interest', 90], ['memo', 400], ['interest', 15], ['bank_error', -400], ['memo', 250]]}, {'adjusted_bank': 7600, 'adjusted_book': 10705, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 90], ['interest', 15]]}], ['control 4', {'bank': 8000, 'book': 11800, 'items': [['bank_fee', 1200], ['interest', 250], ['bank_error', -1200]]}, {'adjusted_bank': 6800, 'adjusted_book': 10850, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 250]]}], ['control 5', {'bank': 8000, 'book': 9000, 'items': [['collection', 4000, 25], ['nsf', 400], ['bank_fee', 15], ['deposit_in_transit', 400]]}, {'adjusted_bank': 8400, 'adjusted_book': 12560, 'reconciled': False, 'entries': [['collection', 3975], ['nsf', -400], ['bank_fee', -15]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['bank_error', 90], ['deposit_in_transit', 400], ['bank_error', -400], ['outstanding_check', 400]]}, {'adjusted_bank': 12190, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}]], [['regression: check recording error sign', {'bank': 10000, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['check_error', 450, 459], ['check_error', 540, 450], ['bank_error', 15]]}, {'adjusted_bank': 11215, 'adjusted_book': 11881, 'reconciled': False, 'entries': [['check_error', -9], ['check_error', 90]]}], ['control 1', {'bank': 10000, 'book': 11800, 'items': [['collection', 4000, 15], ['outstanding_check', 1200], ['bank_error', 400], ['bank_fee', 1200], ['bank_error', 400]]}, {'adjusted_bank': 9600, 'adjusted_book': 14585, 'reconciled': False, 'entries': [['collection', 3985], ['bank_fee', -1200]]}], ['control 2', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['interest', 250], ['nsf', 250], ['outstanding_check', 400], ['deposit_in_transit', 15], ['collection', 12000, 0]]}, {'adjusted_bank': 10815, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['interest', 250], ['nsf', -250], ['collection', 12000]]}], ['control 3', {'bank': 10000, 'book': 9000, 'items': [['collection', 150, 15], ['nsf', 15], ['deposit_in_transit', 90], ['memo', 1200], ['collection', 900, 25], ['interest', 90], ['deposit_in_transit', 400]]}, {'adjusted_bank': 10490, 'adjusted_book': 10085, 'reconciled': False, 'entries': [['collection', 135], ['nsf', -15], ['collection', 875], ['interest', 90]]}], ['control 4', {'bank': 10000, 'book': 10000, 'items': [['interest', 90], ['memo', 250], ['memo', 15], ['check_error', 540, 540], ['bank_fee', 400]]}, {'adjusted_bank': 10000, 'adjusted_book': 9690, 'reconciled': False, 'entries': [['interest', 90], ['check_error', 0], ['bank_fee', -400]]}], ['control 5', {'bank': 12500, 'book': 11800, 'items': [['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 15], ['deposit_in_transit', 90], ['bank_error', 250], ['check_error', 540, 540]]}, {'adjusted_bank': 13150, 'adjusted_book': 23785, 'reconciled': False, 'entries': [['collection', 11985], ['check_error', 0]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 250], ['interest', 15], ['bank_error', 90], ['interest', 90], ['collection', 150, 0], ['outstanding_check', 400]]}, {'adjusted_bank': 12440, 'adjusted_book': 10255, 'reconciled': False, 'entries': [['interest', 15], ['interest', 90], ['collection', 150]]}]], [['regression: check recording error sign', {'bank': 12500, 'book': 11800, 'items': [['collection', 4000, 0], ['bank_error', 400], ['check_error', 450, 459]]}, {'adjusted_bank': 12900, 'adjusted_book': 15791, 'reconciled': False, 'entries': [['collection', 4000], ['check_error', -9]]}], ['regression: check recording error sign, partial-repair probe', {'bank': 12500, 'book': 9000, 'items': [['collection', 2500, 15], ['check_error', 2100, 2109], ['bank_fee', 15], ['bank_error', -15], ['bank_fee', 1200], ['check_error', 2100, 540]]}, {'adjusted_bank': 12485, 'adjusted_book': 11821, 'reconciled': False, 'entries': [['collection', 2485], ['check_error', -9], ['bank_fee', -15], ['bank_fee', -1200], ['check_error', 1560]]}], ['control 1', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['bank_error', 90]]}, {'adjusted_bank': 12750, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 2', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 15], ['bank_error', -15], ['nsf', 90], ['collection', 2500, 25], ['outstanding_check', 90], ['collection', 900, 0]]}, {'adjusted_bank': 12410, 'adjusted_book': 13285, 'reconciled': False, 'entries': [['nsf', -90], ['collection', 2475], ['collection', 900]]}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 90], ['bank_error', 15], ['collection', 4000, 0], ['interest', 250]]}, {'adjusted_bank': 8105, 'adjusted_book': 14250, 'reconciled': False, 'entries': [['collection', 4000], ['interest', 250]]}], ['control 4', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -1200], ['memo', 15], ['bank_fee', 15], ['outstanding_check', 400], ['outstanding_check', 400]]}, {'adjusted_bank': 10500, 'adjusted_book': 8985, 'reconciled': False, 'entries': [['bank_fee', -15]]}], ['control 5', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 0]]}, {'adjusted_bank': 8560, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['collection', 12000]]}]], [['regression: check recording error sign', {'bank': 12500, 'book': 10000, 'items': [['outstanding_check', 250], ['collection', 4000, 25], ['check_error', 2100, 450], ['outstanding_check', 250], ['bank_fee', 90], ['interest', 1200], ['outstanding_check', 15]]}, {'adjusted_bank': 11985, 'adjusted_book': 16735, 'reconciled': False, 'entries': [['collection', 3975], ['check_error', 1650], ['bank_fee', -90], ['interest', 1200]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['nsf', 400], ['bank_fee', 250], ['bank_error', 250]]}, {'adjusted_bank': 12750, 'adjusted_book': 11150, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -250]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['outstanding_check', 90], ['memo', 250], ['bank_fee', 15], ['interest', 1200], ['memo', 250], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9925, 'adjusted_book': 11185, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 1200]]}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['nsf', 1200], ['collection', 4000, 15], ['interest', 400]]}, {'adjusted_bank': 8000, 'adjusted_book': 13185, 'reconciled': False, 'entries': [['nsf', -1200], ['collection', 3985], ['interest', 400]]}], ['control 4', {'bank': 10000, 'book': 11800, 'items': [['bank_error', -250], ['deposit_in_transit', 250], ['bank_fee', 250]]}, {'adjusted_bank': 10000, 'adjusted_book': 11550, 'reconciled': False, 'entries': [['bank_fee', -250]]}], ['control 5', {'bank': 12500, 'book': 10000, 'items': [['bank_error', -15], ['collection', 150, 25], ['nsf', 400], ['nsf', 15], ['collection', 2500, 0], ['interest', 1200]]}, {'adjusted_bank': 12485, 'adjusted_book': 13410, 'reconciled': False, 'entries': [['collection', 125], ['nsf', -400], ['nsf', -15], ['collection', 2500], ['interest', 1200]]}], ['control 6', {'bank': 8000, 'book': 10000, 'items': [['collection', 12000, 0], ['interest', 400], ['outstanding_check', 90], ['nsf', 90], ['bank_error', -1200], ['nsf', 400]]}, {'adjusted_bank': 6710, 'adjusted_book': 21910, 'reconciled': False, 'entries': [['collection', 12000], ['interest', 400], ['nsf', -90], ['nsf', -400]]}]]]
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    bank = x['bank']
    book = x['book']
    entries = []
    for item in x['items']:
        kind = item[0]
        if kind == 'deposit_in_transit':
            bank += item[1]
        elif kind == 'outstanding_check':
            bank -= item[1]
        elif kind == 'bank_error':
            bank += item[1]
        else:
            if kind == 'bank_fee' or kind == 'nsf':
                adj = -item[1]
            elif kind == 'interest':
                adj = item[1]
            elif kind == 'collection':
                adj = item[1] - item[2]
            elif kind == 'check_error':
                adj = -abs(item[1] - item[2])
            else:
                continue
            book += adj
            entries.append([kind, adj])
    return {'adjusted_bank': bank, 'adjusted_book': book, 'reconciled': bank == book, 'entries': entries}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: check recording error sign', {'bank': 8000, 'book': 9000, 'items': [['interest', 15], ['bank_fee', 400], ['check_error', 2100, 450]]}, {'adjusted_bank': 8000, 'adjusted_book': 10265, 'reconciled': False, 'entries': [['interest', 15], ['bank_fee', -400], ['check_error', 1650]]}], ['control 1', {'bank': 10000, 'book': 10000, 'items': [['bank_fee', 90], ['interest', 15], ['bank_error', 1200], ['nsf', 1200], ['memo', 250], ['memo', 1200]]}, {'adjusted_bank': 11200, 'adjusted_book': 8725, 'reconciled': False, 'entries': [['bank_fee', -90], ['interest', 15], ['nsf', -1200]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['deposit_in_transit', 1200], ['deposit_in_transit', 400], ['bank_fee', 90], ['bank_fee', 1200], ['deposit_in_transit', 400]]}, {'adjusted_bank': 12000, 'adjusted_book': 8710, 'reconciled': False, 'entries': [['bank_fee', -90], ['bank_fee', -1200]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['interest', 1200], ['bank_error', 400], ['interest', 400], ['bank_error', 250], ['interest', 400]]}, {'adjusted_bank': 8650, 'adjusted_book': 11000, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 400], ['interest', 400]]}], ['control 4', {'bank': 12500, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['bank_fee', 250], ['bank_error', -1200], ['bank_fee', 1200]]}, {'adjusted_bank': 12500, 'adjusted_book': 10350, 'reconciled': False, 'entries': [['bank_fee', -250], ['bank_fee', -1200]]}], ['control 5', {'bank': 10000, 'book': 9000, 'items': [['outstanding_check', 15], ['interest', 1200], ['interest', 1200], ['collection', 12000, 0], ['collection', 4000, 15], ['outstanding_check', 90]]}, {'adjusted_bank': 9895, 'adjusted_book': 27385, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 1200], ['collection', 12000], ['collection', 3985]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['interest', 250], ['bank_fee', 90], ['memo', 15], ['bank_error', -15], ['collection', 4000, 15]]}, {'adjusted_bank': 12485, 'adjusted_book': 14145, 'reconciled': False, 'entries': [['interest', 250], ['bank_fee', -90], ['collection', 3985]]}]], [['regression: check recording error sign', {'bank': 10000, 'book': 11800, 'items': [['check_error', 2100, 540], ['nsf', 15], ['interest', 400], ['outstanding_check', 400], ['bank_error', -400], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9215, 'adjusted_book': 13745, 'reconciled': False, 'entries': [['check_error', 1560], ['nsf', -15], ['interest', 400]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 400], ['outstanding_check', 400], ['memo', 15], ['outstanding_check', 250], ['memo', 1200], ['deposit_in_transit', 250]]}, {'adjusted_bank': 8000, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['nsf', 400], ['bank_error', -90], ['bank_fee', 90]]}, {'adjusted_bank': 12410, 'adjusted_book': 8510, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -90]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['memo', 400], ['bank_fee', 1200], ['interest', 90], ['memo', 400], ['interest', 15], ['bank_error', -400], ['memo', 250]]}, {'adjusted_bank': 7600, 'adjusted_book': 10705, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 90], ['interest', 15]]}], ['control 4', {'bank': 8000, 'book': 11800, 'items': [['bank_fee', 1200], ['interest', 250], ['bank_error', -1200]]}, {'adjusted_bank': 6800, 'adjusted_book': 10850, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 250]]}], ['control 5', {'bank': 8000, 'book': 9000, 'items': [['collection', 4000, 25], ['nsf', 400], ['bank_fee', 15], ['deposit_in_transit', 400]]}, {'adjusted_bank': 8400, 'adjusted_book': 12560, 'reconciled': False, 'entries': [['collection', 3975], ['nsf', -400], ['bank_fee', -15]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['bank_error', 90], ['deposit_in_transit', 400], ['bank_error', -400], ['outstanding_check', 400]]}, {'adjusted_bank': 12190, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}]], [['regression: check recording error sign', {'bank': 10000, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['check_error', 450, 459], ['check_error', 540, 450], ['bank_error', 15]]}, {'adjusted_bank': 11215, 'adjusted_book': 11881, 'reconciled': False, 'entries': [['check_error', -9], ['check_error', 90]]}], ['control 1', {'bank': 10000, 'book': 11800, 'items': [['collection', 4000, 15], ['outstanding_check', 1200], ['bank_error', 400], ['bank_fee', 1200], ['bank_error', 400]]}, {'adjusted_bank': 9600, 'adjusted_book': 14585, 'reconciled': False, 'entries': [['collection', 3985], ['bank_fee', -1200]]}], ['control 2', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['interest', 250], ['nsf', 250], ['outstanding_check', 400], ['deposit_in_transit', 15], ['collection', 12000, 0]]}, {'adjusted_bank': 10815, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['interest', 250], ['nsf', -250], ['collection', 12000]]}], ['control 3', {'bank': 10000, 'book': 9000, 'items': [['collection', 150, 15], ['nsf', 15], ['deposit_in_transit', 90], ['memo', 1200], ['collection', 900, 25], ['interest', 90], ['deposit_in_transit', 400]]}, {'adjusted_bank': 10490, 'adjusted_book': 10085, 'reconciled': False, 'entries': [['collection', 135], ['nsf', -15], ['collection', 875], ['interest', 90]]}], ['control 4', {'bank': 10000, 'book': 10000, 'items': [['interest', 90], ['memo', 250], ['memo', 15], ['check_error', 540, 540], ['bank_fee', 400]]}, {'adjusted_bank': 10000, 'adjusted_book': 9690, 'reconciled': False, 'entries': [['interest', 90], ['check_error', 0], ['bank_fee', -400]]}], ['control 5', {'bank': 12500, 'book': 11800, 'items': [['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 15], ['deposit_in_transit', 90], ['bank_error', 250], ['check_error', 540, 540]]}, {'adjusted_bank': 13150, 'adjusted_book': 23785, 'reconciled': False, 'entries': [['collection', 11985], ['check_error', 0]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 250], ['interest', 15], ['bank_error', 90], ['interest', 90], ['collection', 150, 0], ['outstanding_check', 400]]}, {'adjusted_bank': 12440, 'adjusted_book': 10255, 'reconciled': False, 'entries': [['interest', 15], ['interest', 90], ['collection', 150]]}]], [['regression: check recording error sign', {'bank': 12500, 'book': 11800, 'items': [['collection', 4000, 0], ['bank_error', 400], ['check_error', 450, 459]]}, {'adjusted_bank': 12900, 'adjusted_book': 15791, 'reconciled': False, 'entries': [['collection', 4000], ['check_error', -9]]}], ['regression: check recording error sign, partial-repair probe', {'bank': 12500, 'book': 9000, 'items': [['collection', 2500, 15], ['check_error', 2100, 2109], ['bank_fee', 15], ['bank_error', -15], ['bank_fee', 1200], ['check_error', 2100, 540]]}, {'adjusted_bank': 12485, 'adjusted_book': 11821, 'reconciled': False, 'entries': [['collection', 2485], ['check_error', -9], ['bank_fee', -15], ['bank_fee', -1200], ['check_error', 1560]]}], ['control 1', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['bank_error', 90]]}, {'adjusted_bank': 12750, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 2', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 15], ['bank_error', -15], ['nsf', 90], ['collection', 2500, 25], ['outstanding_check', 90], ['collection', 900, 0]]}, {'adjusted_bank': 12410, 'adjusted_book': 13285, 'reconciled': False, 'entries': [['nsf', -90], ['collection', 2475], ['collection', 900]]}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 90], ['bank_error', 15], ['collection', 4000, 0], ['interest', 250]]}, {'adjusted_bank': 8105, 'adjusted_book': 14250, 'reconciled': False, 'entries': [['collection', 4000], ['interest', 250]]}], ['control 4', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -1200], ['memo', 15], ['bank_fee', 15], ['outstanding_check', 400], ['outstanding_check', 400]]}, {'adjusted_bank': 10500, 'adjusted_book': 8985, 'reconciled': False, 'entries': [['bank_fee', -15]]}], ['control 5', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 0]]}, {'adjusted_bank': 8560, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['collection', 12000]]}]], [['regression: check recording error sign', {'bank': 12500, 'book': 10000, 'items': [['outstanding_check', 250], ['collection', 4000, 25], ['check_error', 2100, 450], ['outstanding_check', 250], ['bank_fee', 90], ['interest', 1200], ['outstanding_check', 15]]}, {'adjusted_bank': 11985, 'adjusted_book': 16735, 'reconciled': False, 'entries': [['collection', 3975], ['check_error', 1650], ['bank_fee', -90], ['interest', 1200]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['nsf', 400], ['bank_fee', 250], ['bank_error', 250]]}, {'adjusted_bank': 12750, 'adjusted_book': 11150, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -250]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['outstanding_check', 90], ['memo', 250], ['bank_fee', 15], ['interest', 1200], ['memo', 250], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9925, 'adjusted_book': 11185, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 1200]]}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['nsf', 1200], ['collection', 4000, 15], ['interest', 400]]}, {'adjusted_bank': 8000, 'adjusted_book': 13185, 'reconciled': False, 'entries': [['nsf', -1200], ['collection', 3985], ['interest', 400]]}], ['control 4', {'bank': 10000, 'book': 11800, 'items': [['bank_error', -250], ['deposit_in_transit', 250], ['bank_fee', 250]]}, {'adjusted_bank': 10000, 'adjusted_book': 11550, 'reconciled': False, 'entries': [['bank_fee', -250]]}], ['control 5', {'bank': 12500, 'book': 10000, 'items': [['bank_error', -15], ['collection', 150, 25], ['nsf', 400], ['nsf', 15], ['collection', 2500, 0], ['interest', 1200]]}, {'adjusted_bank': 12485, 'adjusted_book': 13410, 'reconciled': False, 'entries': [['collection', 125], ['nsf', -400], ['nsf', -15], ['collection', 2500], ['interest', 1200]]}], ['control 6', {'bank': 8000, 'book': 10000, 'items': [['collection', 12000, 0], ['interest', 400], ['outstanding_check', 90], ['nsf', 90], ['bank_error', -1200], ['nsf', 400]]}, {'adjusted_bank': 6710, 'adjusted_book': 21910, 'reconciled': False, 'entries': [['collection', 12000], ['interest', 400], ['nsf', -90], ['nsf', -400]]}]]]
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)

prompt:
A check recorded for too much reduces cash further instead of restoring it.

x = {'bank': statement balance, 'book': ledger cash balance, 'items': [[kind, ...]]}. Bank side: deposit_in_transit adds, outstanding_check subtracts, bank_error adds its signed correction. Book side (each produces an adjusting entry [kind, signed amount] in input order): bank_fee and nsf subtract, interest adds, collection [kind, face, fee] adds face - fee, check_error [kind, recorded, actual] adds recorded - actual. Other kinds are ignored. Return {'adjusted_bank', 'adjusted_book', 'reconciled', 'entries'}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    bank = x['bank']
    book = x['book']
    entries = []
    for item in x['items']:
        kind = item[0]
        if kind == 'deposit_in_transit':
            bank += item[1]
        elif kind == 'outstanding_check':
            bank -= item[1]
        elif kind == 'bank_error':
            bank += item[1]
        else:
            if kind == 'bank_fee' or kind == 'nsf':
                adj = -item[1]
            elif kind == 'interest':
                adj = item[1]
            elif kind == 'collection':
                adj = item[1]
            elif kind == 'check_error':
                adj = item[1] - item[2]
            else:
                continue
            book += adj
            entries.append([kind, adj])
    return {'adjusted_bank': bank, 'adjusted_book': book, 'reconciled': bank == book, 'entries': entries}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: collection fee netting', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['collection', 2500, 15], ['outstanding_check', 15], ['check_error', 540, 450], ['check_error', 540, 540], ['check_error', 1200, 1020], ['nsf', 90]]}, {'adjusted_bank': 11185, 'adjusted_book': 11665, 'reconciled': False, 'entries': [['collection', 2485], ['check_error', 90], ['check_error', 0], ['check_error', 180], ['nsf', -90]]}], ['control 1', {'bank': 10000, 'book': 10000, 'items': [['bank_fee', 90], ['interest', 15], ['bank_error', 1200], ['nsf', 1200], ['memo', 250], ['memo', 1200]]}, {'adjusted_bank': 11200, 'adjusted_book': 8725, 'reconciled': False, 'entries': [['bank_fee', -90], ['interest', 15], ['nsf', -1200]]}], ['control 2', {'bank': 8000, 'book': 9000, 'items': [['interest', 15], ['bank_fee', 400], ['check_error', 2100, 450]]}, {'adjusted_bank': 8000, 'adjusted_book': 10265, 'reconciled': False, 'entries': [['interest', 15], ['bank_fee', -400], ['check_error', 1650]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['memo', 15], ['check_error', 540, 450], ['bank_error', 400], ['interest', 15], ['bank_fee', 90]]}, {'adjusted_bank': 8400, 'adjusted_book': 9015, 'reconciled': False, 'entries': [['check_error', 90], ['interest', 15], ['bank_fee', -90]]}], ['control 4', {'bank': 8000, 'book': 10000, 'items': [['nsf', 400], ['memo', 90], ['bank_fee', 15], ['bank_fee', 1200], ['check_error', 1200, 1020], ['outstanding_check', 250]]}, {'adjusted_bank': 7750, 'adjusted_book': 8565, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -15], ['bank_fee', -1200], ['check_error', 180]]}], ['control 5', {'bank': 10000, 'book': 10000, 'items': [['deposit_in_transit', 1200], ['deposit_in_transit', 400], ['bank_fee', 90], ['bank_fee', 1200], ['deposit_in_transit', 400]]}, {'adjusted_bank': 12000, 'adjusted_book': 8710, 'reconciled': False, 'entries': [['bank_fee', -90], ['bank_fee', -1200]]}], ['control 6', {'bank': 8000, 'book': 9000, 'items': [['interest', 1200], ['bank_error', 400], ['interest', 400], ['bank_error', 250], ['interest', 400]]}, {'adjusted_bank': 8650, 'adjusted_book': 11000, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 400], ['interest', 400]]}]], [['regression: collection fee netting', {'bank': 8000, 'book': 9000, 'items': [['collection', 4000, 25], ['nsf', 400], ['bank_fee', 15], ['deposit_in_transit', 400]]}, {'adjusted_bank': 8400, 'adjusted_book': 12560, 'reconciled': False, 'entries': [['collection', 3975], ['nsf', -400], ['bank_fee', -15]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 400], ['outstanding_check', 400], ['memo', 15], ['outstanding_check', 250], ['memo', 1200], ['deposit_in_transit', 250]]}, {'adjusted_bank': 8000, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['nsf', 400], ['bank_error', -90], ['bank_fee', 90]]}, {'adjusted_bank': 12410, 'adjusted_book': 8510, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -90]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['memo', 400], ['bank_fee', 1200], ['interest', 90], ['memo', 400], ['interest', 15], ['bank_error', -400], ['memo', 250]]}, {'adjusted_bank': 7600, 'adjusted_book': 10705, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 90], ['interest', 15]]}], ['control 4', {'bank': 10000, 'book': 11800, 'items': [['check_error', 2100, 540], ['nsf', 15], ['interest', 400], ['outstanding_check', 400], ['bank_error', -400], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9215, 'adjusted_book': 13745, 'reconciled': False, 'entries': [['check_error', 1560], ['nsf', -15], ['interest', 400]]}], ['control 5', {'bank': 8000, 'book': 11800, 'items': [['bank_fee', 1200], ['interest', 250], ['bank_error', -1200]]}, {'adjusted_bank': 6800, 'adjusted_book': 10850, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 250]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -250], ['interest', 250], ['check_error', 1200, 1209], ['bank_fee', 90], ['bank_error', -400]]}, {'adjusted_bank': 11850, 'adjusted_book': 9151, 'reconciled': False, 'entries': [['interest', 250], ['check_error', -9], ['bank_fee', -90]]}]], [['regression: collection fee netting', {'bank': 10000, 'book': 11800, 'items': [['collection', 4000, 15], ['outstanding_check', 1200], ['bank_error', 400], ['bank_fee', 1200], ['bank_error', 400]]}, {'adjusted_bank': 9600, 'adjusted_book': 14585, 'reconciled': False, 'entries': [['collection', 3985], ['bank_fee', -1200]]}], ['control 1', {'bank': 10000, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['check_error', 450, 459], ['check_error', 540, 450], ['bank_error', 15]]}, {'adjusted_bank': 11215, 'adjusted_book': 11881, 'reconciled': False, 'entries': [['check_error', -9], ['check_error', 90]]}], ['control 2', {'bank': 8000, 'book': 11800, 'items': [['check_error', 450, 450], ['outstanding_check', 1200], ['bank_error', -400], ['check_error', 2100, 2010]]}, {'adjusted_bank': 6400, 'adjusted_book': 11890, 'reconciled': False, 'entries': [['check_error', 0], ['check_error', 90]]}], ['control 3', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['interest', 250], ['nsf', 250], ['outstanding_check', 400], ['deposit_in_transit', 15], ['collection', 12000, 0]]}, {'adjusted_bank': 10815, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['interest', 250], ['nsf', -250], ['collection', 12000]]}], ['control 4', {'bank': 10000, 'book': 10000, 'items': [['interest', 90], ['memo', 250], ['memo', 15], ['check_error', 540, 540], ['bank_fee', 400]]}, {'adjusted_bank': 10000, 'adjusted_book': 9690, 'reconciled': False, 'entries': [['interest', 90], ['check_error', 0], ['bank_fee', -400]]}], ['control 5', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 250], ['interest', 15], ['bank_error', 90], ['interest', 90], ['collection', 150, 0], ['outstanding_check', 400]]}, {'adjusted_bank': 12440, 'adjusted_book': 10255, 'reconciled': False, 'entries': [['interest', 15], ['interest', 90], ['collection', 150]]}], ['control 6', {'bank': 10000, 'book': 11800, 'items': [['bank_error', 90], ['outstanding_check', 1200], ['collection', 900, 0], ['deposit_in_transit', 1200], ['deposit_in_transit', 15], ['interest', 90], ['check_error', 450, 540]]}, {'adjusted_bank': 10105, 'adjusted_book': 12700, 'reconciled': False, 'entries': [['collection', 900], ['interest', 90], ['check_error', -90]]}]], [['regression: collection fee netting', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 15], ['bank_error', -15], ['nsf', 90], ['collection', 2500, 25], ['outstanding_check', 90], ['collection', 900, 0]]}, {'adjusted_bank': 12410, 'adjusted_book': 13285, 'reconciled': False, 'entries': [['nsf', -90], ['collection', 2475], ['collection', 900]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['collection', 4000, 0], ['bank_error', 400], ['check_error', 450, 459]]}, {'adjusted_bank': 12900, 'adjusted_book': 15791, 'reconciled': False, 'entries': [['collection', 4000], ['check_error', -9]]}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['bank_error', 90]]}, {'adjusted_bank': 12750, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 400], ['deposit_in_transit', 1200], ['memo', 90], ['interest', 250], ['check_error', 540, 540], ['check_error', 2100, 2109], ['interest', 250]]}, {'adjusted_bank': 9600, 'adjusted_book': 10491, 'reconciled': False, 'entries': [['interest', 250], ['check_error', 0], ['check_error', -9], ['interest', 250]]}], ['control 4', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 90], ['bank_error', 15], ['collection', 4000, 0], ['interest', 250]]}, {'adjusted_bank': 8105, 'adjusted_book': 14250, 'reconciled': False, 'entries': [['collection', 4000], ['interest', 250]]}], ['control 5', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -1200], ['memo', 15], ['bank_fee', 15], ['outstanding_check', 400], ['outstanding_check', 400]]}, {'adjusted_bank': 10500, 'adjusted_book': 8985, 'reconciled': False, 'entries': [['bank_fee', -15]]}], ['control 6', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 0]]}, {'adjusted_bank': 8560, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['collection', 12000]]}]], [['regression: collection fee netting', {'bank': 12500, 'book': 10000, 'items': [['outstanding_check', 250], ['collection', 4000, 25], ['check_error', 2100, 450], ['outstanding_check', 250], ['bank_fee', 90], ['interest', 1200], ['outstanding_check', 15]]}, {'adjusted_bank': 11985, 'adjusted_book': 16735, 'reconciled': False, 'entries': [['collection', 3975], ['check_error', 1650], ['bank_fee', -90], ['interest', 1200]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['nsf', 400], ['bank_fee', 250], ['bank_error', 250]]}, {'adjusted_bank': 12750, 'adjusted_book': 11150, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -250]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['outstanding_check', 90], ['memo', 250], ['bank_fee', 15], ['interest', 1200], ['memo', 250], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9925, 'adjusted_book': 11185, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 1200]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['check_error', 450, 459], ['outstanding_check', 400], ['interest', 1200]]}, {'adjusted_bank': 7600, 'adjusted_book': 10191, 'reconciled': False, 'entries': [['check_error', -9], ['interest', 1200]]}], ['control 4', {'bank': 10000, 'book': 11800, 'items': [['bank_error', -250], ['deposit_in_transit', 250], ['bank_fee', 250]]}, {'adjusted_bank': 10000, 'adjusted_book': 11550, 'reconciled': False, 'entries': [['bank_fee', -250]]}], ['control 5', {'bank': 8000, 'book': 10000, 'items': [['collection', 12000, 0], ['interest', 400], ['outstanding_check', 90], ['nsf', 90], ['bank_error', -1200], ['nsf', 400]]}, {'adjusted_bank': 6710, 'adjusted_book': 21910, 'reconciled': False, 'entries': [['collection', 12000], ['interest', 400], ['nsf', -90], ['nsf', -400]]}], ['control 6', {'bank': 8000, 'book': 10000, 'items': [['bank_fee', 15], ['deposit_in_transit', 15], ['outstanding_check', 250]]}, {'adjusted_bank': 7765, 'adjusted_book': 9985, 'reconciled': False, 'entries': [['bank_fee', -15]]}]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    bank = x['bank']
    book = x['book']
    entries = []
    for item in x['items']:
        kind = item[0]
        if kind == 'deposit_in_transit':
            bank += item[1]
        elif kind == 'outstanding_check':
            bank -= item[1]
        elif kind == 'bank_error':
            bank += item[1]
        else:
            if kind == 'bank_fee' or kind == 'nsf':
                adj = -item[1]
            elif kind == 'interest':
                adj = item[1]
            elif kind == 'collection':
                adj = item[1] + item[2]
            elif kind == 'check_error':
                adj = item[1] - item[2]
            else:
                continue
            book += adj
            entries.append([kind, adj])
    return {'adjusted_bank': bank, 'adjusted_book': book, 'reconciled': bank == book, 'entries': entries}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: collection fee netting', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['collection', 2500, 15], ['outstanding_check', 15], ['check_error', 540, 450], ['check_error', 540, 540], ['check_error', 1200, 1020], ['nsf', 90]]}, {'adjusted_bank': 11185, 'adjusted_book': 11665, 'reconciled': False, 'entries': [['collection', 2485], ['check_error', 90], ['check_error', 0], ['check_error', 180], ['nsf', -90]]}], ['control 1', {'bank': 10000, 'book': 10000, 'items': [['bank_fee', 90], ['interest', 15], ['bank_error', 1200], ['nsf', 1200], ['memo', 250], ['memo', 1200]]}, {'adjusted_bank': 11200, 'adjusted_book': 8725, 'reconciled': False, 'entries': [['bank_fee', -90], ['interest', 15], ['nsf', -1200]]}], ['control 2', {'bank': 8000, 'book': 9000, 'items': [['interest', 15], ['bank_fee', 400], ['check_error', 2100, 450]]}, {'adjusted_bank': 8000, 'adjusted_book': 10265, 'reconciled': False, 'entries': [['interest', 15], ['bank_fee', -400], ['check_error', 1650]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['memo', 15], ['check_error', 540, 450], ['bank_error', 400], ['interest', 15], ['bank_fee', 90]]}, {'adjusted_bank': 8400, 'adjusted_book': 9015, 'reconciled': False, 'entries': [['check_error', 90], ['interest', 15], ['bank_fee', -90]]}], ['control 4', {'bank': 8000, 'book': 10000, 'items': [['nsf', 400], ['memo', 90], ['bank_fee', 15], ['bank_fee', 1200], ['check_error', 1200, 1020], ['outstanding_check', 250]]}, {'adjusted_bank': 7750, 'adjusted_book': 8565, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -15], ['bank_fee', -1200], ['check_error', 180]]}], ['control 5', {'bank': 10000, 'book': 10000, 'items': [['deposit_in_transit', 1200], ['deposit_in_transit', 400], ['bank_fee', 90], ['bank_fee', 1200], ['deposit_in_transit', 400]]}, {'adjusted_bank': 12000, 'adjusted_book': 8710, 'reconciled': False, 'entries': [['bank_fee', -90], ['bank_fee', -1200]]}], ['control 6', {'bank': 8000, 'book': 9000, 'items': [['interest', 1200], ['bank_error', 400], ['interest', 400], ['bank_error', 250], ['interest', 400]]}, {'adjusted_bank': 8650, 'adjusted_book': 11000, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 400], ['interest', 400]]}]], [['regression: collection fee netting', {'bank': 8000, 'book': 9000, 'items': [['collection', 4000, 25], ['nsf', 400], ['bank_fee', 15], ['deposit_in_transit', 400]]}, {'adjusted_bank': 8400, 'adjusted_book': 12560, 'reconciled': False, 'entries': [['collection', 3975], ['nsf', -400], ['bank_fee', -15]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 400], ['outstanding_check', 400], ['memo', 15], ['outstanding_check', 250], ['memo', 1200], ['deposit_in_transit', 250]]}, {'adjusted_bank': 8000, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['nsf', 400], ['bank_error', -90], ['bank_fee', 90]]}, {'adjusted_bank': 12410, 'adjusted_book': 8510, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -90]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['memo', 400], ['bank_fee', 1200], ['interest', 90], ['memo', 400], ['interest', 15], ['bank_error', -400], ['memo', 250]]}, {'adjusted_bank': 7600, 'adjusted_book': 10705, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 90], ['interest', 15]]}], ['control 4', {'bank': 10000, 'book': 11800, 'items': [['check_error', 2100, 540], ['nsf', 15], ['interest', 400], ['outstanding_check', 400], ['bank_error', -400], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9215, 'adjusted_book': 13745, 'reconciled': False, 'entries': [['check_error', 1560], ['nsf', -15], ['interest', 400]]}], ['control 5', {'bank': 8000, 'book': 11800, 'items': [['bank_fee', 1200], ['interest', 250], ['bank_error', -1200]]}, {'adjusted_bank': 6800, 'adjusted_book': 10850, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 250]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -250], ['interest', 250], ['check_error', 1200, 1209], ['bank_fee', 90], ['bank_error', -400]]}, {'adjusted_bank': 11850, 'adjusted_book': 9151, 'reconciled': False, 'entries': [['interest', 250], ['check_error', -9], ['bank_fee', -90]]}]], [['regression: collection fee netting', {'bank': 10000, 'book': 11800, 'items': [['collection', 4000, 15], ['outstanding_check', 1200], ['bank_error', 400], ['bank_fee', 1200], ['bank_error', 400]]}, {'adjusted_bank': 9600, 'adjusted_book': 14585, 'reconciled': False, 'entries': [['collection', 3985], ['bank_fee', -1200]]}], ['control 1', {'bank': 10000, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['check_error', 450, 459], ['check_error', 540, 450], ['bank_error', 15]]}, {'adjusted_bank': 11215, 'adjusted_book': 11881, 'reconciled': False, 'entries': [['check_error', -9], ['check_error', 90]]}], ['control 2', {'bank': 8000, 'book': 11800, 'items': [['check_error', 450, 450], ['outstanding_check', 1200], ['bank_error', -400], ['check_error', 2100, 2010]]}, {'adjusted_bank': 6400, 'adjusted_book': 11890, 'reconciled': False, 'entries': [['check_error', 0], ['check_error', 90]]}], ['control 3', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['interest', 250], ['nsf', 250], ['outstanding_check', 400], ['deposit_in_transit', 15], ['collection', 12000, 0]]}, {'adjusted_bank': 10815, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['interest', 250], ['nsf', -250], ['collection', 12000]]}], ['control 4', {'bank': 10000, 'book': 10000, 'items': [['interest', 90], ['memo', 250], ['memo', 15], ['check_error', 540, 540], ['bank_fee', 400]]}, {'adjusted_bank': 10000, 'adjusted_book': 9690, 'reconciled': False, 'entries': [['interest', 90], ['check_error', 0], ['bank_fee', -400]]}], ['control 5', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 250], ['interest', 15], ['bank_error', 90], ['interest', 90], ['collection', 150, 0], ['outstanding_check', 400]]}, {'adjusted_bank': 12440, 'adjusted_book': 10255, 'reconciled': False, 'entries': [['interest', 15], ['interest', 90], ['collection', 150]]}], ['control 6', {'bank': 10000, 'book': 11800, 'items': [['bank_error', 90], ['outstanding_check', 1200], ['collection', 900, 0], ['deposit_in_transit', 1200], ['deposit_in_transit', 15], ['interest', 90], ['check_error', 450, 540]]}, {'adjusted_bank': 10105, 'adjusted_book': 12700, 'reconciled': False, 'entries': [['collection', 900], ['interest', 90], ['check_error', -90]]}]], [['regression: collection fee netting', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 15], ['bank_error', -15], ['nsf', 90], ['collection', 2500, 25], ['outstanding_check', 90], ['collection', 900, 0]]}, {'adjusted_bank': 12410, 'adjusted_book': 13285, 'reconciled': False, 'entries': [['nsf', -90], ['collection', 2475], ['collection', 900]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['collection', 4000, 0], ['bank_error', 400], ['check_error', 450, 459]]}, {'adjusted_bank': 12900, 'adjusted_book': 15791, 'reconciled': False, 'entries': [['collection', 4000], ['check_error', -9]]}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['bank_error', 90]]}, {'adjusted_bank': 12750, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 400], ['deposit_in_transit', 1200], ['memo', 90], ['interest', 250], ['check_error', 540, 540], ['check_error', 2100, 2109], ['interest', 250]]}, {'adjusted_bank': 9600, 'adjusted_book': 10491, 'reconciled': False, 'entries': [['interest', 250], ['check_error', 0], ['check_error', -9], ['interest', 250]]}], ['control 4', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 90], ['bank_error', 15], ['collection', 4000, 0], ['interest', 250]]}, {'adjusted_bank': 8105, 'adjusted_book': 14250, 'reconciled': False, 'entries': [['collection', 4000], ['interest', 250]]}], ['control 5', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -1200], ['memo', 15], ['bank_fee', 15], ['outstanding_check', 400], ['outstanding_check', 400]]}, {'adjusted_bank': 10500, 'adjusted_book': 8985, 'reconciled': False, 'entries': [['bank_fee', -15]]}], ['control 6', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 0]]}, {'adjusted_bank': 8560, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['collection', 12000]]}]], [['regression: collection fee netting', {'bank': 12500, 'book': 10000, 'items': [['outstanding_check', 250], ['collection', 4000, 25], ['check_error', 2100, 450], ['outstanding_check', 250], ['bank_fee', 90], ['interest', 1200], ['outstanding_check', 15]]}, {'adjusted_bank': 11985, 'adjusted_book': 16735, 'reconciled': False, 'entries': [['collection', 3975], ['check_error', 1650], ['bank_fee', -90], ['interest', 1200]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['nsf', 400], ['bank_fee', 250], ['bank_error', 250]]}, {'adjusted_bank': 12750, 'adjusted_book': 11150, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -250]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['outstanding_check', 90], ['memo', 250], ['bank_fee', 15], ['interest', 1200], ['memo', 250], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9925, 'adjusted_book': 11185, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 1200]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['check_error', 450, 459], ['outstanding_check', 400], ['interest', 1200]]}, {'adjusted_bank': 7600, 'adjusted_book': 10191, 'reconciled': False, 'entries': [['check_error', -9], ['interest', 1200]]}], ['control 4', {'bank': 10000, 'book': 11800, 'items': [['bank_error', -250], ['deposit_in_transit', 250], ['bank_fee', 250]]}, {'adjusted_bank': 10000, 'adjusted_book': 11550, 'reconciled': False, 'entries': [['bank_fee', -250]]}], ['control 5', {'bank': 8000, 'book': 10000, 'items': [['collection', 12000, 0], ['interest', 400], ['outstanding_check', 90], ['nsf', 90], ['bank_error', -1200], ['nsf', 400]]}, {'adjusted_bank': 6710, 'adjusted_book': 21910, 'reconciled': False, 'entries': [['collection', 12000], ['interest', 400], ['nsf', -90], ['nsf', -400]]}], ['control 6', {'bank': 8000, 'book': 10000, 'items': [['bank_fee', 15], ['deposit_in_transit', 15], ['outstanding_check', 250]]}, {'adjusted_bank': 7765, 'adjusted_book': 9985, 'reconciled': False, 'entries': [['bank_fee', -15]]}]]]
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)

prompt:
Notes collected by the bank overstate cash by the collection fee.

x = {'bank': statement balance, 'book': ledger cash balance, 'items': [[kind, ...]]}. Bank side: deposit_in_transit adds, outstanding_check subtracts, bank_error adds its signed correction. Book side (each produces an adjusting entry [kind, signed amount] in input order): bank_fee and nsf subtract, interest adds, collection [kind, face, fee] adds face - fee, check_error [kind, recorded, actual] adds recorded - actual. Other kinds are ignored. Return {'adjusted_bank', 'adjusted_book', 'reconciled', 'entries'}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    bank = x['bank']
    book = x['book']
    entries = []
    for item in x['items']:
        kind = item[0]
        if kind == 'deposit_in_transit':
            bank += item[1]
        elif kind == 'outstanding_check':
            bank -= item[1]
        elif kind == 'bank_error':
            bank += item[1]
        else:
            if kind == 'bank_fee' or kind == 'nsf':
                adj = -item[1]
            elif kind == 'interest':
                adj = item[1]
            elif kind == 'collection':
                adj = item[1] - item[2]
            elif kind == 'check_error':
                adj = item[1] - item[2]
            else:
                adj = item[1]
            book += adj
            entries.append([kind, adj])
    return {'adjusted_bank': bank, 'adjusted_book': book, 'reconciled': bank == book, 'entries': entries}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unknown item handling', {'bank': 10000, 'book': 10000, 'items': [['bank_fee', 90], ['interest', 15], ['bank_error', 1200], ['nsf', 1200], ['memo', 250], ['memo', 1200]]}, {'adjusted_bank': 11200, 'adjusted_book': 8725, 'reconciled': False, 'entries': [['bank_fee', -90], ['interest', 15], ['nsf', -1200]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['interest', 15], ['bank_fee', 400], ['check_error', 2100, 450]]}, {'adjusted_bank': 8000, 'adjusted_book': 10265, 'reconciled': False, 'entries': [['interest', 15], ['bank_fee', -400], ['check_error', 1650]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['deposit_in_transit', 1200], ['deposit_in_transit', 400], ['bank_fee', 90], ['bank_fee', 1200], ['deposit_in_transit', 400]]}, {'adjusted_bank': 12000, 'adjusted_book': 8710, 'reconciled': False, 'entries': [['bank_fee', -90], ['bank_fee', -1200]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['interest', 1200], ['bank_error', 400], ['interest', 400], ['bank_error', 250], ['interest', 400]]}, {'adjusted_bank': 8650, 'adjusted_book': 11000, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 400], ['interest', 400]]}], ['control 4', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['collection', 2500, 15], ['outstanding_check', 15], ['check_error', 540, 450], ['check_error', 540, 540], ['check_error', 1200, 1020], ['nsf', 90]]}, {'adjusted_bank': 11185, 'adjusted_book': 11665, 'reconciled': False, 'entries': [['collection', 2485], ['check_error', 90], ['check_error', 0], ['check_error', 180], ['nsf', -90]]}], ['control 5', {'bank': 8000, 'book': 10000, 'items': [['bank_fee', 250], ['deposit_in_transit', 250], ['check_error', 2100, 450], ['deposit_in_transit', 90], ['check_error', 540, 2010], ['deposit_in_transit', 90], ['collection', 2500, 15]]}, {'adjusted_bank': 8430, 'adjusted_book': 12415, 'reconciled': False, 'entries': [['bank_fee', -250], ['check_error', 1650], ['check_error', -1470], ['collection', 2485]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['collection', 12000, 0], ['check_error', 1200, 1020]]}, {'adjusted_bank': 12750, 'adjusted_book': 21180, 'reconciled': False, 'entries': [['collection', 12000], ['check_error', 180]]}]], [['regression: unknown item handling', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 400], ['outstanding_check', 400], ['memo', 15], ['outstanding_check', 250], ['memo', 1200], ['deposit_in_transit', 250]]}, {'adjusted_bank': 8000, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 1', {'bank': 12500, 'book': 9000, 'items': [['nsf', 400], ['bank_error', -90], ['bank_fee', 90]]}, {'adjusted_bank': 12410, 'adjusted_book': 8510, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -90]]}], ['control 2', {'bank': 10000, 'book': 11800, 'items': [['check_error', 2100, 540], ['nsf', 15], ['interest', 400], ['outstanding_check', 400], ['bank_error', -400], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9215, 'adjusted_book': 13745, 'reconciled': False, 'entries': [['check_error', 1560], ['nsf', -15], ['interest', 400]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['bank_fee', 1200], ['interest', 250], ['bank_error', -1200]]}, {'adjusted_bank': 6800, 'adjusted_book': 10850, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 250]]}], ['control 4', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -250], ['interest', 250], ['check_error', 1200, 1209], ['bank_fee', 90], ['bank_error', -400]]}, {'adjusted_bank': 11850, 'adjusted_book': 9151, 'reconciled': False, 'entries': [['interest', 250], ['check_error', -9], ['bank_fee', -90]]}], ['control 5', {'bank': 8000, 'book': 9000, 'items': [['collection', 4000, 25], ['nsf', 400], ['bank_fee', 15], ['deposit_in_transit', 400]]}, {'adjusted_bank': 8400, 'adjusted_book': 12560, 'reconciled': False, 'entries': [['collection', 3975], ['nsf', -400], ['bank_fee', -15]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['bank_error', 90], ['deposit_in_transit', 400], ['bank_error', -400], ['outstanding_check', 400]]}, {'adjusted_bank': 12190, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}]], [['regression: unknown item handling', {'bank': 10000, 'book': 9000, 'items': [['collection', 150, 15], ['nsf', 15], ['deposit_in_transit', 90], ['memo', 1200], ['collection', 900, 25], ['interest', 90], ['deposit_in_transit', 400]]}, {'adjusted_bank': 10490, 'adjusted_book': 10085, 'reconciled': False, 'entries': [['collection', 135], ['nsf', -15], ['collection', 875], ['interest', 90]]}], ['control 1', {'bank': 10000, 'book': 11800, 'items': [['collection', 4000, 15], ['outstanding_check', 1200], ['bank_error', 400], ['bank_fee', 1200], ['bank_error', 400]]}, {'adjusted_bank': 9600, 'adjusted_book': 14585, 'reconciled': False, 'entries': [['collection', 3985], ['bank_fee', -1200]]}], ['control 2', {'bank': 10000, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['check_error', 450, 459], ['check_error', 540, 450], ['bank_error', 15]]}, {'adjusted_bank': 11215, 'adjusted_book': 11881, 'reconciled': False, 'entries': [['check_error', -9], ['check_error', 90]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['check_error', 450, 450], ['outstanding_check', 1200], ['bank_error', -400], ['check_error', 2100, 2010]]}, {'adjusted_bank': 6400, 'adjusted_book': 11890, 'reconciled': False, 'entries': [['check_error', 0], ['check_error', 90]]}], ['control 4', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['interest', 250], ['nsf', 250], ['outstanding_check', 400], ['deposit_in_transit', 15], ['collection', 12000, 0]]}, {'adjusted_bank': 10815, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['interest', 250], ['nsf', -250], ['collection', 12000]]}], ['control 5', {'bank': 12500, 'book': 11800, 'items': [['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 15], ['deposit_in_transit', 90], ['bank_error', 250], ['check_error', 540, 540]]}, {'adjusted_bank': 13150, 'adjusted_book': 23785, 'reconciled': False, 'entries': [['collection', 11985], ['check_error', 0]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 250], ['interest', 15], ['bank_error', 90], ['interest', 90], ['collection', 150, 0], ['outstanding_check', 400]]}, {'adjusted_bank': 12440, 'adjusted_book': 10255, 'reconciled': False, 'entries': [['interest', 15], ['interest', 90], ['collection', 150]]}]], [['regression: unknown item handling', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 400], ['deposit_in_transit', 1200], ['memo', 90], ['interest', 250], ['check_error', 540, 540], ['check_error', 2100, 2109], ['interest', 250]]}, {'adjusted_bank': 9600, 'adjusted_book': 10491, 'reconciled': False, 'entries': [['interest', 250], ['check_error', 0], ['check_error', -9], ['interest', 250]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['collection', 4000, 0], ['bank_error', 400], ['check_error', 450, 459]]}, {'adjusted_bank': 12900, 'adjusted_book': 15791, 'reconciled': False, 'entries': [['collection', 4000], ['check_error', -9]]}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['bank_error', 90]]}, {'adjusted_bank': 12750, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 3', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 15], ['bank_error', -15], ['nsf', 90], ['collection', 2500, 25], ['outstanding_check', 90], ['collection', 900, 0]]}, {'adjusted_bank': 12410, 'adjusted_book': 13285, 'reconciled': False, 'entries': [['nsf', -90], ['collection', 2475], ['collection', 900]]}], ['control 4', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 90], ['bank_error', 15], ['collection', 4000, 0], ['interest', 250]]}, {'adjusted_bank': 8105, 'adjusted_book': 14250, 'reconciled': False, 'entries': [['collection', 4000], ['interest', 250]]}], ['control 5', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 0]]}, {'adjusted_bank': 8560, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['collection', 12000]]}], ['control 6', {'bank': 12500, 'book': 11800, 'items': [['interest', 1200], ['check_error', 450, 1020], ['bank_fee', 15], ['nsf', 250], ['collection', 150, 0]]}, {'adjusted_bank': 12500, 'adjusted_book': 12315, 'reconciled': False, 'entries': [['interest', 1200], ['check_error', -570], ['bank_fee', -15], ['nsf', -250], ['collection', 150]]}]], [['regression: unknown item handling', {'bank': 10000, 'book': 10000, 'items': [['outstanding_check', 90], ['memo', 250], ['bank_fee', 15], ['interest', 1200], ['memo', 250], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9925, 'adjusted_book': 11185, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 1200]]}], ['control 1', {'bank': 12500, 'book': 10000, 'items': [['outstanding_check', 250], ['collection', 4000, 25], ['check_error', 2100, 450], ['outstanding_check', 250], ['bank_fee', 90], ['interest', 1200], ['outstanding_check', 15]]}, {'adjusted_bank': 11985, 'adjusted_book': 16735, 'reconciled': False, 'entries': [['collection', 3975], ['check_error', 1650], ['bank_fee', -90], ['interest', 1200]]}], ['control 2', {'bank': 12500, 'book': 11800, 'items': [['nsf', 400], ['bank_fee', 250], ['bank_error', 250]]}, {'adjusted_bank': 12750, 'adjusted_book': 11150, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -250]]}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['nsf', 1200], ['collection', 4000, 15], ['interest', 400]]}, {'adjusted_bank': 8000, 'adjusted_book': 13185, 'reconciled': False, 'entries': [['nsf', -1200], ['collection', 3985], ['interest', 400]]}], ['control 4', {'bank': 8000, 'book': 9000, 'items': [['check_error', 450, 459], ['outstanding_check', 400], ['interest', 1200]]}, {'adjusted_bank': 7600, 'adjusted_book': 10191, 'reconciled': False, 'entries': [['check_error', -9], ['interest', 1200]]}], ['control 5', {'bank': 10000, 'book': 11800, 'items': [['bank_error', -250], ['deposit_in_transit', 250], ['bank_fee', 250]]}, {'adjusted_bank': 10000, 'adjusted_book': 11550, 'reconciled': False, 'entries': [['bank_fee', -250]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['bank_error', -15], ['collection', 150, 25], ['nsf', 400], ['nsf', 15], ['collection', 2500, 0], ['interest', 1200]]}, {'adjusted_bank': 12485, 'adjusted_book': 13410, 'reconciled': False, 'entries': [['collection', 125], ['nsf', -400], ['nsf', -15], ['collection', 2500], ['interest', 1200]]}]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    bank = x['bank']
    book = x['book']
    entries = []
    for item in x['items']:
        kind = item[0]
        if kind == 'deposit_in_transit':
            bank += item[1]
        elif kind == 'outstanding_check':
            bank -= item[1]
        elif kind == 'bank_error':
            bank += item[1]
        else:
            if kind == 'bank_fee' or kind == 'nsf':
                adj = -item[1]
            elif kind == 'interest':
                adj = item[1]
            elif kind == 'collection':
                adj = item[1] - item[2]
            elif kind == 'check_error':
                adj = item[1] - item[2]
            else:
                adj = 0
            book += adj
            entries.append([kind, adj])
    return {'adjusted_bank': bank, 'adjusted_book': book, 'reconciled': bank == book, 'entries': entries}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unknown item handling', {'bank': 10000, 'book': 10000, 'items': [['bank_fee', 90], ['interest', 15], ['bank_error', 1200], ['nsf', 1200], ['memo', 250], ['memo', 1200]]}, {'adjusted_bank': 11200, 'adjusted_book': 8725, 'reconciled': False, 'entries': [['bank_fee', -90], ['interest', 15], ['nsf', -1200]]}], ['control 1', {'bank': 8000, 'book': 9000, 'items': [['interest', 15], ['bank_fee', 400], ['check_error', 2100, 450]]}, {'adjusted_bank': 8000, 'adjusted_book': 10265, 'reconciled': False, 'entries': [['interest', 15], ['bank_fee', -400], ['check_error', 1650]]}], ['control 2', {'bank': 10000, 'book': 10000, 'items': [['deposit_in_transit', 1200], ['deposit_in_transit', 400], ['bank_fee', 90], ['bank_fee', 1200], ['deposit_in_transit', 400]]}, {'adjusted_bank': 12000, 'adjusted_book': 8710, 'reconciled': False, 'entries': [['bank_fee', -90], ['bank_fee', -1200]]}], ['control 3', {'bank': 8000, 'book': 9000, 'items': [['interest', 1200], ['bank_error', 400], ['interest', 400], ['bank_error', 250], ['interest', 400]]}, {'adjusted_bank': 8650, 'adjusted_book': 11000, 'reconciled': False, 'entries': [['interest', 1200], ['interest', 400], ['interest', 400]]}], ['control 4', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['collection', 2500, 15], ['outstanding_check', 15], ['check_error', 540, 450], ['check_error', 540, 540], ['check_error', 1200, 1020], ['nsf', 90]]}, {'adjusted_bank': 11185, 'adjusted_book': 11665, 'reconciled': False, 'entries': [['collection', 2485], ['check_error', 90], ['check_error', 0], ['check_error', 180], ['nsf', -90]]}], ['control 5', {'bank': 8000, 'book': 10000, 'items': [['bank_fee', 250], ['deposit_in_transit', 250], ['check_error', 2100, 450], ['deposit_in_transit', 90], ['check_error', 540, 2010], ['deposit_in_transit', 90], ['collection', 2500, 15]]}, {'adjusted_bank': 8430, 'adjusted_book': 12415, 'reconciled': False, 'entries': [['bank_fee', -250], ['check_error', 1650], ['check_error', -1470], ['collection', 2485]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['collection', 12000, 0], ['check_error', 1200, 1020]]}, {'adjusted_bank': 12750, 'adjusted_book': 21180, 'reconciled': False, 'entries': [['collection', 12000], ['check_error', 180]]}]], [['regression: unknown item handling', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 400], ['outstanding_check', 400], ['memo', 15], ['outstanding_check', 250], ['memo', 1200], ['deposit_in_transit', 250]]}, {'adjusted_bank': 8000, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 1', {'bank': 12500, 'book': 9000, 'items': [['nsf', 400], ['bank_error', -90], ['bank_fee', 90]]}, {'adjusted_bank': 12410, 'adjusted_book': 8510, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -90]]}], ['control 2', {'bank': 10000, 'book': 11800, 'items': [['check_error', 2100, 540], ['nsf', 15], ['interest', 400], ['outstanding_check', 400], ['bank_error', -400], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9215, 'adjusted_book': 13745, 'reconciled': False, 'entries': [['check_error', 1560], ['nsf', -15], ['interest', 400]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['bank_fee', 1200], ['interest', 250], ['bank_error', -1200]]}, {'adjusted_bank': 6800, 'adjusted_book': 10850, 'reconciled': False, 'entries': [['bank_fee', -1200], ['interest', 250]]}], ['control 4', {'bank': 12500, 'book': 9000, 'items': [['bank_error', -250], ['interest', 250], ['check_error', 1200, 1209], ['bank_fee', 90], ['bank_error', -400]]}, {'adjusted_bank': 11850, 'adjusted_book': 9151, 'reconciled': False, 'entries': [['interest', 250], ['check_error', -9], ['bank_fee', -90]]}], ['control 5', {'bank': 8000, 'book': 9000, 'items': [['collection', 4000, 25], ['nsf', 400], ['bank_fee', 15], ['deposit_in_transit', 400]]}, {'adjusted_bank': 8400, 'adjusted_book': 12560, 'reconciled': False, 'entries': [['collection', 3975], ['nsf', -400], ['bank_fee', -15]]}], ['control 6', {'bank': 12500, 'book': 9000, 'items': [['bank_error', 90], ['deposit_in_transit', 400], ['bank_error', -400], ['outstanding_check', 400]]}, {'adjusted_bank': 12190, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}]], [['regression: unknown item handling', {'bank': 10000, 'book': 9000, 'items': [['collection', 150, 15], ['nsf', 15], ['deposit_in_transit', 90], ['memo', 1200], ['collection', 900, 25], ['interest', 90], ['deposit_in_transit', 400]]}, {'adjusted_bank': 10490, 'adjusted_book': 10085, 'reconciled': False, 'entries': [['collection', 135], ['nsf', -15], ['collection', 875], ['interest', 90]]}], ['control 1', {'bank': 10000, 'book': 11800, 'items': [['collection', 4000, 15], ['outstanding_check', 1200], ['bank_error', 400], ['bank_fee', 1200], ['bank_error', 400]]}, {'adjusted_bank': 9600, 'adjusted_book': 14585, 'reconciled': False, 'entries': [['collection', 3985], ['bank_fee', -1200]]}], ['control 2', {'bank': 10000, 'book': 11800, 'items': [['deposit_in_transit', 1200], ['check_error', 450, 459], ['check_error', 540, 450], ['bank_error', 15]]}, {'adjusted_bank': 11215, 'adjusted_book': 11881, 'reconciled': False, 'entries': [['check_error', -9], ['check_error', 90]]}], ['control 3', {'bank': 8000, 'book': 11800, 'items': [['check_error', 450, 450], ['outstanding_check', 1200], ['bank_error', -400], ['check_error', 2100, 2010]]}, {'adjusted_bank': 6400, 'adjusted_book': 11890, 'reconciled': False, 'entries': [['check_error', 0], ['check_error', 90]]}], ['control 4', {'bank': 10000, 'book': 9000, 'items': [['deposit_in_transit', 1200], ['interest', 250], ['nsf', 250], ['outstanding_check', 400], ['deposit_in_transit', 15], ['collection', 12000, 0]]}, {'adjusted_bank': 10815, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['interest', 250], ['nsf', -250], ['collection', 12000]]}], ['control 5', {'bank': 12500, 'book': 11800, 'items': [['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 15], ['deposit_in_transit', 90], ['bank_error', 250], ['check_error', 540, 540]]}, {'adjusted_bank': 13150, 'adjusted_book': 23785, 'reconciled': False, 'entries': [['collection', 11985], ['check_error', 0]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 250], ['interest', 15], ['bank_error', 90], ['interest', 90], ['collection', 150, 0], ['outstanding_check', 400]]}, {'adjusted_bank': 12440, 'adjusted_book': 10255, 'reconciled': False, 'entries': [['interest', 15], ['interest', 90], ['collection', 150]]}]], [['regression: unknown item handling', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 400], ['deposit_in_transit', 1200], ['memo', 90], ['interest', 250], ['check_error', 540, 540], ['check_error', 2100, 2109], ['interest', 250]]}, {'adjusted_bank': 9600, 'adjusted_book': 10491, 'reconciled': False, 'entries': [['interest', 250], ['check_error', 0], ['check_error', -9], ['interest', 250]]}], ['control 1', {'bank': 12500, 'book': 11800, 'items': [['collection', 4000, 0], ['bank_error', 400], ['check_error', 450, 459]]}, {'adjusted_bank': 12900, 'adjusted_book': 15791, 'reconciled': False, 'entries': [['collection', 4000], ['check_error', -9]]}], ['control 2', {'bank': 12500, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['bank_error', 90]]}, {'adjusted_bank': 12750, 'adjusted_book': 9000, 'reconciled': False, 'entries': []}], ['control 3', {'bank': 12500, 'book': 10000, 'items': [['deposit_in_transit', 15], ['bank_error', -15], ['nsf', 90], ['collection', 2500, 25], ['outstanding_check', 90], ['collection', 900, 0]]}, {'adjusted_bank': 12410, 'adjusted_book': 13285, 'reconciled': False, 'entries': [['nsf', -90], ['collection', 2475], ['collection', 900]]}], ['control 4', {'bank': 8000, 'book': 10000, 'items': [['deposit_in_transit', 90], ['bank_error', 15], ['collection', 4000, 0], ['interest', 250]]}, {'adjusted_bank': 8105, 'adjusted_book': 14250, 'reconciled': False, 'entries': [['collection', 4000], ['interest', 250]]}], ['control 5', {'bank': 8000, 'book': 9000, 'items': [['deposit_in_transit', 250], ['bank_error', -90], ['deposit_in_transit', 400], ['collection', 12000, 0]]}, {'adjusted_bank': 8560, 'adjusted_book': 21000, 'reconciled': False, 'entries': [['collection', 12000]]}], ['control 6', {'bank': 12500, 'book': 11800, 'items': [['interest', 1200], ['check_error', 450, 1020], ['bank_fee', 15], ['nsf', 250], ['collection', 150, 0]]}, {'adjusted_bank': 12500, 'adjusted_book': 12315, 'reconciled': False, 'entries': [['interest', 1200], ['check_error', -570], ['bank_fee', -15], ['nsf', -250], ['collection', 150]]}]], [['regression: unknown item handling', {'bank': 10000, 'book': 10000, 'items': [['outstanding_check', 90], ['memo', 250], ['bank_fee', 15], ['interest', 1200], ['memo', 250], ['deposit_in_transit', 15]]}, {'adjusted_bank': 9925, 'adjusted_book': 11185, 'reconciled': False, 'entries': [['bank_fee', -15], ['interest', 1200]]}], ['control 1', {'bank': 12500, 'book': 10000, 'items': [['outstanding_check', 250], ['collection', 4000, 25], ['check_error', 2100, 450], ['outstanding_check', 250], ['bank_fee', 90], ['interest', 1200], ['outstanding_check', 15]]}, {'adjusted_bank': 11985, 'adjusted_book': 16735, 'reconciled': False, 'entries': [['collection', 3975], ['check_error', 1650], ['bank_fee', -90], ['interest', 1200]]}], ['control 2', {'bank': 12500, 'book': 11800, 'items': [['nsf', 400], ['bank_fee', 250], ['bank_error', 250]]}, {'adjusted_bank': 12750, 'adjusted_book': 11150, 'reconciled': False, 'entries': [['nsf', -400], ['bank_fee', -250]]}], ['control 3', {'bank': 8000, 'book': 10000, 'items': [['nsf', 1200], ['collection', 4000, 15], ['interest', 400]]}, {'adjusted_bank': 8000, 'adjusted_book': 13185, 'reconciled': False, 'entries': [['nsf', -1200], ['collection', 3985], ['interest', 400]]}], ['control 4', {'bank': 8000, 'book': 9000, 'items': [['check_error', 450, 459], ['outstanding_check', 400], ['interest', 1200]]}, {'adjusted_bank': 7600, 'adjusted_book': 10191, 'reconciled': False, 'entries': [['check_error', -9], ['interest', 1200]]}], ['control 5', {'bank': 10000, 'book': 11800, 'items': [['bank_error', -250], ['deposit_in_transit', 250], ['bank_fee', 250]]}, {'adjusted_bank': 10000, 'adjusted_book': 11550, 'reconciled': False, 'entries': [['bank_fee', -250]]}], ['control 6', {'bank': 12500, 'book': 10000, 'items': [['bank_error', -15], ['collection', 150, 25], ['nsf', 400], ['nsf', 15], ['collection', 2500, 0], ['interest', 1200]]}, {'adjusted_bank': 12485, 'adjusted_book': 13410, 'reconciled': False, 'entries': [['collection', 125], ['nsf', -400], ['nsf', -15], ['collection', 2500], ['interest', 1200]]}]]]
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)

prompt:
Informational memo lines generate book adjustments.

x = {'bank': statement balance, 'book': ledger cash balance, 'items': [[kind, ...]]}. Bank side: deposit_in_transit adds, outstanding_check subtracts, bank_error adds its signed correction. Book side (each produces an adjusting entry [kind, signed amount] in input order): bank_fee and nsf subtract, interest adds, collection [kind, face, fee] adds face - fee, check_error [kind, recorded, actual] adds recorded - actual. Other kinds are ignored. Return {'adjusted_bank', 'adjusted_book', 'reconciled', 'entries'}.

split: open-access