FA-62841 / Insurance premium rating / Open access
Personal auto multiplicative rating: Age 25 is still rated as youthful · case 01
A 25-year-old driver is charged the 1.50 youthful factor.
ROOT CAUSE
The youthful band test uses age<=25, so the first adult age stays in the surcharged band.
VERIFIED REPAIR
Use age<25 so ages 16 through 24 inclusive are youthful.
Unsuccessful approach: Changing the test to age<24 releases 25-year-olds but drops 24-year-olds out of the youthful band.
Case contract
Input dict base, territory (A/B/C factors 1.00/1.15/1.30, else 'invalid territory'), age (<16 'invalid age'; 16-24 factor 1.50; 25-64 1.00; 65+ 1.20), symbol s with factor 1+0.05*(s-1), cars (>=2 gives 10% discount), fee. Rated premium = base*factors*discount rounded half-up to a cent once, then a 30000-cent minimum, then the fee is added.
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):
T={'A':Fraction(1),'B':Fraction(115,100),'C':Fraction(130,100)}
if x['territory'] not in T: return 'invalid territory'
age=x['age']
if age<16: return 'invalid age'
if age<=25: af=Fraction(150,100)
elif age<65: af=Fraction(1)
else: af=Fraction(120,100)
sf=1+Fraction(5,100)*(x['symbol']-1)
disc=Fraction(90,100) if x['cars']>=2 else Fraction(1)
rated=x['base']*T[x['territory']]*af*sf
rated=rated*disc
rated=int(rated+Fraction(1,2))
rated=max(rated,30000)
return rated+x['fee']
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['youthful band ends at 24', {'base': 54520, 'territory': 'B', 'age': 24, 'symbol': 10, 'cars': 1, 'fee': 0}, 136368], ['age 25 leaves youthful band', {'base': 48271, 'territory': 'A', 'age': 25, 'symbol': 2, 'cars': 1, 'fee': 1500}, 52185], ['senior boundary 65', {'base': 31490, 'territory': 'A', 'age': 65, 'symbol': 8, 'cars': 2, 'fee': 0}, 45912], ['two cars earn multi-car discount', {'base': 53546, 'territory': 'A', 'age': 55, 'symbol': 8, 'cars': 2, 'fee': 0}, 65058], ['single car control', {'base': 41604, 'territory': 'A', 'age': 56, 'symbol': 9, 'cars': 1, 'fee': 0}, 58246], ['discounted policy below minimum', {'base': 30977, 'territory': 'A', 'age': 39, 'symbol': 1, 'cars': 3, 'fee': 0}, 30000], ['unknown territory rejected', {'base': 78746, 'territory': 'Z', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 84653, 'territory': 'C', 'age': 15, 'symbol': 2, 'cars': 1, 'fee': 2500}, 'invalid age'], ['random rating 0', {'base': 34126, 'territory': 'C', 'age': 33, 'symbol': 6, 'cars': 3, 'fee': 0}, 49909], ['random rating 1', {'base': 62350, 'territory': 'A', 'age': 16, 'symbol': 1, 'cars': 3, 'fee': 1500}, 85673], ['random rating 2', {'base': 95267, 'territory': 'A', 'age': 16, 'symbol': 6, 'cars': 2, 'fee': 2500}, 163263], ['random rating 3', {'base': 65141, 'territory': 'A', 'age': 16, 'symbol': 5, 'cars': 2, 'fee': 1500}, 107028], ['top symbol relativity', {'base': 50001, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85877], ['half-cent rounds up', {'base': 60003, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 71503], ['sub-half cent rounds down', {'base': 40011, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 48513]], [['youthful band ends at 24', {'base': 65596, 'territory': 'B', 'age': 24, 'symbol': 4, 'cars': 1, 'fee': 1500}, 131626], ['age 25 leaves youthful band', {'base': 53332, 'territory': 'C', 'age': 25, 'symbol': 6, 'cars': 1, 'fee': 1500}, 88165], ['senior boundary 65', {'base': 72267, 'territory': 'B', 'age': 65, 'symbol': 9, 'cars': 2, 'fee': 0}, 125658], ['two cars earn multi-car discount', {'base': 46182, 'territory': 'A', 'age': 53, 'symbol': 1, 'cars': 2, 'fee': 2500}, 44064], ['single car control', {'base': 42325, 'territory': 'C', 'age': 57, 'symbol': 4, 'cars': 1, 'fee': 2500}, 65776], ['discounted policy below minimum', {'base': 31359, 'territory': 'A', 'age': 40, 'symbol': 1, 'cars': 3, 'fee': 1500}, 31500], ['unknown territory rejected', {'base': 70758, 'territory': 'Z', 'age': 40, 'symbol': 3, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 74254, 'territory': 'B', 'age': 15, 'symbol': 2, 'cars': 1, 'fee': 0}, 'invalid age'], ['random rating 0', {'base': 35490, 'territory': 'C', 'age': 47, 'symbol': 10, 'cars': 1, 'fee': 0}, 66899], ['random rating 1', {'base': 93585, 'territory': 'B', 'age': 47, 'symbol': 2, 'cars': 1, 'fee': 0}, 113004], ['random rating 2', {'base': 54005, 'territory': 'C', 'age': 47, 'symbol': 8, 'cars': 1, 'fee': 0}, 94779], ['random rating 3', {'base': 35309, 'territory': 'C', 'age': 20, 'symbol': 6, 'cars': 2, 'fee': 1500}, 78959], ['top symbol relativity', {'base': 50002, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 1500}, 84878], ['half-cent rounds up', {'base': 60007, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69008], ['sub-half cent rounds down', {'base': 40031, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 46036]], [['youthful band ends at 24', {'base': 33706, 'territory': 'B', 'age': 24, 'symbol': 1, 'cars': 1, 'fee': 1500}, 59643], ['age 25 leaves youthful band', {'base': 47580, 'territory': 'C', 'age': 25, 'symbol': 4, 'cars': 1, 'fee': 1500}, 72632], ['senior boundary 65', {'base': 45782, 'territory': 'A', 'age': 65, 'symbol': 7, 'cars': 2, 'fee': 1500}, 65778], ['two cars earn multi-car discount', {'base': 69933, 'territory': 'C', 'age': 45, 'symbol': 3, 'cars': 2, 'fee': 2500}, 92504], ['single car control', {'base': 81532, 'territory': 'A', 'age': 57, 'symbol': 10, 'cars': 1, 'fee': 1500}, 119721], ['discounted policy below minimum', {'base': 31838, 'territory': 'A', 'age': 49, 'symbol': 1, 'cars': 3, 'fee': 1500}, 31500], ['unknown territory rejected', {'base': 23484, 'territory': 'Z', 'age': 40, 'symbol': 5, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 20672, 'territory': 'A', 'age': 15, 'symbol': 8, 'cars': 1, 'fee': 1500}, 'invalid age'], ['random rating 0', {'base': 54283, 'territory': 'B', 'age': 16, 'symbol': 7, 'cars': 2, 'fee': 0}, 109557], ['random rating 1', {'base': 85283, 'territory': 'B', 'age': 33, 'symbol': 7, 'cars': 3, 'fee': 1500}, 116248], ['random rating 2', {'base': 97243, 'territory': 'A', 'age': 47, 'symbol': 10, 'cars': 2, 'fee': 1500}, 128402], ['random rating 3', {'base': 47342, 'territory': 'B', 'age': 70, 'symbol': 9, 'cars': 3, 'fee': 1500}, 83818], ['top symbol relativity', {'base': 50003, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85880], ['half-cent rounds up', {'base': 60011, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69013], ['sub-half cent rounds down', {'base': 40051, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 46059]], [['youthful band ends at 24', {'base': 49705, 'territory': 'B', 'age': 24, 'symbol': 10, 'cars': 1, 'fee': 0}, 124325], ['age 25 leaves youthful band', {'base': 77136, 'territory': 'B', 'age': 25, 'symbol': 9, 'cars': 1, 'fee': 2500}, 126689], ['senior boundary 65', {'base': 48566, 'territory': 'C', 'age': 65, 'symbol': 7, 'cars': 1, 'fee': 2500}, 100992], ['two cars earn multi-car discount', {'base': 86089, 'territory': 'C', 'age': 58, 'symbol': 4, 'cars': 2, 'fee': 2500}, 118333], ['single car control', {'base': 65782, 'territory': 'C', 'age': 60, 'symbol': 5, 'cars': 1, 'fee': 0}, 102620], ['discounted policy below minimum', {'base': 30193, 'territory': 'A', 'age': 34, 'symbol': 1, 'cars': 3, 'fee': 2500}, 32500], ['unknown territory rejected', {'base': 37853, 'territory': 'Z', 'age': 40, 'symbol': 5, 'cars': 1, 'fee': 2500}, 'invalid territory'], ['under-age applicant rejected', {'base': 85063, 'territory': 'C', 'age': 15, 'symbol': 9, 'cars': 1, 'fee': 1500}, 'invalid age'], ['random rating 0', {'base': 81605, 'territory': 'C', 'age': 70, 'symbol': 3, 'cars': 1, 'fee': 2500}, 142534], ['random rating 1', {'base': 50741, 'territory': 'C', 'age': 16, 'symbol': 9, 'cars': 1, 'fee': 0}, 138523], ['random rating 2', {'base': 88025, 'territory': 'B', 'age': 33, 'symbol': 5, 'cars': 1, 'fee': 0}, 121475], ['random rating 3', {'base': 60769, 'territory': 'C', 'age': 47, 'symbol': 8, 'cars': 3, 'fee': 1500}, 97485], ['top symbol relativity', {'base': 50004, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85882], ['half-cent rounds up', {'base': 60015, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69017], ['sub-half cent rounds down', {'base': 40071, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 48582]], [['youthful band ends at 24', {'base': 83462, 'territory': 'C', 'age': 24, 'symbol': 4, 'cars': 1, 'fee': 0}, 187164], ['age 25 leaves youthful band', {'base': 23842, 'territory': 'A', 'age': 25, 'symbol': 10, 'cars': 1, 'fee': 2500}, 37071], ['senior boundary 65', {'base': 43695, 'territory': 'C', 'age': 65, 'symbol': 10, 'cars': 2, 'fee': 1500}, 90454], ['two cars earn multi-car discount', {'base': 87356, 'territory': 'A', 'age': 42, 'symbol': 8, 'cars': 2, 'fee': 2500}, 108638], ['single car control', {'base': 73244, 'territory': 'B', 'age': 41, 'symbol': 8, 'cars': 1, 'fee': 0}, 113711], ['discounted policy below minimum', {'base': 30044, 'territory': 'A', 'age': 31, 'symbol': 1, 'cars': 3, 'fee': 0}, 30000], ['unknown territory rejected', {'base': 50727, 'territory': 'Z', 'age': 40, 'symbol': 6, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 35931, 'territory': 'A', 'age': 15, 'symbol': 3, 'cars': 1, 'fee': 1500}, 'invalid age'], ['random rating 0', {'base': 90411, 'territory': 'C', 'age': 70, 'symbol': 10, 'cars': 3, 'fee': 2500}, 186559], ['random rating 1', {'base': 60039, 'territory': 'C', 'age': 33, 'symbol': 10, 'cars': 2, 'fee': 2500}, 104356], ['random rating 2', {'base': 58926, 'territory': 'A', 'age': 47, 'symbol': 9, 'cars': 2, 'fee': 1500}, 75747], ['random rating 3', {'base': 56741, 'territory': 'B', 'age': 16, 'symbol': 6, 'cars': 1, 'fee': 2500}, 124848], ['top symbol relativity', {'base': 50005, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85883], ['half-cent rounds up', {'base': 60019, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69022], ['sub-half cent rounds down', {'base': 40091, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 48605]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| youthful band ends at 24 | 136368 | 136368 | Passed |
| age 25 leaves youthful band | 77527 | 52185 | Failed |
| senior boundary 65 | 45912 | 45912 | Passed |
| two cars earn multi-car discount | 65058 | 65058 | Passed |
| single car control | 58246 | 58246 | Passed |
| discounted policy below minimum | 30000 | 30000 | Passed |
| unknown territory rejected | invalid territory | invalid territory | Passed |
| under-age applicant rejected | invalid age | invalid age | Passed |
| random rating 0 | 49909 | 49909 | Passed |
| random rating 1 | 85673 | 85673 | Passed |
| random rating 2 | 163263 | 163263 | Passed |
| random rating 3 | 107028 | 107028 | Passed |
| top symbol relativity | 85877 | 85877 | Passed |
| half-cent rounds up | 71503 | 71503 | Passed |
| sub-half cent rounds down | 48513 | 48513 | Passed |
SHA-256 / 02903077508adab91fedc075b1755e7b8dcf77b6faa3d3e5c21a22065291165c
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):
T={'A':Fraction(1),'B':Fraction(115,100),'C':Fraction(130,100)}
if x['territory'] not in T: return 'invalid territory'
age=x['age']
if age<16: return 'invalid age'
if age<24: af=Fraction(150,100)
elif age<65: af=Fraction(1)
else: af=Fraction(120,100)
sf=1+Fraction(5,100)*(x['symbol']-1)
disc=Fraction(90,100) if x['cars']>=2 else Fraction(1)
rated=x['base']*T[x['territory']]*af*sf
rated=rated*disc
rated=int(rated+Fraction(1,2))
rated=max(rated,30000)
return rated+x['fee']
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['youthful band ends at 24', {'base': 54520, 'territory': 'B', 'age': 24, 'symbol': 10, 'cars': 1, 'fee': 0}, 136368], ['age 25 leaves youthful band', {'base': 48271, 'territory': 'A', 'age': 25, 'symbol': 2, 'cars': 1, 'fee': 1500}, 52185], ['senior boundary 65', {'base': 31490, 'territory': 'A', 'age': 65, 'symbol': 8, 'cars': 2, 'fee': 0}, 45912], ['two cars earn multi-car discount', {'base': 53546, 'territory': 'A', 'age': 55, 'symbol': 8, 'cars': 2, 'fee': 0}, 65058], ['single car control', {'base': 41604, 'territory': 'A', 'age': 56, 'symbol': 9, 'cars': 1, 'fee': 0}, 58246], ['discounted policy below minimum', {'base': 30977, 'territory': 'A', 'age': 39, 'symbol': 1, 'cars': 3, 'fee': 0}, 30000], ['unknown territory rejected', {'base': 78746, 'territory': 'Z', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 84653, 'territory': 'C', 'age': 15, 'symbol': 2, 'cars': 1, 'fee': 2500}, 'invalid age'], ['random rating 0', {'base': 34126, 'territory': 'C', 'age': 33, 'symbol': 6, 'cars': 3, 'fee': 0}, 49909], ['random rating 1', {'base': 62350, 'territory': 'A', 'age': 16, 'symbol': 1, 'cars': 3, 'fee': 1500}, 85673], ['random rating 2', {'base': 95267, 'territory': 'A', 'age': 16, 'symbol': 6, 'cars': 2, 'fee': 2500}, 163263], ['random rating 3', {'base': 65141, 'territory': 'A', 'age': 16, 'symbol': 5, 'cars': 2, 'fee': 1500}, 107028], ['top symbol relativity', {'base': 50001, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85877], ['half-cent rounds up', {'base': 60003, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 71503], ['sub-half cent rounds down', {'base': 40011, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 48513]], [['youthful band ends at 24', {'base': 65596, 'territory': 'B', 'age': 24, 'symbol': 4, 'cars': 1, 'fee': 1500}, 131626], ['age 25 leaves youthful band', {'base': 53332, 'territory': 'C', 'age': 25, 'symbol': 6, 'cars': 1, 'fee': 1500}, 88165], ['senior boundary 65', {'base': 72267, 'territory': 'B', 'age': 65, 'symbol': 9, 'cars': 2, 'fee': 0}, 125658], ['two cars earn multi-car discount', {'base': 46182, 'territory': 'A', 'age': 53, 'symbol': 1, 'cars': 2, 'fee': 2500}, 44064], ['single car control', {'base': 42325, 'territory': 'C', 'age': 57, 'symbol': 4, 'cars': 1, 'fee': 2500}, 65776], ['discounted policy below minimum', {'base': 31359, 'territory': 'A', 'age': 40, 'symbol': 1, 'cars': 3, 'fee': 1500}, 31500], ['unknown territory rejected', {'base': 70758, 'territory': 'Z', 'age': 40, 'symbol': 3, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 74254, 'territory': 'B', 'age': 15, 'symbol': 2, 'cars': 1, 'fee': 0}, 'invalid age'], ['random rating 0', {'base': 35490, 'territory': 'C', 'age': 47, 'symbol': 10, 'cars': 1, 'fee': 0}, 66899], ['random rating 1', {'base': 93585, 'territory': 'B', 'age': 47, 'symbol': 2, 'cars': 1, 'fee': 0}, 113004], ['random rating 2', {'base': 54005, 'territory': 'C', 'age': 47, 'symbol': 8, 'cars': 1, 'fee': 0}, 94779], ['random rating 3', {'base': 35309, 'territory': 'C', 'age': 20, 'symbol': 6, 'cars': 2, 'fee': 1500}, 78959], ['top symbol relativity', {'base': 50002, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 1500}, 84878], ['half-cent rounds up', {'base': 60007, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69008], ['sub-half cent rounds down', {'base': 40031, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 46036]], [['youthful band ends at 24', {'base': 33706, 'territory': 'B', 'age': 24, 'symbol': 1, 'cars': 1, 'fee': 1500}, 59643], ['age 25 leaves youthful band', {'base': 47580, 'territory': 'C', 'age': 25, 'symbol': 4, 'cars': 1, 'fee': 1500}, 72632], ['senior boundary 65', {'base': 45782, 'territory': 'A', 'age': 65, 'symbol': 7, 'cars': 2, 'fee': 1500}, 65778], ['two cars earn multi-car discount', {'base': 69933, 'territory': 'C', 'age': 45, 'symbol': 3, 'cars': 2, 'fee': 2500}, 92504], ['single car control', {'base': 81532, 'territory': 'A', 'age': 57, 'symbol': 10, 'cars': 1, 'fee': 1500}, 119721], ['discounted policy below minimum', {'base': 31838, 'territory': 'A', 'age': 49, 'symbol': 1, 'cars': 3, 'fee': 1500}, 31500], ['unknown territory rejected', {'base': 23484, 'territory': 'Z', 'age': 40, 'symbol': 5, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 20672, 'territory': 'A', 'age': 15, 'symbol': 8, 'cars': 1, 'fee': 1500}, 'invalid age'], ['random rating 0', {'base': 54283, 'territory': 'B', 'age': 16, 'symbol': 7, 'cars': 2, 'fee': 0}, 109557], ['random rating 1', {'base': 85283, 'territory': 'B', 'age': 33, 'symbol': 7, 'cars': 3, 'fee': 1500}, 116248], ['random rating 2', {'base': 97243, 'territory': 'A', 'age': 47, 'symbol': 10, 'cars': 2, 'fee': 1500}, 128402], ['random rating 3', {'base': 47342, 'territory': 'B', 'age': 70, 'symbol': 9, 'cars': 3, 'fee': 1500}, 83818], ['top symbol relativity', {'base': 50003, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85880], ['half-cent rounds up', {'base': 60011, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69013], ['sub-half cent rounds down', {'base': 40051, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 46059]], [['youthful band ends at 24', {'base': 49705, 'territory': 'B', 'age': 24, 'symbol': 10, 'cars': 1, 'fee': 0}, 124325], ['age 25 leaves youthful band', {'base': 77136, 'territory': 'B', 'age': 25, 'symbol': 9, 'cars': 1, 'fee': 2500}, 126689], ['senior boundary 65', {'base': 48566, 'territory': 'C', 'age': 65, 'symbol': 7, 'cars': 1, 'fee': 2500}, 100992], ['two cars earn multi-car discount', {'base': 86089, 'territory': 'C', 'age': 58, 'symbol': 4, 'cars': 2, 'fee': 2500}, 118333], ['single car control', {'base': 65782, 'territory': 'C', 'age': 60, 'symbol': 5, 'cars': 1, 'fee': 0}, 102620], ['discounted policy below minimum', {'base': 30193, 'territory': 'A', 'age': 34, 'symbol': 1, 'cars': 3, 'fee': 2500}, 32500], ['unknown territory rejected', {'base': 37853, 'territory': 'Z', 'age': 40, 'symbol': 5, 'cars': 1, 'fee': 2500}, 'invalid territory'], ['under-age applicant rejected', {'base': 85063, 'territory': 'C', 'age': 15, 'symbol': 9, 'cars': 1, 'fee': 1500}, 'invalid age'], ['random rating 0', {'base': 81605, 'territory': 'C', 'age': 70, 'symbol': 3, 'cars': 1, 'fee': 2500}, 142534], ['random rating 1', {'base': 50741, 'territory': 'C', 'age': 16, 'symbol': 9, 'cars': 1, 'fee': 0}, 138523], ['random rating 2', {'base': 88025, 'territory': 'B', 'age': 33, 'symbol': 5, 'cars': 1, 'fee': 0}, 121475], ['random rating 3', {'base': 60769, 'territory': 'C', 'age': 47, 'symbol': 8, 'cars': 3, 'fee': 1500}, 97485], ['top symbol relativity', {'base': 50004, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85882], ['half-cent rounds up', {'base': 60015, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69017], ['sub-half cent rounds down', {'base': 40071, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 48582]], [['youthful band ends at 24', {'base': 83462, 'territory': 'C', 'age': 24, 'symbol': 4, 'cars': 1, 'fee': 0}, 187164], ['age 25 leaves youthful band', {'base': 23842, 'territory': 'A', 'age': 25, 'symbol': 10, 'cars': 1, 'fee': 2500}, 37071], ['senior boundary 65', {'base': 43695, 'territory': 'C', 'age': 65, 'symbol': 10, 'cars': 2, 'fee': 1500}, 90454], ['two cars earn multi-car discount', {'base': 87356, 'territory': 'A', 'age': 42, 'symbol': 8, 'cars': 2, 'fee': 2500}, 108638], ['single car control', {'base': 73244, 'territory': 'B', 'age': 41, 'symbol': 8, 'cars': 1, 'fee': 0}, 113711], ['discounted policy below minimum', {'base': 30044, 'territory': 'A', 'age': 31, 'symbol': 1, 'cars': 3, 'fee': 0}, 30000], ['unknown territory rejected', {'base': 50727, 'territory': 'Z', 'age': 40, 'symbol': 6, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 35931, 'territory': 'A', 'age': 15, 'symbol': 3, 'cars': 1, 'fee': 1500}, 'invalid age'], ['random rating 0', {'base': 90411, 'territory': 'C', 'age': 70, 'symbol': 10, 'cars': 3, 'fee': 2500}, 186559], ['random rating 1', {'base': 60039, 'territory': 'C', 'age': 33, 'symbol': 10, 'cars': 2, 'fee': 2500}, 104356], ['random rating 2', {'base': 58926, 'territory': 'A', 'age': 47, 'symbol': 9, 'cars': 2, 'fee': 1500}, 75747], ['random rating 3', {'base': 56741, 'territory': 'B', 'age': 16, 'symbol': 6, 'cars': 1, 'fee': 2500}, 124848], ['top symbol relativity', {'base': 50005, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85883], ['half-cent rounds up', {'base': 60019, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69022], ['sub-half cent rounds down', {'base': 40091, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 48605]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| youthful band ends at 24 | 90912 | 136368 | Failed |
| age 25 leaves youthful band | 52185 | 52185 | Passed |
| senior boundary 65 | 45912 | 45912 | Passed |
| two cars earn multi-car discount | 65058 | 65058 | Passed |
| single car control | 58246 | 58246 | Passed |
| discounted policy below minimum | 30000 | 30000 | Passed |
| unknown territory rejected | invalid territory | invalid territory | Passed |
| under-age applicant rejected | invalid age | invalid age | Passed |
| random rating 0 | 49909 | 49909 | Passed |
| random rating 1 | 85673 | 85673 | Passed |
| random rating 2 | 163263 | 163263 | Passed |
| random rating 3 | 107028 | 107028 | Passed |
| top symbol relativity | 85877 | 85877 | Passed |
| half-cent rounds up | 71503 | 71503 | Passed |
| sub-half cent rounds down | 48513 | 48513 | Passed |
SHA-256 / 8fda90d8752456fb819a03c6100f82d776f7acb21854410451e9a5eda6833574
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):
T={'A':Fraction(1),'B':Fraction(115,100),'C':Fraction(130,100)}
if x['territory'] not in T: return 'invalid territory'
age=x['age']
if age<16: return 'invalid age'
if age<25: af=Fraction(150,100)
elif age<65: af=Fraction(1)
else: af=Fraction(120,100)
sf=1+Fraction(5,100)*(x['symbol']-1)
disc=Fraction(90,100) if x['cars']>=2 else Fraction(1)
rated=x['base']*T[x['territory']]*af*sf
rated=rated*disc
rated=int(rated+Fraction(1,2))
rated=max(rated,30000)
return rated+x['fee']
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['youthful band ends at 24', {'base': 54520, 'territory': 'B', 'age': 24, 'symbol': 10, 'cars': 1, 'fee': 0}, 136368], ['age 25 leaves youthful band', {'base': 48271, 'territory': 'A', 'age': 25, 'symbol': 2, 'cars': 1, 'fee': 1500}, 52185], ['senior boundary 65', {'base': 31490, 'territory': 'A', 'age': 65, 'symbol': 8, 'cars': 2, 'fee': 0}, 45912], ['two cars earn multi-car discount', {'base': 53546, 'territory': 'A', 'age': 55, 'symbol': 8, 'cars': 2, 'fee': 0}, 65058], ['single car control', {'base': 41604, 'territory': 'A', 'age': 56, 'symbol': 9, 'cars': 1, 'fee': 0}, 58246], ['discounted policy below minimum', {'base': 30977, 'territory': 'A', 'age': 39, 'symbol': 1, 'cars': 3, 'fee': 0}, 30000], ['unknown territory rejected', {'base': 78746, 'territory': 'Z', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 84653, 'territory': 'C', 'age': 15, 'symbol': 2, 'cars': 1, 'fee': 2500}, 'invalid age'], ['random rating 0', {'base': 34126, 'territory': 'C', 'age': 33, 'symbol': 6, 'cars': 3, 'fee': 0}, 49909], ['random rating 1', {'base': 62350, 'territory': 'A', 'age': 16, 'symbol': 1, 'cars': 3, 'fee': 1500}, 85673], ['random rating 2', {'base': 95267, 'territory': 'A', 'age': 16, 'symbol': 6, 'cars': 2, 'fee': 2500}, 163263], ['random rating 3', {'base': 65141, 'territory': 'A', 'age': 16, 'symbol': 5, 'cars': 2, 'fee': 1500}, 107028], ['top symbol relativity', {'base': 50001, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85877], ['half-cent rounds up', {'base': 60003, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 71503], ['sub-half cent rounds down', {'base': 40011, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 48513]], [['youthful band ends at 24', {'base': 65596, 'territory': 'B', 'age': 24, 'symbol': 4, 'cars': 1, 'fee': 1500}, 131626], ['age 25 leaves youthful band', {'base': 53332, 'territory': 'C', 'age': 25, 'symbol': 6, 'cars': 1, 'fee': 1500}, 88165], ['senior boundary 65', {'base': 72267, 'territory': 'B', 'age': 65, 'symbol': 9, 'cars': 2, 'fee': 0}, 125658], ['two cars earn multi-car discount', {'base': 46182, 'territory': 'A', 'age': 53, 'symbol': 1, 'cars': 2, 'fee': 2500}, 44064], ['single car control', {'base': 42325, 'territory': 'C', 'age': 57, 'symbol': 4, 'cars': 1, 'fee': 2500}, 65776], ['discounted policy below minimum', {'base': 31359, 'territory': 'A', 'age': 40, 'symbol': 1, 'cars': 3, 'fee': 1500}, 31500], ['unknown territory rejected', {'base': 70758, 'territory': 'Z', 'age': 40, 'symbol': 3, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 74254, 'territory': 'B', 'age': 15, 'symbol': 2, 'cars': 1, 'fee': 0}, 'invalid age'], ['random rating 0', {'base': 35490, 'territory': 'C', 'age': 47, 'symbol': 10, 'cars': 1, 'fee': 0}, 66899], ['random rating 1', {'base': 93585, 'territory': 'B', 'age': 47, 'symbol': 2, 'cars': 1, 'fee': 0}, 113004], ['random rating 2', {'base': 54005, 'territory': 'C', 'age': 47, 'symbol': 8, 'cars': 1, 'fee': 0}, 94779], ['random rating 3', {'base': 35309, 'territory': 'C', 'age': 20, 'symbol': 6, 'cars': 2, 'fee': 1500}, 78959], ['top symbol relativity', {'base': 50002, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 1500}, 84878], ['half-cent rounds up', {'base': 60007, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69008], ['sub-half cent rounds down', {'base': 40031, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 46036]], [['youthful band ends at 24', {'base': 33706, 'territory': 'B', 'age': 24, 'symbol': 1, 'cars': 1, 'fee': 1500}, 59643], ['age 25 leaves youthful band', {'base': 47580, 'territory': 'C', 'age': 25, 'symbol': 4, 'cars': 1, 'fee': 1500}, 72632], ['senior boundary 65', {'base': 45782, 'territory': 'A', 'age': 65, 'symbol': 7, 'cars': 2, 'fee': 1500}, 65778], ['two cars earn multi-car discount', {'base': 69933, 'territory': 'C', 'age': 45, 'symbol': 3, 'cars': 2, 'fee': 2500}, 92504], ['single car control', {'base': 81532, 'territory': 'A', 'age': 57, 'symbol': 10, 'cars': 1, 'fee': 1500}, 119721], ['discounted policy below minimum', {'base': 31838, 'territory': 'A', 'age': 49, 'symbol': 1, 'cars': 3, 'fee': 1500}, 31500], ['unknown territory rejected', {'base': 23484, 'territory': 'Z', 'age': 40, 'symbol': 5, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 20672, 'territory': 'A', 'age': 15, 'symbol': 8, 'cars': 1, 'fee': 1500}, 'invalid age'], ['random rating 0', {'base': 54283, 'territory': 'B', 'age': 16, 'symbol': 7, 'cars': 2, 'fee': 0}, 109557], ['random rating 1', {'base': 85283, 'territory': 'B', 'age': 33, 'symbol': 7, 'cars': 3, 'fee': 1500}, 116248], ['random rating 2', {'base': 97243, 'territory': 'A', 'age': 47, 'symbol': 10, 'cars': 2, 'fee': 1500}, 128402], ['random rating 3', {'base': 47342, 'territory': 'B', 'age': 70, 'symbol': 9, 'cars': 3, 'fee': 1500}, 83818], ['top symbol relativity', {'base': 50003, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85880], ['half-cent rounds up', {'base': 60011, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69013], ['sub-half cent rounds down', {'base': 40051, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 46059]], [['youthful band ends at 24', {'base': 49705, 'territory': 'B', 'age': 24, 'symbol': 10, 'cars': 1, 'fee': 0}, 124325], ['age 25 leaves youthful band', {'base': 77136, 'territory': 'B', 'age': 25, 'symbol': 9, 'cars': 1, 'fee': 2500}, 126689], ['senior boundary 65', {'base': 48566, 'territory': 'C', 'age': 65, 'symbol': 7, 'cars': 1, 'fee': 2500}, 100992], ['two cars earn multi-car discount', {'base': 86089, 'territory': 'C', 'age': 58, 'symbol': 4, 'cars': 2, 'fee': 2500}, 118333], ['single car control', {'base': 65782, 'territory': 'C', 'age': 60, 'symbol': 5, 'cars': 1, 'fee': 0}, 102620], ['discounted policy below minimum', {'base': 30193, 'territory': 'A', 'age': 34, 'symbol': 1, 'cars': 3, 'fee': 2500}, 32500], ['unknown territory rejected', {'base': 37853, 'territory': 'Z', 'age': 40, 'symbol': 5, 'cars': 1, 'fee': 2500}, 'invalid territory'], ['under-age applicant rejected', {'base': 85063, 'territory': 'C', 'age': 15, 'symbol': 9, 'cars': 1, 'fee': 1500}, 'invalid age'], ['random rating 0', {'base': 81605, 'territory': 'C', 'age': 70, 'symbol': 3, 'cars': 1, 'fee': 2500}, 142534], ['random rating 1', {'base': 50741, 'territory': 'C', 'age': 16, 'symbol': 9, 'cars': 1, 'fee': 0}, 138523], ['random rating 2', {'base': 88025, 'territory': 'B', 'age': 33, 'symbol': 5, 'cars': 1, 'fee': 0}, 121475], ['random rating 3', {'base': 60769, 'territory': 'C', 'age': 47, 'symbol': 8, 'cars': 3, 'fee': 1500}, 97485], ['top symbol relativity', {'base': 50004, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85882], ['half-cent rounds up', {'base': 60015, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69017], ['sub-half cent rounds down', {'base': 40071, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 48582]], [['youthful band ends at 24', {'base': 83462, 'territory': 'C', 'age': 24, 'symbol': 4, 'cars': 1, 'fee': 0}, 187164], ['age 25 leaves youthful band', {'base': 23842, 'territory': 'A', 'age': 25, 'symbol': 10, 'cars': 1, 'fee': 2500}, 37071], ['senior boundary 65', {'base': 43695, 'territory': 'C', 'age': 65, 'symbol': 10, 'cars': 2, 'fee': 1500}, 90454], ['two cars earn multi-car discount', {'base': 87356, 'territory': 'A', 'age': 42, 'symbol': 8, 'cars': 2, 'fee': 2500}, 108638], ['single car control', {'base': 73244, 'territory': 'B', 'age': 41, 'symbol': 8, 'cars': 1, 'fee': 0}, 113711], ['discounted policy below minimum', {'base': 30044, 'territory': 'A', 'age': 31, 'symbol': 1, 'cars': 3, 'fee': 0}, 30000], ['unknown territory rejected', {'base': 50727, 'territory': 'Z', 'age': 40, 'symbol': 6, 'cars': 1, 'fee': 0}, 'invalid territory'], ['under-age applicant rejected', {'base': 35931, 'territory': 'A', 'age': 15, 'symbol': 3, 'cars': 1, 'fee': 1500}, 'invalid age'], ['random rating 0', {'base': 90411, 'territory': 'C', 'age': 70, 'symbol': 10, 'cars': 3, 'fee': 2500}, 186559], ['random rating 1', {'base': 60039, 'territory': 'C', 'age': 33, 'symbol': 10, 'cars': 2, 'fee': 2500}, 104356], ['random rating 2', {'base': 58926, 'territory': 'A', 'age': 47, 'symbol': 9, 'cars': 2, 'fee': 1500}, 75747], ['random rating 3', {'base': 56741, 'territory': 'B', 'age': 16, 'symbol': 6, 'cars': 1, 'fee': 2500}, 124848], ['top symbol relativity', {'base': 50005, 'territory': 'B', 'age': 40, 'symbol': 10, 'cars': 1, 'fee': 2500}, 85883], ['half-cent rounds up', {'base': 60019, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 0}, 69022], ['sub-half cent rounds down', {'base': 40091, 'territory': 'B', 'age': 40, 'symbol': 1, 'cars': 1, 'fee': 2500}, 48605]]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| youthful band ends at 24 | 136368 | 136368 | Passed |
| age 25 leaves youthful band | 52185 | 52185 | Passed |
| senior boundary 65 | 45912 | 45912 | Passed |
| two cars earn multi-car discount | 65058 | 65058 | Passed |
| single car control | 58246 | 58246 | Passed |
| discounted policy below minimum | 30000 | 30000 | Passed |
| unknown territory rejected | invalid territory | invalid territory | Passed |
| under-age applicant rejected | invalid age | invalid age | Passed |
| random rating 0 | 49909 | 49909 | Passed |
| random rating 1 | 85673 | 85673 | Passed |
| random rating 2 | 163263 | 163263 | Passed |
| random rating 3 | 107028 | 107028 | Passed |
| top symbol relativity | 85877 | 85877 | Passed |
| half-cent rounds up | 71503 | 71503 | Passed |
| sub-half cent rounds down | 48513 | 48513 | Passed |
SHA-256 / b4b5f98603af34056fc5f928b0387d6ea336bc6494c930b76e129db98fd012b8
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.607584+00:00.
Case digest / 5dba9a3fcf285da137a22a5a73b1879d882561a853bf645d6d3526bb26a4c85a