FAILURE MAP
← Case archive

FA-60041 / Inventory cost layering / Open access

Dollar-value LIFO layering: liquidation order · case 01

A decline in inventory strips the base-year layer, leaving recent high-priced layers intact.

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

ROOT CAUSE

Decrements start at the oldest layer instead of the most recent one.

VERIFIED REPAIR

Strip base dollars from the most recent layer first.

Unsuccessful approach: Stripping the highest-index layer first coincides only when indexes rise monotonically.

Case contract

Input {layers:[[year, base_dollars, index_bp]] oldest first, year, ending_current_cost, index (bp, 10000 = base year)}. Ending base dollars = round-half-up(current cost*10000/index). An increase over the prior base total adds one layer at the current index; a decrease strips base dollars from the newest layers first, removing layers that reach zero. LIFO value = sum of round-half-up(base*index/10000) per layer. Return {end_base, layers, lifo_value}.

Why this case matters

Inventory valuation and cost-of-goods decisions depend on this rule.

1 / The failure

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

N = 1
observations = []
def solve(x):
    layers = [list(l) for l in x['layers']]
    idx = x['index']
    end_base = (2 * x['ending_current_cost'] * 10000 + idx) // (2 * idx)
    prev = sum(l[1] for l in layers)
    if end_base > prev:
        layers.append([x['year'], end_base - prev, idx])
    else:
        cut = prev - end_base
        while cut > 0 and layers:
            k = 0
            top = layers[k]
            if top[1] <= cut:
                cut -= top[1]
                layers.pop(k)
            else:
                top[1] -= cut
                cut = 0
    value = sum((b * i + 5000) // 10000 for _, b, i in layers)
    return {'end_base': end_base, 'layers': layers, 'lifo_value': value}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15100, 'index': 11500}, {'end_base': 13130, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1130, 11500]], 'lifo_value': 13460}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12651, 'index': 11500}, {'end_base': 11001, 'layers': [[2020, 10000, 10000], [2021, 1001, 10800]], 'lifo_value': 11081}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1001, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5201, 'index': 10400}, {'end_base': 5001, 'layers': [[2020, 5000, 10000], [2021, 1, 10500]], 'lifo_value': 5001}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1051, 'index': 10300}, {'end_base': 1020, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 10, 10300]], 'lifo_value': 1022}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3001, 'index': 9500}, {'end_base': 3159, 'layers': [[2020, 3000, 10000], [2021, 159, 9500]], 'lifo_value': 3151}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5601, 'index': 11200}, {'end_base': 5001, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1, 11000]], 'lifo_value': 5201}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15200, 'index': 11500}, {'end_base': 13217, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1217, 11500]], 'lifo_value': 13560}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12652, 'index': 11500}, {'end_base': 11002, 'layers': [[2020, 10000, 10000], [2021, 1002, 10800]], 'lifo_value': 11082}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1002, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5202, 'index': 10400}, {'end_base': 5002, 'layers': [[2020, 5000, 10000], [2021, 2, 10500]], 'lifo_value': 5002}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1062, 'index': 10300}, {'end_base': 1031, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 21, 10300]], 'lifo_value': 1034}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3002, 'index': 9500}, {'end_base': 3160, 'layers': [[2020, 3000, 10000], [2021, 160, 9500]], 'lifo_value': 3152}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5602, 'index': 11200}, {'end_base': 5002, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 2, 11000]], 'lifo_value': 5202}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15300, 'index': 11500}, {'end_base': 13304, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1304, 11500]], 'lifo_value': 13660}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12653, 'index': 11500}, {'end_base': 11003, 'layers': [[2020, 10000, 10000], [2021, 1003, 10800]], 'lifo_value': 11083}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1003, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5203, 'index': 10400}, {'end_base': 5003, 'layers': [[2020, 5000, 10000], [2021, 3, 10500]], 'lifo_value': 5003}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1073, 'index': 10300}, {'end_base': 1042, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 32, 10300]], 'lifo_value': 1045}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3003, 'index': 9500}, {'end_base': 3161, 'layers': [[2020, 3000, 10000], [2021, 161, 9500]], 'lifo_value': 3153}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5603, 'index': 11200}, {'end_base': 5003, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 3, 11000]], 'lifo_value': 5203}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15400, 'index': 11500}, {'end_base': 13391, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1391, 11500]], 'lifo_value': 13760}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12654, 'index': 11500}, {'end_base': 11003, 'layers': [[2020, 10000, 10000], [2021, 1003, 10800]], 'lifo_value': 11083}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1004, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5204, 'index': 10400}, {'end_base': 5004, 'layers': [[2020, 5000, 10000], [2021, 4, 10500]], 'lifo_value': 5004}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1084, 'index': 10300}, {'end_base': 1052, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 42, 10300]], 'lifo_value': 1055}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3004, 'index': 9500}, {'end_base': 3162, 'layers': [[2020, 3000, 10000], [2021, 162, 9500]], 'lifo_value': 3154}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5604, 'index': 11200}, {'end_base': 5004, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 4, 11000]], 'lifo_value': 5204}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15500, 'index': 11500}, {'end_base': 13478, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1478, 11500]], 'lifo_value': 13860}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12655, 'index': 11500}, {'end_base': 11004, 'layers': [[2020, 10000, 10000], [2021, 1004, 10800]], 'lifo_value': 11084}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1005, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5205, 'index': 10400}, {'end_base': 5005, 'layers': [[2020, 5000, 10000], [2021, 5, 10500]], 'lifo_value': 5005}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1095, 'index': 10300}, {'end_base': 1063, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 53, 10300]], 'lifo_value': 1067}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3005, 'index': 9500}, {'end_base': 3163, 'layers': [[2020, 3000, 10000], [2021, 163, 9500]], 'lifo_value': 3155}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5605, 'index': 11200}, {'end_base': 5004, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 4, 11000]], 'lifo_value': 5204}]]]
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)
Boundary fixtureActualExpectedOutcome
new layer{'end_base': 13130, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1130, 11500]], 'lifo_value': 13460}{'end_base': 13130, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1130, 11500]], 'lifo_value': 13460}Passed
partial strip{'end_base': 11001, 'layers': [[2020, 9001, 10000], [2021, 2000, 10800]], 'lifo_value': 11161}{'end_base': 11001, 'layers': [[2020, 10000, 10000], [2021, 1001, 10800]], 'lifo_value': 11081}Failed
strip exact layer{'end_base': 12000, 'layers': [[2020, 8999, 10000], [2021, 2000, 10800], [2022, 1001, 11000]], 'lifo_value': 12260}{'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}Failed
strip two layers{'end_base': 5001, 'layers': [[2020, 3001, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'lifo_value': 5301}{'end_base': 5001, 'layers': [[2020, 5000, 10000], [2021, 1, 10500]], 'lifo_value': 5001}Failed
unchanged base{'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}{'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}Passed
rounding layers{'end_base': 1020, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 10, 10300]], 'lifo_value': 1022}{'end_base': 1020, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 10, 10300]], 'lifo_value': 1022}Passed
deflation{'end_base': 3159, 'layers': [[2020, 3000, 10000], [2021, 159, 9500]], 'lifo_value': 3151}{'end_base': 3159, 'layers': [[2020, 3000, 10000], [2021, 159, 9500]], 'lifo_value': 3151}Passed
non monotonic index{'end_base': 5001, 'layers': [[2019, 3001, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'lifo_value': 5301}{'end_base': 5001, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1, 11000]], 'lifo_value': 5201}Failed

SHA-256 / 0e101e10564437e9547b55abe15f61062fdd8847dd82a0a6f6d02304c325500b

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    layers = [list(l) for l in x['layers']]
    idx = x['index']
    end_base = (2 * x['ending_current_cost'] * 10000 + idx) // (2 * idx)
    prev = sum(l[1] for l in layers)
    if end_base > prev:
        layers.append([x['year'], end_base - prev, idx])
    else:
        cut = prev - end_base
        while cut > 0 and layers:
            k = max(range(len(layers)), key=lambda j: layers[j][2])
            top = layers[k]
            if top[1] <= cut:
                cut -= top[1]
                layers.pop(k)
            else:
                top[1] -= cut
                cut = 0
    value = sum((b * i + 5000) // 10000 for _, b, i in layers)
    return {'end_base': end_base, 'layers': layers, 'lifo_value': value}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15100, 'index': 11500}, {'end_base': 13130, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1130, 11500]], 'lifo_value': 13460}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12651, 'index': 11500}, {'end_base': 11001, 'layers': [[2020, 10000, 10000], [2021, 1001, 10800]], 'lifo_value': 11081}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1001, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5201, 'index': 10400}, {'end_base': 5001, 'layers': [[2020, 5000, 10000], [2021, 1, 10500]], 'lifo_value': 5001}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1051, 'index': 10300}, {'end_base': 1020, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 10, 10300]], 'lifo_value': 1022}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3001, 'index': 9500}, {'end_base': 3159, 'layers': [[2020, 3000, 10000], [2021, 159, 9500]], 'lifo_value': 3151}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5601, 'index': 11200}, {'end_base': 5001, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1, 11000]], 'lifo_value': 5201}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15200, 'index': 11500}, {'end_base': 13217, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1217, 11500]], 'lifo_value': 13560}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12652, 'index': 11500}, {'end_base': 11002, 'layers': [[2020, 10000, 10000], [2021, 1002, 10800]], 'lifo_value': 11082}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1002, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5202, 'index': 10400}, {'end_base': 5002, 'layers': [[2020, 5000, 10000], [2021, 2, 10500]], 'lifo_value': 5002}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1062, 'index': 10300}, {'end_base': 1031, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 21, 10300]], 'lifo_value': 1034}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3002, 'index': 9500}, {'end_base': 3160, 'layers': [[2020, 3000, 10000], [2021, 160, 9500]], 'lifo_value': 3152}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5602, 'index': 11200}, {'end_base': 5002, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 2, 11000]], 'lifo_value': 5202}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15300, 'index': 11500}, {'end_base': 13304, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1304, 11500]], 'lifo_value': 13660}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12653, 'index': 11500}, {'end_base': 11003, 'layers': [[2020, 10000, 10000], [2021, 1003, 10800]], 'lifo_value': 11083}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1003, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5203, 'index': 10400}, {'end_base': 5003, 'layers': [[2020, 5000, 10000], [2021, 3, 10500]], 'lifo_value': 5003}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1073, 'index': 10300}, {'end_base': 1042, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 32, 10300]], 'lifo_value': 1045}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3003, 'index': 9500}, {'end_base': 3161, 'layers': [[2020, 3000, 10000], [2021, 161, 9500]], 'lifo_value': 3153}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5603, 'index': 11200}, {'end_base': 5003, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 3, 11000]], 'lifo_value': 5203}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15400, 'index': 11500}, {'end_base': 13391, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1391, 11500]], 'lifo_value': 13760}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12654, 'index': 11500}, {'end_base': 11003, 'layers': [[2020, 10000, 10000], [2021, 1003, 10800]], 'lifo_value': 11083}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1004, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5204, 'index': 10400}, {'end_base': 5004, 'layers': [[2020, 5000, 10000], [2021, 4, 10500]], 'lifo_value': 5004}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1084, 'index': 10300}, {'end_base': 1052, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 42, 10300]], 'lifo_value': 1055}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3004, 'index': 9500}, {'end_base': 3162, 'layers': [[2020, 3000, 10000], [2021, 162, 9500]], 'lifo_value': 3154}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5604, 'index': 11200}, {'end_base': 5004, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 4, 11000]], 'lifo_value': 5204}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15500, 'index': 11500}, {'end_base': 13478, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1478, 11500]], 'lifo_value': 13860}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12655, 'index': 11500}, {'end_base': 11004, 'layers': [[2020, 10000, 10000], [2021, 1004, 10800]], 'lifo_value': 11084}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1005, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5205, 'index': 10400}, {'end_base': 5005, 'layers': [[2020, 5000, 10000], [2021, 5, 10500]], 'lifo_value': 5005}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1095, 'index': 10300}, {'end_base': 1063, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 53, 10300]], 'lifo_value': 1067}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3005, 'index': 9500}, {'end_base': 3163, 'layers': [[2020, 3000, 10000], [2021, 163, 9500]], 'lifo_value': 3155}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5605, 'index': 11200}, {'end_base': 5004, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 4, 11000]], 'lifo_value': 5204}]]]
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)
Boundary fixtureActualExpectedOutcome
new layer{'end_base': 13130, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1130, 11500]], 'lifo_value': 13460}{'end_base': 13130, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1130, 11500]], 'lifo_value': 13460}Passed
partial strip{'end_base': 11001, 'layers': [[2020, 10000, 10000], [2021, 1001, 10800]], 'lifo_value': 11081}{'end_base': 11001, 'layers': [[2020, 10000, 10000], [2021, 1001, 10800]], 'lifo_value': 11081}Passed
strip exact layer{'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}{'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}Passed
strip two layers{'end_base': 5001, 'layers': [[2020, 5000, 10000], [2021, 1, 10500]], 'lifo_value': 5001}{'end_base': 5001, 'layers': [[2020, 5000, 10000], [2021, 1, 10500]], 'lifo_value': 5001}Passed
unchanged base{'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}{'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}Passed
rounding layers{'end_base': 1020, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 10, 10300]], 'lifo_value': 1022}{'end_base': 1020, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 10, 10300]], 'lifo_value': 1022}Passed
deflation{'end_base': 3159, 'layers': [[2020, 3000, 10000], [2021, 159, 9500]], 'lifo_value': 3151}{'end_base': 3159, 'layers': [[2020, 3000, 10000], [2021, 159, 9500]], 'lifo_value': 3151}Passed
non monotonic index{'end_base': 5001, 'layers': [[2019, 4000, 10000], [2020, 1, 12000], [2021, 1000, 11000]], 'lifo_value': 5101}{'end_base': 5001, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1, 11000]], 'lifo_value': 5201}Failed

SHA-256 / 22172751459cec0da240289177c5ac90b40d936ce9c016bfb1c1eac4a09fc644

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    layers = [list(l) for l in x['layers']]
    idx = x['index']
    end_base = (2 * x['ending_current_cost'] * 10000 + idx) // (2 * idx)
    prev = sum(l[1] for l in layers)
    if end_base > prev:
        layers.append([x['year'], end_base - prev, idx])
    else:
        cut = prev - end_base
        while cut > 0 and layers:
            k = -1
            top = layers[k]
            if top[1] <= cut:
                cut -= top[1]
                layers.pop(k)
            else:
                top[1] -= cut
                cut = 0
    value = sum((b * i + 5000) // 10000 for _, b, i in layers)
    return {'end_base': end_base, 'layers': layers, 'lifo_value': value}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15100, 'index': 11500}, {'end_base': 13130, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1130, 11500]], 'lifo_value': 13460}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12651, 'index': 11500}, {'end_base': 11001, 'layers': [[2020, 10000, 10000], [2021, 1001, 10800]], 'lifo_value': 11081}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1001, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5201, 'index': 10400}, {'end_base': 5001, 'layers': [[2020, 5000, 10000], [2021, 1, 10500]], 'lifo_value': 5001}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1051, 'index': 10300}, {'end_base': 1020, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 10, 10300]], 'lifo_value': 1022}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3001, 'index': 9500}, {'end_base': 3159, 'layers': [[2020, 3000, 10000], [2021, 159, 9500]], 'lifo_value': 3151}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5601, 'index': 11200}, {'end_base': 5001, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1, 11000]], 'lifo_value': 5201}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15200, 'index': 11500}, {'end_base': 13217, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1217, 11500]], 'lifo_value': 13560}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12652, 'index': 11500}, {'end_base': 11002, 'layers': [[2020, 10000, 10000], [2021, 1002, 10800]], 'lifo_value': 11082}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1002, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5202, 'index': 10400}, {'end_base': 5002, 'layers': [[2020, 5000, 10000], [2021, 2, 10500]], 'lifo_value': 5002}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1062, 'index': 10300}, {'end_base': 1031, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 21, 10300]], 'lifo_value': 1034}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3002, 'index': 9500}, {'end_base': 3160, 'layers': [[2020, 3000, 10000], [2021, 160, 9500]], 'lifo_value': 3152}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5602, 'index': 11200}, {'end_base': 5002, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 2, 11000]], 'lifo_value': 5202}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15300, 'index': 11500}, {'end_base': 13304, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1304, 11500]], 'lifo_value': 13660}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12653, 'index': 11500}, {'end_base': 11003, 'layers': [[2020, 10000, 10000], [2021, 1003, 10800]], 'lifo_value': 11083}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1003, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5203, 'index': 10400}, {'end_base': 5003, 'layers': [[2020, 5000, 10000], [2021, 3, 10500]], 'lifo_value': 5003}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1073, 'index': 10300}, {'end_base': 1042, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 32, 10300]], 'lifo_value': 1045}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3003, 'index': 9500}, {'end_base': 3161, 'layers': [[2020, 3000, 10000], [2021, 161, 9500]], 'lifo_value': 3153}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5603, 'index': 11200}, {'end_base': 5003, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 3, 11000]], 'lifo_value': 5203}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15400, 'index': 11500}, {'end_base': 13391, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1391, 11500]], 'lifo_value': 13760}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12654, 'index': 11500}, {'end_base': 11003, 'layers': [[2020, 10000, 10000], [2021, 1003, 10800]], 'lifo_value': 11083}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1004, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5204, 'index': 10400}, {'end_base': 5004, 'layers': [[2020, 5000, 10000], [2021, 4, 10500]], 'lifo_value': 5004}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1084, 'index': 10300}, {'end_base': 1052, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 42, 10300]], 'lifo_value': 1055}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3004, 'index': 9500}, {'end_base': 3162, 'layers': [[2020, 3000, 10000], [2021, 162, 9500]], 'lifo_value': 3154}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5604, 'index': 11200}, {'end_base': 5004, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 4, 11000]], 'lifo_value': 5204}]], [['new layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 15500, 'index': 11500}, {'end_base': 13478, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1478, 11500]], 'lifo_value': 13860}], ['partial strip', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'year': 2022, 'ending_current_cost': 12655, 'index': 11500}, {'end_base': 11004, 'layers': [[2020, 10000, 10000], [2021, 1004, 10800]], 'lifo_value': 11084}], ['strip exact layer', {'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1005, 11000]], 'year': 2023, 'ending_current_cost': 14400, 'index': 12000}, {'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}], ['strip two layers', {'layers': [[2020, 5000, 10000], [2021, 1000, 10500], [2022, 1000, 12500]], 'year': 2023, 'ending_current_cost': 5205, 'index': 10400}, {'end_base': 5005, 'layers': [[2020, 5000, 10000], [2021, 5, 10500]], 'lifo_value': 5005}], ['unchanged base', {'layers': [[2020, 8000, 10000]], 'year': 2021, 'ending_current_cost': 8800, 'index': 11000}, {'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}], ['rounding layers', {'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000]], 'year': 2023, 'ending_current_cost': 1095, 'index': 10300}, {'end_base': 1063, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 53, 10300]], 'lifo_value': 1067}], ['deflation', {'layers': [[2020, 3000, 10000]], 'year': 2021, 'ending_current_cost': 3005, 'index': 9500}, {'end_base': 3163, 'layers': [[2020, 3000, 10000], [2021, 163, 9500]], 'lifo_value': 3155}], ['non monotonic index', {'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1000, 11000]], 'year': 2022, 'ending_current_cost': 5605, 'index': 11200}, {'end_base': 5004, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 4, 11000]], 'lifo_value': 5204}]]]
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)
Boundary fixtureActualExpectedOutcome
new layer{'end_base': 13130, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1130, 11500]], 'lifo_value': 13460}{'end_base': 13130, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800], [2022, 1130, 11500]], 'lifo_value': 13460}Passed
partial strip{'end_base': 11001, 'layers': [[2020, 10000, 10000], [2021, 1001, 10800]], 'lifo_value': 11081}{'end_base': 11001, 'layers': [[2020, 10000, 10000], [2021, 1001, 10800]], 'lifo_value': 11081}Passed
strip exact layer{'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}{'end_base': 12000, 'layers': [[2020, 10000, 10000], [2021, 2000, 10800]], 'lifo_value': 12160}Passed
strip two layers{'end_base': 5001, 'layers': [[2020, 5000, 10000], [2021, 1, 10500]], 'lifo_value': 5001}{'end_base': 5001, 'layers': [[2020, 5000, 10000], [2021, 1, 10500]], 'lifo_value': 5001}Passed
unchanged base{'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}{'end_base': 8000, 'layers': [[2020, 8000, 10000]], 'lifo_value': 8000}Passed
rounding layers{'end_base': 1020, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 10, 10300]], 'lifo_value': 1022}{'end_base': 1020, 'layers': [[2020, 1000, 10000], [2021, 5, 11000], [2022, 5, 11000], [2023, 10, 10300]], 'lifo_value': 1022}Passed
deflation{'end_base': 3159, 'layers': [[2020, 3000, 10000], [2021, 159, 9500]], 'lifo_value': 3151}{'end_base': 3159, 'layers': [[2020, 3000, 10000], [2021, 159, 9500]], 'lifo_value': 3151}Passed
non monotonic index{'end_base': 5001, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1, 11000]], 'lifo_value': 5201}{'end_base': 5001, 'layers': [[2019, 4000, 10000], [2020, 1000, 12000], [2021, 1, 11000]], 'lifo_value': 5201}Passed

SHA-256 / 3b8338d96252e83768e8d31d15dfef7e30a9b2da142b124b20a744fe1859eb09

Verification & scope

Stipulated bounded teaching model with explicit toy rules; not an accounting-standard implementation. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

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

Case digest / 46d5eb1f3337b60d1eeaea6b2a02a8c00f9488b1ad7c89866ae9c4cbea10001f