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

N = 1
observations = []
def solve(x):
    gross = 0
    dw = 0
    di = 0.0
    for kind, wt, idx in x['changes']:
        s = 1 if kind == 'add' else -1
        gross += wt
        dw += s * wt
        di += s * idx
    if gross > x['max_lmc_weight'] or abs(di) > x['max_lmc_index']: return 'NEW_LOADSHEET'
    tow = x['tow'] + dw
    ti = x['index'] + di
    lo, hi = x['index_limits']
    if tow > x['mtow'] or x['index'] < lo or x['index'] > hi: return 'NEW_LOADSHEET'
    return ['LMC', tow, round(ti, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 171, 1.5], ['add', 85, 0.8]]}, ['LMC', 68256, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 291, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.1]]}, ['LMC', 67800, 48.9]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 151, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.1]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 0.5]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 64100, 'mtow': 70000, 'index': 45.9, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['remove', 180, 3.4], ['remove', 155, -2.5], ['add', 35, -3.5], ['add', 345, 3.7]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 68550, 'mtow': 70000, 'index': 33.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 3.0, 'changes': [['add', 340, -1.0], ['remove', 260, 1.2]]}, 'NEW_LOADSHEET'], ['sampled case 3', {'tow': 61300, 'mtow': 70000, 'index': 42.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 3.0, 'changes': [['add', 350, -3.5], ['remove', 30, -2.6], ['add', 230, 1.5]]}, 'NEW_LOADSHEET']], [['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 172, 1.5], ['add', 85, 0.8]]}, ['LMC', 68257, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 292, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.2]]}, ['LMC', 67800, 48.8]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 152, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.2]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 1.0]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 68750, 'mtow': 70000, 'index': 62.6, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['add', 275, -2.1], ['add', 25, -1.8]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 64950, 'mtow': 70000, 'index': 44.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 600, 'max_lmc_index': 3.0, 'changes': [['add', 385, 2.3]]}, ['LMC', 65335, 46.8]], ['sampled case 3', {'tow': 65950, 'mtow': 70000, 'index': 59.8, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['remove', 170, 1.7]]}, ['LMC', 65780, 58.1]]], [['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 173, 1.5], ['add', 85, 0.8]]}, ['LMC', 68258, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 293, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.3]]}, ['LMC', 67800, 48.7]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 153, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.3]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 1.5]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 64750, 'mtow': 70000, 'index': 33.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['remove', 20, 2.4], ['remove', 125, -3.9], ['remove', 190, 3.9], ['remove', 270, 3.3]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 63200, 'mtow': 70000, 'index': 47.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 5.0, 'changes': [['remove', 335, -0.9], ['add', 105, 3.3]]}, 'NEW_LOADSHEET'], ['sampled case 3', {'tow': 66200, 'mtow': 70000, 'index': 38.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 3.0, 'changes': [['add', 150, -0.8], ['add', 95, 1.5], ['add', 140, -2.4], ['add', 150, -0.8]]}, 'NEW_LOADSHEET']], [['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 174, 1.5], ['add', 85, 0.8]]}, ['LMC', 68259, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 294, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.4]]}, ['LMC', 67800, 48.6]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 154, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.4]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 2.0]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 66150, 'mtow': 70000, 'index': 46.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 3.0, 'changes': [['add', 390, 0.4], ['remove', 40, 2.1], ['add', 300, 3.5]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 64000, 'mtow': 70000, 'index': 30.4, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['remove', 350, 3.5], ['remove', 60, 0.9]]}, 'NEW_LOADSHEET'], ['sampled case 3', {'tow': 60650, 'mtow': 70000, 'index': 63.7, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 295, -2.6]]}, ['LMC', 60945, 61.1]]], [['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 175, 1.5], ['add', 85, 0.8]]}, ['LMC', 68260, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 295, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.5]]}, ['LMC', 67800, 48.5]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 155, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.5]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 2.5]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 69850, 'mtow': 70000, 'index': 46.3, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 600, 'max_lmc_index': 5.0, 'changes': [['add', 195, -0.8], ['add', 240, -1.5]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 69600, 'mtow': 70000, 'index': 31.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 600, 'max_lmc_index': 3.0, 'changes': [['add', 180, 3.5], ['remove', 165, 3.5]]}, ['LMC', 69615, 31.5]], ['sampled case 3', {'tow': 61550, 'mtow': 70000, 'index': 46.4, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 600, 'max_lmc_index': 5.0, 'changes': [['remove', 340, 1.9], ['remove', 260, -0.5]]}, ['LMC', 60950, 45.0]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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):
    gross = 0
    dw = 0
    di = 0.0
    for kind, wt, idx in x['changes']:
        s = 1 if kind == 'add' else -1
        gross += wt
        dw += s * wt
        di += s * idx
    if gross > x['max_lmc_weight'] or abs(di) > x['max_lmc_index']: return 'NEW_LOADSHEET'
    tow = x['tow'] + dw
    ti = x['index'] + di
    lo, hi = x['index_limits']
    if tow > x['mtow'] or ti < lo: return 'NEW_LOADSHEET'
    return ['LMC', tow, round(ti, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 171, 1.5], ['add', 85, 0.8]]}, ['LMC', 68256, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 291, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.1]]}, ['LMC', 67800, 48.9]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 151, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.1]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 0.5]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 64100, 'mtow': 70000, 'index': 45.9, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['remove', 180, 3.4], ['remove', 155, -2.5], ['add', 35, -3.5], ['add', 345, 3.7]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 68550, 'mtow': 70000, 'index': 33.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 3.0, 'changes': [['add', 340, -1.0], ['remove', 260, 1.2]]}, 'NEW_LOADSHEET'], ['sampled case 3', {'tow': 61300, 'mtow': 70000, 'index': 42.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 3.0, 'changes': [['add', 350, -3.5], ['remove', 30, -2.6], ['add', 230, 1.5]]}, 'NEW_LOADSHEET']], [['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 172, 1.5], ['add', 85, 0.8]]}, ['LMC', 68257, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 292, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.2]]}, ['LMC', 67800, 48.8]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 152, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.2]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 1.0]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 68750, 'mtow': 70000, 'index': 62.6, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['add', 275, -2.1], ['add', 25, -1.8]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 64950, 'mtow': 70000, 'index': 44.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 600, 'max_lmc_index': 3.0, 'changes': [['add', 385, 2.3]]}, ['LMC', 65335, 46.8]], ['sampled case 3', {'tow': 65950, 'mtow': 70000, 'index': 59.8, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['remove', 170, 1.7]]}, ['LMC', 65780, 58.1]]], [['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 173, 1.5], ['add', 85, 0.8]]}, ['LMC', 68258, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 293, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.3]]}, ['LMC', 67800, 48.7]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 153, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.3]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 1.5]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 64750, 'mtow': 70000, 'index': 33.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['remove', 20, 2.4], ['remove', 125, -3.9], ['remove', 190, 3.9], ['remove', 270, 3.3]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 63200, 'mtow': 70000, 'index': 47.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 5.0, 'changes': [['remove', 335, -0.9], ['add', 105, 3.3]]}, 'NEW_LOADSHEET'], ['sampled case 3', {'tow': 66200, 'mtow': 70000, 'index': 38.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 3.0, 'changes': [['add', 150, -0.8], ['add', 95, 1.5], ['add', 140, -2.4], ['add', 150, -0.8]]}, 'NEW_LOADSHEET']], [['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 174, 1.5], ['add', 85, 0.8]]}, ['LMC', 68259, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 294, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.4]]}, ['LMC', 67800, 48.6]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 154, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.4]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 2.0]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 66150, 'mtow': 70000, 'index': 46.1, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 400, 'max_lmc_index': 3.0, 'changes': [['add', 390, 0.4], ['remove', 40, 2.1], ['add', 300, 3.5]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 64000, 'mtow': 70000, 'index': 30.4, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 3.0, 'changes': [['remove', 350, 3.5], ['remove', 60, 0.9]]}, 'NEW_LOADSHEET'], ['sampled case 3', {'tow': 60650, 'mtow': 70000, 'index': 63.7, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 295, -2.6]]}, ['LMC', 60945, 61.1]]], [['two late passengers', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 175, 1.5], ['add', 85, 0.8]]}, ['LMC', 68260, 54.3]], ['swap cancels net', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 300, 2.0], ['remove', 295, 1.9]]}, 'NEW_LOADSHEET'], ['exactly at weight tolerance', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 250, 1.0], ['add', 250, 1.0]]}, ['LMC', 68500, 54.0]], ['offload moves index', {'tow': 68000, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 200, 3.5]]}, ['LMC', 67800, 48.5]], ['change pushes over MTOW', {'tow': 69900, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 155, 0.5]]}, 'NEW_LOADSHEET'], ['change pushes index out', {'tow': 68000, 'mtow': 70000, 'index': 68.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['add', 100, 2.5]]}, 'NEW_LOADSHEET'], ['already heavy then offload', {'tow': 70200, 'mtow': 70000, 'index': 52.0, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 500, 'max_lmc_index': 5.0, 'changes': [['remove', 150, 2.5]]}, 'NEW_LOADSHEET'], ['sampled case 1', {'tow': 69850, 'mtow': 70000, 'index': 46.3, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 600, 'max_lmc_index': 5.0, 'changes': [['add', 195, -0.8], ['add', 240, -1.5]]}, 'NEW_LOADSHEET'], ['sampled case 2', {'tow': 69600, 'mtow': 70000, 'index': 31.5, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 600, 'max_lmc_index': 3.0, 'changes': [['add', 180, 3.5], ['remove', 165, 3.5]]}, ['LMC', 69615, 31.5]], ['sampled case 3', {'tow': 61550, 'mtow': 70000, 'index': 46.4, 'index_limits': [30.0, 70.0], 'max_lmc_weight': 600, 'max_lmc_index': 5.0, 'changes': [['remove', 340, 1.9], ['remove', 260, -0.5]]}, ['LMC', 60950, 45.0]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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 late aft-hold bag that pushes the index past the aft limit is accepted.

Input {'tow','mtow','index','index_limits','max_lmc_weight','max_lmc_index','changes':[['add'|'remove', kg, index effect of adding]]}. The weight tolerance applies to the gross sum of all changed weights (<= limit allowed); removals negate weight and index; |net index| <= limit. Then new TOW <= MTOW and new index within inclusive limits, else 'NEW_LOADSHEET'. Return ['LMC', new TOW, new index r1].

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
Aft-loaded aircraft show heavy nose-wheel loads and forward-loaded aircraft show light ones.

Input {'items':[[lb,arm]],'main_arm','nose_arm'}. CG at or aft of the main gear -> ['TIP', CG r2]. Otherwise nose reaction = W*(main-CG)/(main-nose), main = W - nose; status 'LIGHT_NOSE' if nose < 5% of total weight else 'OK'. Return [status, nose r1, main r1].

split: open-access


prompt:
An aircraft balanced exactly on the mains is reported LIGHT_NOSE with zero nose load instead of TIP.

Input {'items':[[lb,arm]],'main_arm','nose_arm'}. CG at or aft of the main gear -> ['TIP', CG r2]. Otherwise nose reaction = W*(main-CG)/(main-nose), main = W - nose; status 'LIGHT_NOSE' if nose < 5% of total weight else 'OK'. Return [status, nose r1, main r1].

split: open-access


prompt:
Aircraft with a nose load slightly under 5% of gross weight are reported OK.

Input {'items':[[lb,arm]],'main_arm','nose_arm'}. CG at or aft of the main gear -> ['TIP', CG r2]. Otherwise nose reaction = W*(main-CG)/(main-nose), main = W - nose; status 'LIGHT_NOSE' if nose < 5% of total weight else 'OK'. Return [status, nose r1, main r1].

split: open-access


prompt:
Nose and main reactions add up to more than the aircraft weight.

Input {'items':[[lb,arm]],'main_arm','nose_arm'}. CG at or aft of the main gear -> ['TIP', CG r2]. Otherwise nose reaction = W*(main-CG)/(main-nose), main = W - nose; status 'LIGHT_NOSE' if nose < 5% of total weight else 'OK'. Return [status, nose r1, main r1].

split: open-access


prompt:
A light item far aft moves the computed CG as much as the airframe itself.

Input {'items':[[lb,arm]],'main_arm','nose_arm'}. CG at or aft of the main gear -> ['TIP', CG r2]. Otherwise nose reaction = W*(main-CG)/(main-nose), main = W - nose; status 'LIGHT_NOSE' if nose < 5% of total weight else 'OK'. Return [status, nose r1, main r1].

split: open-access


prompt:
Basic empty weight matches the scale sheet but the empty-weight arm is shifted toward the heavily chocked wheel.

Input {'scales':[[position, reading lb, tare lb, arm]],'unusable_gal','fuel_arm','oil_qt','oil_arm','oil_drained'}. Aircraft weighed defueled, so unusable fuel (6.0 lb/gal) is added; full oil (1.875 lb per quart) is added only if the oil was drained for weighing. Return [basic empty weight r1, arm r2].

split: open-access


prompt:
Weighings done with full oil show the oil counted twice, and drained weighings show none.

Input {'scales':[[position, reading lb, tare lb, arm]],'unusable_gal','fuel_arm','oil_qt','oil_arm','oil_drained'}. Aircraft weighed defueled, so unusable fuel (6.0 lb/gal) is added; full oil (1.875 lb per quart) is added only if the oil was drained for weighing. Return [basic empty weight r1, arm r2].

split: open-access


prompt:
The drained-oil correction is four times too heavy.

Input {'scales':[[position, reading lb, tare lb, arm]],'unusable_gal','fuel_arm','oil_qt','oil_arm','oil_drained'}. Aircraft weighed defueled, so unusable fuel (6.0 lb/gal) is added; full oil (1.875 lb per quart) is added only if the oil was drained for weighing. Return [basic empty weight r1, arm r2].

split: open-access


prompt:
Basic empty weight is lighter than the scale readings even though fuel was drained.

Input {'scales':[[position, reading lb, tare lb, arm]],'unusable_gal','fuel_arm','oil_qt','oil_arm','oil_drained'}. Aircraft weighed defueled, so unusable fuel (6.0 lb/gal) is added; full oil (1.875 lb per quart) is added only if the oil was drained for weighing. Return [basic empty weight r1, arm r2].

split: open-access


prompt:
Low-pressure days compute a lower pressure altitude and more allowable weight.

Input {'elev_ft','altimeter' inHg,'oat_c','mtow'}. Pressure altitude = elev + (29.92 - altimeter)*1000; ISA temp = 15 - 2 per 1000 ft of PA; DA = PA + 120*(OAT - ISA). Allowed weight = MTOW - 20 lb per 1000 ft (pro rata) of DA above 3000 ft, rounded DOWN to 10 lb. Return [DA rounded, allowed].

split: open-access


prompt:
Density altitude is off whenever the altimeter differs from standard.

Input {'elev_ft','altimeter' inHg,'oat_c','mtow'}. Pressure altitude = elev + (29.92 - altimeter)*1000; ISA temp = 15 - 2 per 1000 ft of PA; DA = PA + 120*(OAT - ISA). Allowed weight = MTOW - 20 lb per 1000 ft (pro rata) of DA above 3000 ft, rounded DOWN to 10 lb. Return [DA rounded, allowed].

split: open-access


prompt:
Crossing 3000 ft DA suddenly removes 60 lb of allowable weight.

Input {'elev_ft','altimeter' inHg,'oat_c','mtow'}. Pressure altitude = elev + (29.92 - altimeter)*1000; ISA temp = 15 - 2 per 1000 ft of PA; DA = PA + 120*(OAT - ISA). Allowed weight = MTOW - 20 lb per 1000 ft (pro rata) of DA above 3000 ft, rounded DOWN to 10 lb. Return [DA rounded, allowed].

split: open-access


prompt:
The published allowable weight is a few pounds above the computed derated limit.

Input {'elev_ft','altimeter' inHg,'oat_c','mtow'}. Pressure altitude = elev + (29.92 - altimeter)*1000; ISA temp = 15 - 2 per 1000 ft of PA; DA = PA + 120*(OAT - ISA). Allowed weight = MTOW - 20 lb per 1000 ft (pro rata) of DA above 3000 ft, rounded DOWN to 10 lb. Return [DA rounded, allowed].

split: open-access


prompt:
A density altitude of 4990 ft gets the same reduction as 4000 ft.

Input {'elev_ft','altimeter' inHg,'oat_c','mtow'}. Pressure altitude = elev + (29.92 - altimeter)*1000; ISA temp = 15 - 2 per 1000 ft of PA; DA = PA + 120*(OAT - ISA). Allowed weight = MTOW - 20 lb per 1000 ft (pro rata) of DA above 3000 ft, rounded DOWN to 10 lb. Return [DA rounded, allowed].

split: open-access


prompt:
Two side-by-side containers each under their own limit but over the pair limit are accepted.

Input {'limits':{position: max kg},'combined':[[[positions], max kg]],'loads':{position: kg}}. Positions are visited in sorted order: unknown -> 'UNKNOWN:p', above its own limit -> 'POS:p'. Then each combined group in given order whose summed load (absent positions count 0) exceeds its cap -> 'COMB:a+b'. Limits are inclusive.

split: open-access


prompt:
A pair overload appears as two separate findings that look like individual position overloads.

Input {'limits':{position: max kg},'combined':[[[positions], max kg]],'loads':{position: kg}}. Positions are visited in sorted order: unknown -> 'UNKNOWN:p', above its own limit -> 'POS:p'. Then each combined group in given order whose summed load (absent positions count 0) exceeds its cap -> 'COMB:a+b'. Limits are inclusive.

split: open-access


prompt:
A container at exactly its position maximum is reported as an overload.

Input {'limits':{position: max kg},'combined':[[[positions], max kg]],'loads':{position: kg}}. Positions are visited in sorted order: unknown -> 'UNKNOWN:p', above its own limit -> 'POS:p'. Then each combined group in given order whose summed load (absent positions count 0) exceeds its cap -> 'COMB:a+b'. Limits are inclusive.

split: open-access


prompt:
A manifest line for a position that does not exist in this aircraft passes validation.

Input {'limits':{position: max kg},'combined':[[[positions], max kg]],'loads':{position: kg}}. Positions are visited in sorted order: unknown -> 'UNKNOWN:p', above its own limit -> 'POS:p'. Then each combined group in given order whose summed load (absent positions count 0) exceeds its cap -> 'COMB:a+b'. Limits are inclusive.

split: open-access


prompt:
Two runs over the same load in different manifest order produce differently ordered findings.

Input {'limits':{position: max kg},'combined':[[[positions], max kg]],'loads':{position: kg}}. Positions are visited in sorted order: unknown -> 'UNKNOWN:p', above its own limit -> 'POS:p'. Then each combined group in given order whose summed load (absent positions count 0) exceeds its cap -> 'COMB:a+b'. Limits are inclusive.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 + 0.004 * (x['temp_c'] - 15), 3)
    need = x['target_lb'] / dens - x['onboard_gal']
    if need <= 0: return [dens, 0]
    up = math.ceil(round(need, 6))
    if x['onboard_gal'] + up > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 - 0.004 * x['temp_c'], 3)
    need = x['target_lb'] / dens - x['onboard_gal']
    if need <= 0: return [dens, 0]
    up = math.ceil(round(need, 6))
    if x['onboard_gal'] + up > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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:
Hot days produce short-fuelled aircraft because too few gallons are ordered.

Input {'temp_c','target_lb','onboard_gal','capacity_gal'}. Jet fuel density = 6.7 - 0.004*(T-15) lb/gal rounded to 3 decimals. Uplift gallons = target/density - onboard, rounded UP to whole gallons (after clearing noise); none needed -> [density, 0]; onboard+uplift above capacity -> 'ERR_CAPACITY'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 - 0.004 * (x['temp_c'] - 15), 3)
    need = x['target_lb'] / dens - x['onboard_gal']
    if need <= 0: return [dens, 0]
    up = int(need)
    if x['onboard_gal'] + up > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 - 0.004 * (x['temp_c'] - 15), 3)
    need = x['target_lb'] / dens - x['onboard_gal']
    if need <= 0: return [dens, 0]
    up = round(need)
    if x['onboard_gal'] + up > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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:
The aircraft ends up a fraction of a gallon below the planned fuel weight.

Input {'temp_c','target_lb','onboard_gal','capacity_gal'}. Jet fuel density = 6.7 - 0.004*(T-15) lb/gal rounded to 3 decimals. Uplift gallons = target/density - onboard, rounded UP to whole gallons (after clearing noise); none needed -> [density, 0]; onboard+uplift above capacity -> 'ERR_CAPACITY'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 - 0.004 * (x['temp_c'] - 15), 3)
    need = (x['target_lb'] - x['onboard_gal']) / dens
    if need <= 0: return [dens, 0]
    up = math.ceil(round(need, 6))
    if x['onboard_gal'] + up > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 - 0.004 * (x['temp_c'] - 15), 3)
    need = x['target_lb'] / 6.7 - x['onboard_gal']
    if need <= 0: return [dens, 0]
    up = math.ceil(round(need, 6))
    if x['onboard_gal'] + up > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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:
Uplift orders are far too large when fuel is already on board.

Input {'temp_c','target_lb','onboard_gal','capacity_gal'}. Jet fuel density = 6.7 - 0.004*(T-15) lb/gal rounded to 3 decimals. Uplift gallons = target/density - onboard, rounded UP to whole gallons (after clearing noise); none needed -> [density, 0]; onboard+uplift above capacity -> 'ERR_CAPACITY'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 - 0.004 * (x['temp_c'] - 15), 3)
    need = x['target_lb'] / dens - x['onboard_gal']
    if need <= 0: return [dens, 0]
    up = math.ceil(round(need, 6))
    if x['target_lb'] > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 - 0.004 * (x['temp_c'] - 15), 3)
    need = x['target_lb'] / dens - x['onboard_gal']
    if need <= 0: return [dens, 0]
    up = math.ceil(round(need, 6))
    if up > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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:
Ordinary fuel orders are rejected because pounds exceed the gallon capacity number.

Input {'temp_c','target_lb','onboard_gal','capacity_gal'}. Jet fuel density = 6.7 - 0.004*(T-15) lb/gal rounded to 3 decimals. Uplift gallons = target/density - onboard, rounded UP to whole gallons (after clearing noise); none needed -> [density, 0]; onboard+uplift above capacity -> 'ERR_CAPACITY'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 - 0.004 * (x['temp_c'] - 15), 3)
    need = x['target_lb'] / dens - x['onboard_gal']
    if need <= 0: return 'ERR_CAPACITY'
    up = math.ceil(round(need, 6))
    if x['onboard_gal'] + up > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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
import math
N = 1
observations = []
def solve(x):
    dens = round(6.7 - 0.004 * (x['temp_c'] - 15), 3)
    need = x['target_lb'] / dens - x['onboard_gal']
    if need <= 0: return 'ERR_NO_UPLIFT'
    up = math.ceil(round(need, 6))
    if x['onboard_gal'] + up > x['capacity_gal']: return 'ERR_CAPACITY'
    return [dens, up]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['warm day uplift', {'temp_c': 30, 'target_lb': 12100.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1423]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 251.0, 'capacity_gal': 2800.0}, [6.84, 1065]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 501.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19010.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 39, 'target_lb': 11250.0, 'onboard_gal': 1045.9, 'capacity_gal': 3000.0}, [6.604, 658]], ['sampled case 2', {'temp_c': 43, 'target_lb': 7430.0, 'onboard_gal': 1471.0, 'capacity_gal': 1500.0}, [6.588, 0]], ['sampled case 3', {'temp_c': 32, 'target_lb': 13530.0, 'onboard_gal': 1415.1, 'capacity_gal': 3000.0}, [6.632, 626]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12200.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1438]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 252.0, 'capacity_gal': 2800.0}, [6.84, 1064]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 502.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19020.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': -6, 'target_lb': 17110.0, 'onboard_gal': 738.4, 'capacity_gal': 3000.0}, [6.784, 1784]], ['sampled case 2', {'temp_c': -18, 'target_lb': 12230.0, 'onboard_gal': 914.0, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -10, 'target_lb': 4890.0, 'onboard_gal': 1152.8, 'capacity_gal': 2800.0}, [6.8, 0]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12300.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1453]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 253.0, 'capacity_gal': 2800.0}, [6.84, 1063]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 503.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19030.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 35, 'target_lb': 9630.0, 'onboard_gal': 1062.7, 'capacity_gal': 3000.0}, [6.62, 392]], ['sampled case 2', {'temp_c': -7, 'target_lb': 18780.0, 'onboard_gal': 704.7, 'capacity_gal': 3000.0}, [6.788, 2062]], ['sampled case 3', {'temp_c': -5, 'target_lb': 6020.0, 'onboard_gal': 776.7, 'capacity_gal': 1500.0}, [6.78, 112]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12400.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1468]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 254.0, 'capacity_gal': 2800.0}, [6.84, 1062]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 504.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19040.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 0, 'target_lb': 12260.0, 'onboard_gal': 149.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': -16, 'target_lb': 6400.0, 'onboard_gal': 1488.9, 'capacity_gal': 2800.0}, [6.824, 0]], ['sampled case 3', {'temp_c': 7, 'target_lb': 11810.0, 'onboard_gal': 133.9, 'capacity_gal': 2800.0}, [6.732, 1621]]], [['warm day uplift', {'temp_c': 30, 'target_lb': 12500.0, 'onboard_gal': 400.0, 'capacity_gal': 2800.0}, [6.64, 1483]], ['cold day uplift', {'temp_c': -20, 'target_lb': 9000.0, 'onboard_gal': 255.0, 'capacity_gal': 2800.0}, [6.84, 1061]], ['already enough fuel', {'temp_c': 15, 'target_lb': 3000.0, 'onboard_gal': 505.0, 'capacity_gal': 2800.0}, [6.7, 0]], ['exact whole gallons', {'temp_c': 15, 'target_lb': 6700.0, 'onboard_gal': 200.0, 'capacity_gal': 2800.0}, [6.7, 800]], ['exceeds capacity', {'temp_c': 5, 'target_lb': 19050.0, 'onboard_gal': 300.0, 'capacity_gal': 2800.0}, 'ERR_CAPACITY'], ['fills to exactly capacity', {'temp_c': 15, 'target_lb': 18760.0, 'onboard_gal': 500.0, 'capacity_gal': 2800.0}, [6.7, 2300]], ['sampled case 1', {'temp_c': 41, 'target_lb': 11350.0, 'onboard_gal': 968.5, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 2', {'temp_c': 22, 'target_lb': 16520.0, 'onboard_gal': 628.8, 'capacity_gal': 1500.0}, 'ERR_CAPACITY'], ['sampled case 3', {'temp_c': -22, 'target_lb': 8500.0, 'onboard_gal': 1100.2, 'capacity_gal': 1500.0}, [6.848, 142]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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 tanker-loaded aircraft that needs no fuel gets an ERR_CAPACITY result.

Input {'temp_c','target_lb','onboard_gal','capacity_gal'}. Jet fuel density = 6.7 - 0.004*(T-15) lb/gal rounded to 3 decimals. Uplift gallons = target/density - onboard, rounded UP to whole gallons (after clearing noise); none needed -> [density, 0]; onboard+uplift above capacity -> 'ERR_CAPACITY'.

split: open-access