FAILURE MAP
← Case archive

FA-62891 / Insurance premium rating / Open access

Deductible credit interpolation: Credits are extrapolated past the largest deductible · case 01

Very large deductibles receive credits beyond the largest filed credit.

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

ROOT CAUSE

The upper branch extends the last segment slope instead of flattening at the last row.

VERIFIED REPAIR

Use the last tabulated credit for every deductible at or above the last row.

Unsuccessful approach: Using the second-to-last credit flattens but at the wrong row.

Case contract

Input premium, deductible and table [[deductible, credit per mille]] ascending (credits may be negative surcharges). Deductibles at or below the first row take its credit, at or above the last row take the last credit (no extrapolation), otherwise interpolate linearly. Credit cents = floor(prem*c/1000+1/2). Negative deductible or empty table -> 'invalid'. Return [credit, premium-credit].

Why this case matters

Premium rating engines apply ordered tabular rules where one misplaced boundary or step silently misprices policies.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    tab=x['table']; d=x['deductible']; prem=x['premium']
    if d<0 or not tab: return 'invalid'
    if d<=tab[0][0]: c=Fraction(tab[0][1])
    elif d>tab[-1][0]: c=Fraction(tab[-1][1])+Fraction(tab[-1][1]-tab[-2][1])*(d-tab[-1][0])/(tab[-1][0]-tab[-2][0])
    else:
        i=0
        while tab[i+1][0]<d: i+=1
        d0,c0=tab[i]; d1,c1=tab[i+1]
        c=c0+Fraction(c1-c0)*(d-d0)/(d1-d0)
    credit=math.floor(prem*c/1000+Fraction(1,2))
    return [credit, prem-credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['base deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 50000, 'premium': 261724}, [0, 261724]], ['interpolated low segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 78500, 'premium': 331983}, [11543, 320440]], ['interpolated upper segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 481000, 'premium': 116345}, [23939, 92406]], ['beyond largest tabulated deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 751000, 'premium': 322204}, [67985, 254219]], ['exact largest deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 500000, 'premium': 393848}, [83102, 310746]], ['zero deductible uses lowest row', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 0, 'premium': 210458}, [-631, 211089]], ['deductible below table surcharged', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 10000, 'premium': 199242}, [-598, 199840]], ['negative deductible rejected', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': -100, 'premium': 226782}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 25000, 'premium': 22500}, [-67, 22567]], ['interior knot', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 250000, 'premium': 94197}, [13376, 80821]]], [['base deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 50000, 'premium': 199101}, [0, 199101]], ['interpolated low segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 86000, 'premium': 159529}, [7121, 152408]], ['interpolated upper segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 369000, 'premium': 114198}, [20141, 94057]], ['beyond largest tabulated deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 752000, 'premium': 110216}, [23366, 86850]], ['exact largest deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 500000, 'premium': 313269}, [66413, 246856]], ['zero deductible uses lowest row', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 0, 'premium': 174100}, [-870, 174970]], ['deductible below table surcharged', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 10000, 'premium': 243190}, [-1216, 244406]], ['negative deductible rejected', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': -100, 'premium': 214814}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 25000, 'premium': 23500}, [-117, 23617]], ['interior knot', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 250000, 'premium': 349563}, [50337, 299226]]], [['base deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 50000, 'premium': 263025}, [0, 263025]], ['interpolated low segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 55000, 'premium': 117616}, [741, 116875]], ['interpolated upper segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 315000, 'premium': 209271}, [34199, 175072]], ['beyond largest tabulated deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 753000, 'premium': 115225}, [24543, 90682]], ['exact largest deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 500000, 'premium': 322765}, [68749, 254016]], ['zero deductible uses lowest row', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 0, 'premium': 297017}, [-2079, 299096]], ['deductible below table surcharged', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 10000, 'premium': 263626}, [-1845, 265471]], ['negative deductible rejected', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': -100, 'premium': 120680}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 25000, 'premium': 24500}, [-171, 24671]], ['interior knot', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 250000, 'premium': 301911}, [44079, 257832]]], [['base deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 50000, 'premium': 340242}, [0, 340242]], ['interpolated low segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 96500, 'premium': 240169}, [14295, 225874]], ['interpolated upper segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 339000, 'premium': 148801}, [25519, 123282]], ['beyond largest tabulated deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 754000, 'premium': 216687}, [46371, 170316]], ['exact largest deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 500000, 'premium': 388433}, [83125, 305308]], ['zero deductible uses lowest row', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 0, 'premium': 394112}, [-3547, 397659]], ['deductible below table surcharged', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 10000, 'premium': 145337}, [-1308, 146645]], ['negative deductible rejected', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': -100, 'premium': 335212}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 25000, 'premium': 25500}, [-229, 25729]], ['interior knot', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 250000, 'premium': 128496}, [19017, 109479]]], [['base deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 50000, 'premium': 113213}, [0, 113213]], ['interpolated low segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 56500, 'premium': 364381}, [3079, 361302]], ['interpolated upper segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 374000, 'premium': 322937}, [58852, 264085]], ['beyond largest tabulated deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 755000, 'premium': 161418}, [34705, 126713]], ['exact largest deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 500000, 'premium': 386131}, [83018, 303113]], ['zero deductible uses lowest row', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 0, 'premium': 264667}, [-2911, 267578]], ['deductible below table surcharged', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 10000, 'premium': 141161}, [-1553, 142714]], ['negative deductible rejected', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': -100, 'premium': 190310}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 25000, 'premium': 26500}, [-291, 26791]], ['interior knot', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 250000, 'premium': 86734}, [13010, 73724]]]]
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
base deductible[0, 261724][0, 261724]Passed
interpolated low segment[11543, 320440][11543, 320440]Passed
interpolated upper segment[23939, 92406][23939, 92406]Passed
beyond largest tabulated deductible[90306, 231898][67985, 254219]Failed
exact largest deductible[83102, 310746][83102, 310746]Passed
zero deductible uses lowest row[-631, 211089][-631, 211089]Passed
deductible below table surcharged[-598, 199840][-598, 199840]Passed
negative deductible rejectedinvalidinvalidPassed
surcharge tie rounds toward positive[-67, 22567][-67, 22567]Passed
interior knot[13376, 80821][13376, 80821]Passed

SHA-256 / 1dba673d4b6714c6742095e315afc62289d1b02e9004416e06b784e8b2687672

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    tab=x['table']; d=x['deductible']; prem=x['premium']
    if d<0 or not tab: return 'invalid'
    if d<=tab[0][0]: c=Fraction(tab[0][1])
    elif d>=tab[-1][0]: c=Fraction(tab[-2][1])
    else:
        i=0
        while tab[i+1][0]<d: i+=1
        d0,c0=tab[i]; d1,c1=tab[i+1]
        c=c0+Fraction(c1-c0)*(d-d0)/(d1-d0)
    credit=math.floor(prem*c/1000+Fraction(1,2))
    return [credit, prem-credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['base deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 50000, 'premium': 261724}, [0, 261724]], ['interpolated low segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 78500, 'premium': 331983}, [11543, 320440]], ['interpolated upper segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 481000, 'premium': 116345}, [23939, 92406]], ['beyond largest tabulated deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 751000, 'premium': 322204}, [67985, 254219]], ['exact largest deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 500000, 'premium': 393848}, [83102, 310746]], ['zero deductible uses lowest row', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 0, 'premium': 210458}, [-631, 211089]], ['deductible below table surcharged', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 10000, 'premium': 199242}, [-598, 199840]], ['negative deductible rejected', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': -100, 'premium': 226782}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 25000, 'premium': 22500}, [-67, 22567]], ['interior knot', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 250000, 'premium': 94197}, [13376, 80821]]], [['base deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 50000, 'premium': 199101}, [0, 199101]], ['interpolated low segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 86000, 'premium': 159529}, [7121, 152408]], ['interpolated upper segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 369000, 'premium': 114198}, [20141, 94057]], ['beyond largest tabulated deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 752000, 'premium': 110216}, [23366, 86850]], ['exact largest deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 500000, 'premium': 313269}, [66413, 246856]], ['zero deductible uses lowest row', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 0, 'premium': 174100}, [-870, 174970]], ['deductible below table surcharged', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 10000, 'premium': 243190}, [-1216, 244406]], ['negative deductible rejected', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': -100, 'premium': 214814}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 25000, 'premium': 23500}, [-117, 23617]], ['interior knot', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 250000, 'premium': 349563}, [50337, 299226]]], [['base deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 50000, 'premium': 263025}, [0, 263025]], ['interpolated low segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 55000, 'premium': 117616}, [741, 116875]], ['interpolated upper segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 315000, 'premium': 209271}, [34199, 175072]], ['beyond largest tabulated deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 753000, 'premium': 115225}, [24543, 90682]], ['exact largest deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 500000, 'premium': 322765}, [68749, 254016]], ['zero deductible uses lowest row', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 0, 'premium': 297017}, [-2079, 299096]], ['deductible below table surcharged', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 10000, 'premium': 263626}, [-1845, 265471]], ['negative deductible rejected', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': -100, 'premium': 120680}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 25000, 'premium': 24500}, [-171, 24671]], ['interior knot', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 250000, 'premium': 301911}, [44079, 257832]]], [['base deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 50000, 'premium': 340242}, [0, 340242]], ['interpolated low segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 96500, 'premium': 240169}, [14295, 225874]], ['interpolated upper segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 339000, 'premium': 148801}, [25519, 123282]], ['beyond largest tabulated deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 754000, 'premium': 216687}, [46371, 170316]], ['exact largest deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 500000, 'premium': 388433}, [83125, 305308]], ['zero deductible uses lowest row', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 0, 'premium': 394112}, [-3547, 397659]], ['deductible below table surcharged', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 10000, 'premium': 145337}, [-1308, 146645]], ['negative deductible rejected', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': -100, 'premium': 335212}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 25000, 'premium': 25500}, [-229, 25729]], ['interior knot', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 250000, 'premium': 128496}, [19017, 109479]]], [['base deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 50000, 'premium': 113213}, [0, 113213]], ['interpolated low segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 56500, 'premium': 364381}, [3079, 361302]], ['interpolated upper segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 374000, 'premium': 322937}, [58852, 264085]], ['beyond largest tabulated deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 755000, 'premium': 161418}, [34705, 126713]], ['exact largest deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 500000, 'premium': 386131}, [83018, 303113]], ['zero deductible uses lowest row', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 0, 'premium': 264667}, [-2911, 267578]], ['deductible below table surcharged', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 10000, 'premium': 141161}, [-1553, 142714]], ['negative deductible rejected', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': -100, 'premium': 190310}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 25000, 'premium': 26500}, [-291, 26791]], ['interior knot', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 250000, 'premium': 86734}, [13010, 73724]]]]
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
base deductible[0, 261724][0, 261724]Passed
interpolated low segment[11543, 320440][11543, 320440]Passed
interpolated upper segment[23939, 92406][23939, 92406]Passed
beyond largest tabulated deductible[45753, 276451][67985, 254219]Failed
exact largest deductible[55926, 337922][83102, 310746]Failed
zero deductible uses lowest row[-631, 211089][-631, 211089]Passed
deductible below table surcharged[-598, 199840][-598, 199840]Passed
negative deductible rejectedinvalidinvalidPassed
surcharge tie rounds toward positive[-67, 22567][-67, 22567]Passed
interior knot[13376, 80821][13376, 80821]Passed

SHA-256 / 3f6b98ffb7f5868c351416816f723c2d317b7cbad2c09cc08e77973fcd6b54a2

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    tab=x['table']; d=x['deductible']; prem=x['premium']
    if d<0 or not tab: return 'invalid'
    if d<=tab[0][0]: c=Fraction(tab[0][1])
    elif d>=tab[-1][0]: c=Fraction(tab[-1][1])
    else:
        i=0
        while tab[i+1][0]<d: i+=1
        d0,c0=tab[i]; d1,c1=tab[i+1]
        c=c0+Fraction(c1-c0)*(d-d0)/(d1-d0)
    credit=math.floor(prem*c/1000+Fraction(1,2))
    return [credit, prem-credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['base deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 50000, 'premium': 261724}, [0, 261724]], ['interpolated low segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 78500, 'premium': 331983}, [11543, 320440]], ['interpolated upper segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 481000, 'premium': 116345}, [23939, 92406]], ['beyond largest tabulated deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 751000, 'premium': 322204}, [67985, 254219]], ['exact largest deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 500000, 'premium': 393848}, [83102, 310746]], ['zero deductible uses lowest row', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 0, 'premium': 210458}, [-631, 211089]], ['deductible below table surcharged', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 10000, 'premium': 199242}, [-598, 199840]], ['negative deductible rejected', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': -100, 'premium': 226782}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 25000, 'premium': 22500}, [-67, 22567]], ['interior knot', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 250000, 'premium': 94197}, [13376, 80821]]], [['base deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 50000, 'premium': 199101}, [0, 199101]], ['interpolated low segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 86000, 'premium': 159529}, [7121, 152408]], ['interpolated upper segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 369000, 'premium': 114198}, [20141, 94057]], ['beyond largest tabulated deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 752000, 'premium': 110216}, [23366, 86850]], ['exact largest deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 500000, 'premium': 313269}, [66413, 246856]], ['zero deductible uses lowest row', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 0, 'premium': 174100}, [-870, 174970]], ['deductible below table surcharged', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 10000, 'premium': 243190}, [-1216, 244406]], ['negative deductible rejected', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': -100, 'premium': 214814}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 25000, 'premium': 23500}, [-117, 23617]], ['interior knot', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 250000, 'premium': 349563}, [50337, 299226]]], [['base deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 50000, 'premium': 263025}, [0, 263025]], ['interpolated low segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 55000, 'premium': 117616}, [741, 116875]], ['interpolated upper segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 315000, 'premium': 209271}, [34199, 175072]], ['beyond largest tabulated deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 753000, 'premium': 115225}, [24543, 90682]], ['exact largest deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 500000, 'premium': 322765}, [68749, 254016]], ['zero deductible uses lowest row', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 0, 'premium': 297017}, [-2079, 299096]], ['deductible below table surcharged', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 10000, 'premium': 263626}, [-1845, 265471]], ['negative deductible rejected', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': -100, 'premium': 120680}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 25000, 'premium': 24500}, [-171, 24671]], ['interior knot', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 250000, 'premium': 301911}, [44079, 257832]]], [['base deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 50000, 'premium': 340242}, [0, 340242]], ['interpolated low segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 96500, 'premium': 240169}, [14295, 225874]], ['interpolated upper segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 339000, 'premium': 148801}, [25519, 123282]], ['beyond largest tabulated deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 754000, 'premium': 216687}, [46371, 170316]], ['exact largest deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 500000, 'premium': 388433}, [83125, 305308]], ['zero deductible uses lowest row', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 0, 'premium': 394112}, [-3547, 397659]], ['deductible below table surcharged', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 10000, 'premium': 145337}, [-1308, 146645]], ['negative deductible rejected', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': -100, 'premium': 335212}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 25000, 'premium': 25500}, [-229, 25729]], ['interior knot', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 250000, 'premium': 128496}, [19017, 109479]]], [['base deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 50000, 'premium': 113213}, [0, 113213]], ['interpolated low segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 56500, 'premium': 364381}, [3079, 361302]], ['interpolated upper segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 374000, 'premium': 322937}, [58852, 264085]], ['beyond largest tabulated deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 755000, 'premium': 161418}, [34705, 126713]], ['exact largest deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 500000, 'premium': 386131}, [83018, 303113]], ['zero deductible uses lowest row', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 0, 'premium': 264667}, [-2911, 267578]], ['deductible below table surcharged', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 10000, 'premium': 141161}, [-1553, 142714]], ['negative deductible rejected', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': -100, 'premium': 190310}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 25000, 'premium': 26500}, [-291, 26791]], ['interior knot', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 250000, 'premium': 86734}, [13010, 73724]]]]
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
base deductible[0, 261724][0, 261724]Passed
interpolated low segment[11543, 320440][11543, 320440]Passed
interpolated upper segment[23939, 92406][23939, 92406]Passed
beyond largest tabulated deductible[67985, 254219][67985, 254219]Passed
exact largest deductible[83102, 310746][83102, 310746]Passed
zero deductible uses lowest row[-631, 211089][-631, 211089]Passed
deductible below table surcharged[-598, 199840][-598, 199840]Passed
negative deductible rejectedinvalidinvalidPassed
surcharge tie rounds toward positive[-67, 22567][-67, 22567]Passed
interior knot[13376, 80821][13376, 80821]Passed

SHA-256 / d8143b057c5f753e8c81b5267b7a28222a7c5667173b46f4a298c6600336effb

Verification & scope

A deterministic bounded teaching model of a stipulated toy rating contract. Amounts are integer cents and factors exact rationals; it makes no claim of conformance with any filed rating plan, bureau manual or jurisdiction. 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:47:08.963710+00:00.

Case digest / 5967457c61d949ab797cff5ae52e2a5fe9ef41d834d2aef39a1ac60b8bee68fd