broken_source:
"""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)

source:
"""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)

prompt:
A 25-year-old driver is charged the 1.50 youthful factor.

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.

split: open-access


broken_source:
"""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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""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']>=1 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)

prompt:
A household with exactly two cars pays the undiscounted premium.

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.

split: open-access


broken_source:
"""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']
    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)

source:
"""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']-2)
    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)

prompt:
Every vehicle symbol is rated one step too high; symbol 1 is not the unit relativity.

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.

split: open-access


broken_source:
"""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)
    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)

source:
"""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=math.ceil(rated)
    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)

prompt:
Premiums with a fractional cent of one half or more come out one cent low.

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.

split: open-access