broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    bands = [(25, 5), (30, 6), (35, 8), (40, 9), (45, 10), (50, 15), (55, 23), (60, 43), (65, 66), (70, 127)]
    rate = 206
    for upper, r in bands:
        if x['age'] < upper:
            rate = r
            break
    excess = max(0, x['coverage'])
    cost = Fraction(excess * rate * x['months'], 100000)
    imputed = max(0, cost - x['employee_paid'])
    return math.floor(imputed + Fraction(1, 2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'coverage': 31951582, 'age': 24, 'months': 2, 'employee_paid': 0}, 2695), ('regression', {'coverage': 5000000, 'age': 30, 'months': 6, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 5000000, 'age': 64, 'months': 3, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368), ('normal control', {'coverage': 7307633, 'age': 24, 'months': 3, 'employee_paid': 19462}, 0), ('normal control', {'coverage': 4843457, 'age': 30, 'months': 9, 'employee_paid': 37040}, 0), ('normal control', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('normal control', {'coverage': 22529249, 'age': 29, 'months': 1, 'employee_paid': 38785}, 0)], [('regression', {'coverage': 5000000, 'age': 30, 'months': 6, 'employee_paid': 0}, 0), ('regression', {'coverage': 5000000, 'age': 64, 'months': 3, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368), ('partial-repair probe', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('normal control', {'coverage': 9261111, 'age': 29, 'months': 1, 'employee_paid': 24425}, 0), ('normal control', {'coverage': 20304981, 'age': 29, 'months': 10, 'employee_paid': 12373}, 0), ('normal control', {'coverage': 635952, 'age': 25, 'months': 4, 'employee_paid': 16597}, 0), ('normal control', {'coverage': 5000000, 'age': 29, 'months': 2, 'employee_paid': 22644}, 0)], [('regression', {'coverage': 5000000, 'age': 64, 'months': 3, 'employee_paid': 0}, 0), ('regression', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368), ('partial-repair probe', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 26680167, 'age': 24, 'months': 8, 'employee_paid': 0}, 8672), ('normal control', {'coverage': 15550480, 'age': 24, 'months': 6, 'employee_paid': 26462}, 0), ('normal control', {'coverage': 10839712, 'age': 47, 'months': 6, 'employee_paid': 13304}, 0), ('normal control', {'coverage': 5000000, 'age': 25, 'months': 6, 'employee_paid': 12164}, 0), ('normal control', {'coverage': 25580732, 'age': 25, 'months': 5, 'employee_paid': 10831}, 0)], [('regression', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368), ('regression', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 16856564, 'age': 70, 'months': 8, 'employee_paid': 0}, 195396), ('partial-repair probe', {'coverage': 9181727, 'age': 25, 'months': 6, 'employee_paid': 0}, 1505), ('normal control', {'coverage': 37417908, 'age': 30, 'months': 2, 'employee_paid': 18235}, 0), ('normal control', {'coverage': 23651725, 'age': 29, 'months': 9, 'employee_paid': 22226}, 0), ('normal control', {'coverage': 5000000, 'age': 29, 'months': 9, 'employee_paid': 46974}, 0), ('normal control', {'coverage': 5000000, 'age': 30, 'months': 4, 'employee_paid': 34676}, 0)], [('regression', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('regression', {'coverage': 26680167, 'age': 24, 'months': 8, 'employee_paid': 0}, 8672), ('partial-repair probe', {'coverage': 20685038, 'age': 29, 'months': 4, 'employee_paid': 4881}, 0), ('partial-repair probe', {'coverage': 15762067, 'age': 70, 'months': 10, 'employee_paid': 0}, 221699), ('normal control', {'coverage': 20510722, 'age': 24, 'months': 2, 'employee_paid': 48846}, 0), ('normal control', {'coverage': 24414800, 'age': 24, 'months': 4, 'employee_paid': 35815}, 0), ('normal control', {'coverage': 9498973, 'age': 24, 'months': 7, 'employee_paid': 18100}, 0), ('normal control', {'coverage': 22999814, 'age': 29, 'months': 10, 'employee_paid': 30014}, 0)]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    bands = [(25, 5), (30, 6), (35, 8), (40, 9), (45, 10), (50, 15), (55, 23), (60, 43), (65, 66), (70, 127)]
    rate = 206
    for upper, r in bands:
        if x['age'] < upper:
            rate = r
            break
    excess = max(0, x['coverage'] - 50000)
    cost = Fraction(excess * rate * x['months'], 100000)
    imputed = max(0, cost - x['employee_paid'])
    return math.floor(imputed + Fraction(1, 2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'coverage': 31951582, 'age': 24, 'months': 2, 'employee_paid': 0}, 2695), ('regression', {'coverage': 5000000, 'age': 30, 'months': 6, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 5000000, 'age': 64, 'months': 3, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368), ('normal control', {'coverage': 7307633, 'age': 24, 'months': 3, 'employee_paid': 19462}, 0), ('normal control', {'coverage': 4843457, 'age': 30, 'months': 9, 'employee_paid': 37040}, 0), ('normal control', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('normal control', {'coverage': 22529249, 'age': 29, 'months': 1, 'employee_paid': 38785}, 0)], [('regression', {'coverage': 5000000, 'age': 30, 'months': 6, 'employee_paid': 0}, 0), ('regression', {'coverage': 5000000, 'age': 64, 'months': 3, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368), ('partial-repair probe', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('normal control', {'coverage': 9261111, 'age': 29, 'months': 1, 'employee_paid': 24425}, 0), ('normal control', {'coverage': 20304981, 'age': 29, 'months': 10, 'employee_paid': 12373}, 0), ('normal control', {'coverage': 635952, 'age': 25, 'months': 4, 'employee_paid': 16597}, 0), ('normal control', {'coverage': 5000000, 'age': 29, 'months': 2, 'employee_paid': 22644}, 0)], [('regression', {'coverage': 5000000, 'age': 64, 'months': 3, 'employee_paid': 0}, 0), ('regression', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368), ('partial-repair probe', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 26680167, 'age': 24, 'months': 8, 'employee_paid': 0}, 8672), ('normal control', {'coverage': 15550480, 'age': 24, 'months': 6, 'employee_paid': 26462}, 0), ('normal control', {'coverage': 10839712, 'age': 47, 'months': 6, 'employee_paid': 13304}, 0), ('normal control', {'coverage': 5000000, 'age': 25, 'months': 6, 'employee_paid': 12164}, 0), ('normal control', {'coverage': 25580732, 'age': 25, 'months': 5, 'employee_paid': 10831}, 0)], [('regression', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368), ('regression', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('partial-repair probe', {'coverage': 16856564, 'age': 70, 'months': 8, 'employee_paid': 0}, 195396), ('partial-repair probe', {'coverage': 9181727, 'age': 25, 'months': 6, 'employee_paid': 0}, 1505), ('normal control', {'coverage': 37417908, 'age': 30, 'months': 2, 'employee_paid': 18235}, 0), ('normal control', {'coverage': 23651725, 'age': 29, 'months': 9, 'employee_paid': 22226}, 0), ('normal control', {'coverage': 5000000, 'age': 29, 'months': 9, 'employee_paid': 46974}, 0), ('normal control', {'coverage': 5000000, 'age': 30, 'months': 4, 'employee_paid': 34676}, 0)], [('regression', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('regression', {'coverage': 26680167, 'age': 24, 'months': 8, 'employee_paid': 0}, 8672), ('partial-repair probe', {'coverage': 20685038, 'age': 29, 'months': 4, 'employee_paid': 4881}, 0), ('partial-repair probe', {'coverage': 15762067, 'age': 70, 'months': 10, 'employee_paid': 0}, 221699), ('normal control', {'coverage': 20510722, 'age': 24, 'months': 2, 'employee_paid': 48846}, 0), ('normal control', {'coverage': 24414800, 'age': 24, 'months': 4, 'employee_paid': 35815}, 0), ('normal control', {'coverage': 9498973, 'age': 24, 'months': 7, 'employee_paid': 18100}, 0), ('normal control', {'coverage': 22999814, 'age': 29, 'months': 10, 'employee_paid': 30014}, 0)]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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:
Employees with modest coverage have imputed income on the first 50,000 of coverage.

Input {coverage cents, age, months, employee_paid}. Monthly cost per 1,000.00 of coverage by age band (<25:5, <30:6, <35:8, <40:9, <45:10, <50:15, <55:23, <60:43, <65:66, <70:127, else 206 cents). Excess = max(0, coverage - 50,000.00). Imputed = max(0, excess/100000*rate*months - employee_paid), half-up. Return imputed cents.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    bands = [(25, 5), (30, 6), (35, 8), (40, 9), (45, 10), (50, 15), (55, 23), (60, 43), (65, 66), (70, 127)]
    rate = 206
    for upper, r in bands:
        if x['age'] < upper:
            rate = r
            break
    excess = max(0, x['coverage'] - 5000000)
    cost = Fraction(excess * rate * x['months'], 100000)
    imputed = cost
    return math.floor(imputed + Fraction(1, 2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'coverage': 7307633, 'age': 24, 'months': 3, 'employee_paid': 19462}, 0), ('regression', {'coverage': 20685038, 'age': 29, 'months': 4, 'employee_paid': 4881}, 0), ('partial-repair probe', {'coverage': 4843457, 'age': 30, 'months': 9, 'employee_paid': 37040}, 0), ('partial-repair probe', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('normal control', {'coverage': 31951582, 'age': 24, 'months': 2, 'employee_paid': 0}, 2695), ('normal control', {'coverage': 5000000, 'age': 30, 'months': 6, 'employee_paid': 0}, 0), ('normal control', {'coverage': 5000000, 'age': 64, 'months': 3, 'employee_paid': 0}, 0), ('normal control', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368)], [('regression', {'coverage': 20685038, 'age': 29, 'months': 4, 'employee_paid': 4881}, 0), ('regression', {'coverage': 45748038, 'age': 25, 'months': 3, 'employee_paid': 2480}, 4855), ('partial-repair probe', {'coverage': 4843457, 'age': 30, 'months': 9, 'employee_paid': 37040}, 0), ('partial-repair probe', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('normal control', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('normal control', {'coverage': 26680167, 'age': 24, 'months': 8, 'employee_paid': 0}, 8672), ('normal control', {'coverage': 16856564, 'age': 70, 'months': 8, 'employee_paid': 0}, 195396), ('normal control', {'coverage': 9181727, 'age': 25, 'months': 6, 'employee_paid': 0}, 1505)], [('regression', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('regression', {'coverage': 45748038, 'age': 25, 'months': 3, 'employee_paid': 2480}, 4855), ('partial-repair probe', {'coverage': 5000000, 'age': 65, 'months': 8, 'employee_paid': 12759}, 0), ('partial-repair probe', {'coverage': 5000000, 'age': 61, 'months': 12, 'employee_paid': 2761}, 0), ('normal control', {'coverage': 15762067, 'age': 70, 'months': 10, 'employee_paid': 0}, 221699), ('normal control', {'coverage': 5000000, 'age': 25, 'months': 6, 'employee_paid': 0}, 0), ('normal control', {'coverage': 46403884, 'age': 30, 'months': 4, 'employee_paid': 0}, 13249), ('normal control', {'coverage': 5153794, 'age': 25, 'months': 6, 'employee_paid': 0}, 55)], [('regression', {'coverage': 22529249, 'age': 29, 'months': 1, 'employee_paid': 38785}, 0), ('regression', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('partial-repair probe', {'coverage': 9261111, 'age': 29, 'months': 1, 'employee_paid': 24425}, 0), ('partial-repair probe', {'coverage': 20304981, 'age': 29, 'months': 10, 'employee_paid': 12373}, 0), ('normal control', {'coverage': 44993212, 'age': 70, 'months': 2, 'employee_paid': 0}, 164772), ('normal control', {'coverage': 20847001, 'age': 64, 'months': 8, 'employee_paid': 0}, 83672), ('normal control', {'coverage': 15471033, 'age': 66, 'months': 5, 'employee_paid': 0}, 66491), ('normal control', {'coverage': 5000000, 'age': 50, 'months': 9, 'employee_paid': 0}, 0)], [('regression', {'coverage': 9261111, 'age': 29, 'months': 1, 'employee_paid': 24425}, 0), ('regression', {'coverage': 22529249, 'age': 29, 'months': 1, 'employee_paid': 38785}, 0), ('partial-repair probe', {'coverage': 20304981, 'age': 29, 'months': 10, 'employee_paid': 12373}, 0), ('partial-repair probe', {'coverage': 635952, 'age': 25, 'months': 4, 'employee_paid': 16597}, 0), ('normal control', {'coverage': 17670130, 'age': 50, 'months': 11, 'employee_paid': 0}, 32055), ('normal control', {'coverage': 40943559, 'age': 30, 'months': 6, 'employee_paid': 0}, 17253), ('normal control', {'coverage': 5000000, 'age': 64, 'months': 12, 'employee_paid': 0}, 0), ('normal control', {'coverage': 5000000, 'age': 27, 'months': 10, 'employee_paid': 0}, 0)]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
    bands = [(25, 5), (30, 6), (35, 8), (40, 9), (45, 10), (50, 15), (55, 23), (60, 43), (65, 66), (70, 127)]
    rate = 206
    for upper, r in bands:
        if x['age'] < upper:
            rate = r
            break
    excess = max(0, x['coverage'] - 5000000)
    cost = Fraction(excess * rate * x['months'], 100000)
    imputed = max(0, cost) - x['employee_paid']
    return math.floor(imputed + Fraction(1, 2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'coverage': 7307633, 'age': 24, 'months': 3, 'employee_paid': 19462}, 0), ('regression', {'coverage': 20685038, 'age': 29, 'months': 4, 'employee_paid': 4881}, 0), ('partial-repair probe', {'coverage': 4843457, 'age': 30, 'months': 9, 'employee_paid': 37040}, 0), ('partial-repair probe', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('normal control', {'coverage': 31951582, 'age': 24, 'months': 2, 'employee_paid': 0}, 2695), ('normal control', {'coverage': 5000000, 'age': 30, 'months': 6, 'employee_paid': 0}, 0), ('normal control', {'coverage': 5000000, 'age': 64, 'months': 3, 'employee_paid': 0}, 0), ('normal control', {'coverage': 23127161, 'age': 70, 'months': 4, 'employee_paid': 0}, 149368)], [('regression', {'coverage': 20685038, 'age': 29, 'months': 4, 'employee_paid': 4881}, 0), ('regression', {'coverage': 45748038, 'age': 25, 'months': 3, 'employee_paid': 2480}, 4855), ('partial-repair probe', {'coverage': 4843457, 'age': 30, 'months': 9, 'employee_paid': 37040}, 0), ('partial-repair probe', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('normal control', {'coverage': 5000000, 'age': 24, 'months': 10, 'employee_paid': 0}, 0), ('normal control', {'coverage': 26680167, 'age': 24, 'months': 8, 'employee_paid': 0}, 8672), ('normal control', {'coverage': 16856564, 'age': 70, 'months': 8, 'employee_paid': 0}, 195396), ('normal control', {'coverage': 9181727, 'age': 25, 'months': 6, 'employee_paid': 0}, 1505)], [('regression', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('regression', {'coverage': 45748038, 'age': 25, 'months': 3, 'employee_paid': 2480}, 4855), ('partial-repair probe', {'coverage': 5000000, 'age': 65, 'months': 8, 'employee_paid': 12759}, 0), ('partial-repair probe', {'coverage': 5000000, 'age': 61, 'months': 12, 'employee_paid': 2761}, 0), ('normal control', {'coverage': 15762067, 'age': 70, 'months': 10, 'employee_paid': 0}, 221699), ('normal control', {'coverage': 5000000, 'age': 25, 'months': 6, 'employee_paid': 0}, 0), ('normal control', {'coverage': 46403884, 'age': 30, 'months': 4, 'employee_paid': 0}, 13249), ('normal control', {'coverage': 5153794, 'age': 25, 'months': 6, 'employee_paid': 0}, 55)], [('regression', {'coverage': 22529249, 'age': 29, 'months': 1, 'employee_paid': 38785}, 0), ('regression', {'coverage': 19400395, 'age': 25, 'months': 7, 'employee_paid': 36789}, 0), ('partial-repair probe', {'coverage': 9261111, 'age': 29, 'months': 1, 'employee_paid': 24425}, 0), ('partial-repair probe', {'coverage': 20304981, 'age': 29, 'months': 10, 'employee_paid': 12373}, 0), ('normal control', {'coverage': 44993212, 'age': 70, 'months': 2, 'employee_paid': 0}, 164772), ('normal control', {'coverage': 20847001, 'age': 64, 'months': 8, 'employee_paid': 0}, 83672), ('normal control', {'coverage': 15471033, 'age': 66, 'months': 5, 'employee_paid': 0}, 66491), ('normal control', {'coverage': 5000000, 'age': 50, 'months': 9, 'employee_paid': 0}, 0)], [('regression', {'coverage': 9261111, 'age': 29, 'months': 1, 'employee_paid': 24425}, 0), ('regression', {'coverage': 22529249, 'age': 29, 'months': 1, 'employee_paid': 38785}, 0), ('partial-repair probe', {'coverage': 20304981, 'age': 29, 'months': 10, 'employee_paid': 12373}, 0), ('partial-repair probe', {'coverage': 635952, 'age': 25, 'months': 4, 'employee_paid': 16597}, 0), ('normal control', {'coverage': 17670130, 'age': 50, 'months': 11, 'employee_paid': 0}, 32055), ('normal control', {'coverage': 40943559, 'age': 30, 'months': 6, 'employee_paid': 0}, 17253), ('normal control', {'coverage': 5000000, 'age': 64, 'months': 12, 'employee_paid': 0}, 0), ('normal control', {'coverage': 5000000, 'age': 27, 'months': 10, 'employee_paid': 0}, 0)]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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:
Employees paying part of the premium after tax still see the full imputed cost.

Input {coverage cents, age, months, employee_paid}. Monthly cost per 1,000.00 of coverage by age band (<25:5, <30:6, <35:8, <40:9, <45:10, <50:15, <55:23, <60:43, <65:66, <70:127, else 206 cents). Excess = max(0, coverage - 50,000.00). Imputed = max(0, excess/100000*rate*months - employee_paid), half-up. Return imputed cents.

split: open-access


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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in sorted(x['claims'], key=lambda c: tuple(c[0])):
        if tuple(date) <= pay:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1]:
        return 'per-form'
    expiry = (active[0][0], 2, 15)
    return 'exempt' if pay <= expiry else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('regression', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('normal control', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default'), ('normal control', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form')], [('regression', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('regression', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default')], [('regression', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('regression', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 11, 25], False], [[2022, 6, 11], True], [[2024, 3, 25], True]], 'pay_date': [2024, 4, 3]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 10, 24], True], [[2022, 6, 19], True], [[2023, 1, 23], False]], 'pay_date': [2022, 10, 24]}, 'exempt'), ('normal control', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form'), ('normal control', {'claims': [[[2023, 4, 9], False], [[2024, 8, 26], False], [[2022, 5, 3], False]], 'pay_date': [2024, 7, 21]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default')], [('regression', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('regression', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 2, 17], True], [[2024, 9, 16], False]], 'pay_date': [2023, 2, 17]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 3, 20], True]], 'pay_date': [2025, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 14], False], [[2024, 8, 7], True], [[2024, 1, 1], True]], 'pay_date': [2023, 9, 14]}, 'per-form'), ('normal control', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default')], [('regression', {'claims': [[[2024, 11, 25], False], [[2022, 6, 11], True], [[2024, 3, 25], True]], 'pay_date': [2024, 4, 3]}, 'exempt'), ('regression', {'claims': [[[2022, 7, 16], True], [[2024, 7, 18], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 9, 8], True], [[2023, 6, 20], True]], 'pay_date': [2023, 9, 8]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 10, 19], True], [[2022, 10, 27], True]], 'pay_date': [2022, 10, 19]}, 'exempt'), ('normal control', {'claims': [[[2024, 12, 15], False], [[2023, 9, 28], False]], 'pay_date': [2025, 2, 3]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2024, 7, 6]}, 'single-default'), ('normal control', {'claims': [[[2022, 1, 12], True], [[2022, 3, 16], True]], 'pay_date': [2024, 5, 17]}, 'single-default'), ('normal control', {'claims': [[[2022, 3, 17], True]], 'pay_date': [2023, 2, 17]}, 'single-default')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in sorted(x['claims'], key=lambda c: tuple(c[0])):
        if tuple(date) <= pay:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1]:
        return 'per-form'
    expiry = (pay[0], 2, 15)
    return 'exempt' if pay <= expiry else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('regression', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('normal control', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default'), ('normal control', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form')], [('regression', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('regression', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default')], [('regression', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('regression', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 11, 25], False], [[2022, 6, 11], True], [[2024, 3, 25], True]], 'pay_date': [2024, 4, 3]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 10, 24], True], [[2022, 6, 19], True], [[2023, 1, 23], False]], 'pay_date': [2022, 10, 24]}, 'exempt'), ('normal control', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form'), ('normal control', {'claims': [[[2023, 4, 9], False], [[2024, 8, 26], False], [[2022, 5, 3], False]], 'pay_date': [2024, 7, 21]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default')], [('regression', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('regression', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 2, 17], True], [[2024, 9, 16], False]], 'pay_date': [2023, 2, 17]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 3, 20], True]], 'pay_date': [2025, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 14], False], [[2024, 8, 7], True], [[2024, 1, 1], True]], 'pay_date': [2023, 9, 14]}, 'per-form'), ('normal control', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default')], [('regression', {'claims': [[[2024, 11, 25], False], [[2022, 6, 11], True], [[2024, 3, 25], True]], 'pay_date': [2024, 4, 3]}, 'exempt'), ('regression', {'claims': [[[2022, 7, 16], True], [[2024, 7, 18], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 9, 8], True], [[2023, 6, 20], True]], 'pay_date': [2023, 9, 8]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 10, 19], True], [[2022, 10, 27], True]], 'pay_date': [2022, 10, 19]}, 'exempt'), ('normal control', {'claims': [[[2024, 12, 15], False], [[2023, 9, 28], False]], 'pay_date': [2025, 2, 3]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2024, 7, 6]}, 'single-default'), ('normal control', {'claims': [[[2022, 1, 12], True], [[2022, 3, 16], True]], 'pay_date': [2024, 5, 17]}, 'single-default'), ('normal control', {'claims': [[[2022, 3, 17], True]], 'pay_date': [2023, 2, 17]}, 'single-default')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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:
Exempt forms filed after mid-February expire immediately.

Input {claims: [[[y,m,d], exempt]], pay_date [y,m,d]}. The active claim is the latest-dated claim on or before the pay date (claims processed by date; equal dates keep input order, last wins). No claim -> 'single-default'. Non-exempt claim -> 'per-form'. Exempt claim is honored through February 15 of the year after it was filed, inclusive; afterwards 'single-default'.

split: open-access


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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in sorted(x['claims'], key=lambda c: tuple(c[0])):
        if tuple(date) <= pay:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1]:
        return 'per-form'
    expiry = (active[0][0] + 1, 2, 15)
    return 'exempt' if pay < expiry else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2022, 7, 16], True], [[2024, 7, 18], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2024, 2, 8], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2022, 3, 17], True]], 'pay_date': [2023, 2, 17]}, 'single-default'), ('normal control', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('normal control', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default')], [('regression', {'claims': [[[2024, 2, 8], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2023, 9, 9], True], [[2022, 3, 23], True]], 'pay_date': [2024, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 7, 11], True], [[2024, 11, 28], True]], 'pay_date': [2023, 2, 25]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 5, 16], True], [[2024, 10, 25], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default'), ('normal control', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt')], [('regression', {'claims': [[[2023, 9, 9], True], [[2022, 3, 23], True]], 'pay_date': [2024, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2022, 5, 3], True]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 9, 20], True], [[2022, 9, 28], False]], 'pay_date': [2025, 2, 23]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 1, 4], True]], 'pay_date': [2024, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form')], [('regression', {'claims': [[[2022, 5, 3], True]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2022, 6, 21], True]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 9, 2], True], [[2024, 9, 25], False], [[2023, 4, 4], True]], 'pay_date': [2024, 2, 26]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 5, 13], True], [[2024, 1, 6], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt'), ('normal control', {'claims': [[[2023, 4, 9], False], [[2024, 8, 26], False], [[2022, 5, 3], False]], 'pay_date': [2024, 7, 21]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 14], False], [[2024, 8, 7], True], [[2024, 1, 1], True]], 'pay_date': [2023, 9, 14]}, 'per-form')], [('regression', {'claims': [[[2022, 6, 21], True]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2023, 10, 18], True], [[2024, 9, 28], True]], 'pay_date': [2024, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 3, 7], True], [[2023, 1, 28], True], [[2022, 12, 8], False]], 'pay_date': [2024, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2022, 4, 14], True], [[2023, 9, 6], False], [[2023, 3, 2], True]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('normal control', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2024, 12, 15], False], [[2023, 9, 28], False]], 'pay_date': [2025, 2, 3]}, 'per-form')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in sorted(x['claims'], key=lambda c: tuple(c[0])):
        if tuple(date) <= pay:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1]:
        return 'per-form'
    expiry = (active[0][0] + 1, 2, 15)
    return 'exempt' if pay[:2] <= expiry[:2] else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2022, 7, 16], True], [[2024, 7, 18], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2024, 2, 8], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2022, 3, 17], True]], 'pay_date': [2023, 2, 17]}, 'single-default'), ('normal control', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('normal control', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default')], [('regression', {'claims': [[[2024, 2, 8], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2023, 9, 9], True], [[2022, 3, 23], True]], 'pay_date': [2024, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 7, 11], True], [[2024, 11, 28], True]], 'pay_date': [2023, 2, 25]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 5, 16], True], [[2024, 10, 25], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default'), ('normal control', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt')], [('regression', {'claims': [[[2023, 9, 9], True], [[2022, 3, 23], True]], 'pay_date': [2024, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2022, 5, 3], True]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 9, 20], True], [[2022, 9, 28], False]], 'pay_date': [2025, 2, 23]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 1, 4], True]], 'pay_date': [2024, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form')], [('regression', {'claims': [[[2022, 5, 3], True]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2022, 6, 21], True]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 9, 2], True], [[2024, 9, 25], False], [[2023, 4, 4], True]], 'pay_date': [2024, 2, 26]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 5, 13], True], [[2024, 1, 6], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt'), ('normal control', {'claims': [[[2023, 4, 9], False], [[2024, 8, 26], False], [[2022, 5, 3], False]], 'pay_date': [2024, 7, 21]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 14], False], [[2024, 8, 7], True], [[2024, 1, 1], True]], 'pay_date': [2023, 9, 14]}, 'per-form')], [('regression', {'claims': [[[2022, 6, 21], True]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('regression', {'claims': [[[2023, 10, 18], True], [[2024, 9, 28], True]], 'pay_date': [2024, 2, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 3, 7], True], [[2023, 1, 28], True], [[2022, 12, 8], False]], 'pay_date': [2024, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2022, 4, 14], True], [[2023, 9, 6], False], [[2023, 3, 2], True]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('normal control', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2024, 12, 15], False], [[2023, 9, 28], False]], 'pay_date': [2025, 2, 3]}, 'per-form')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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:
Paychecks dated exactly February 15 lose exempt status one day early.

Input {claims: [[[y,m,d], exempt]], pay_date [y,m,d]}. The active claim is the latest-dated claim on or before the pay date (claims processed by date; equal dates keep input order, last wins). No claim -> 'single-default'. Non-exempt claim -> 'per-form'. Exempt claim is honored through February 15 of the year after it was filed, inclusive; afterwards 'single-default'.

split: open-access


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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in x['claims']:
        if tuple(date) <= pay:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1]:
        return 'per-form'
    expiry = (active[0][0] + 1, 2, 15)
    return 'exempt' if pay <= expiry else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2023, 3, 11], True], [[2024, 4, 21], True], [[2023, 2, 25], False]], 'pay_date': [2024, 2, 4]}, 'exempt'), ('regression', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 5, 13], True], [[2024, 1, 6], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default'), ('normal control', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form')], [('regression', {'claims': [[[2024, 5, 13], True], [[2024, 1, 6], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('regression', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 11, 8], True], [[2023, 11, 2], True], [[2023, 2, 20], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 6, 6], False], [[2023, 1, 26], True]], 'pay_date': [2024, 2, 15]}, 'per-form'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default'), ('normal control', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default')], [('regression', {'claims': [[[2022, 11, 8], True], [[2023, 11, 2], True], [[2023, 2, 20], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('regression', {'claims': [[[2024, 9, 20], True], [[2022, 9, 28], False]], 'pay_date': [2025, 2, 23]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 6, 6], False], [[2023, 1, 26], True]], 'pay_date': [2024, 2, 15]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 9, 16], False], [[2024, 2, 20], True]], 'pay_date': [2024, 9, 16]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt')], [('regression', {'claims': [[[2023, 6, 6], False], [[2023, 1, 26], True]], 'pay_date': [2024, 2, 15]}, 'per-form'), ('regression', {'claims': [[[2023, 3, 11], True], [[2024, 4, 21], True], [[2023, 2, 25], False]], 'pay_date': [2024, 2, 4]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 6, 15], True], [[2023, 3, 6], False]], 'pay_date': [2023, 6, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 12, 19], True], [[2022, 5, 28], False], [[2023, 5, 27], False]], 'pay_date': [2023, 2, 11]}, 'exempt'), ('normal control', {'claims': [[[2023, 4, 9], False], [[2024, 8, 26], False], [[2022, 5, 3], False]], 'pay_date': [2024, 7, 21]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default'), ('normal control', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 14], False], [[2024, 8, 7], True], [[2024, 1, 1], True]], 'pay_date': [2023, 9, 14]}, 'per-form')], [('regression', {'claims': [[[2024, 9, 16], False], [[2024, 2, 20], True]], 'pay_date': [2024, 9, 16]}, 'per-form'), ('regression', {'claims': [[[2024, 5, 13], True], [[2024, 1, 6], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 11, 10], False], [[2023, 1, 11], True], [[2024, 5, 22], False]], 'pay_date': [2023, 11, 10]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 8, 13], True], [[2022, 5, 20], True], [[2022, 4, 7], False]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('normal control', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('normal control', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2024, 12, 15], False], [[2023, 9, 28], False]], 'pay_date': [2025, 2, 3]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2024, 7, 6]}, 'single-default')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in sorted(x['claims'], key=lambda c: c[0][0]):
        if tuple(date) <= pay:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1]:
        return 'per-form'
    expiry = (active[0][0] + 1, 2, 15)
    return 'exempt' if pay <= expiry else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2023, 3, 11], True], [[2024, 4, 21], True], [[2023, 2, 25], False]], 'pay_date': [2024, 2, 4]}, 'exempt'), ('regression', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 5, 13], True], [[2024, 1, 6], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default'), ('normal control', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form')], [('regression', {'claims': [[[2024, 5, 13], True], [[2024, 1, 6], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('regression', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 11, 8], True], [[2023, 11, 2], True], [[2023, 2, 20], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 6, 6], False], [[2023, 1, 26], True]], 'pay_date': [2024, 2, 15]}, 'per-form'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default'), ('normal control', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default')], [('regression', {'claims': [[[2022, 11, 8], True], [[2023, 11, 2], True], [[2023, 2, 20], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('regression', {'claims': [[[2024, 9, 20], True], [[2022, 9, 28], False]], 'pay_date': [2025, 2, 23]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 6, 6], False], [[2023, 1, 26], True]], 'pay_date': [2024, 2, 15]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 9, 16], False], [[2024, 2, 20], True]], 'pay_date': [2024, 9, 16]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt')], [('regression', {'claims': [[[2023, 6, 6], False], [[2023, 1, 26], True]], 'pay_date': [2024, 2, 15]}, 'per-form'), ('regression', {'claims': [[[2023, 3, 11], True], [[2024, 4, 21], True], [[2023, 2, 25], False]], 'pay_date': [2024, 2, 4]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 6, 15], True], [[2023, 3, 6], False]], 'pay_date': [2023, 6, 15]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 12, 19], True], [[2022, 5, 28], False], [[2023, 5, 27], False]], 'pay_date': [2023, 2, 11]}, 'exempt'), ('normal control', {'claims': [[[2023, 4, 9], False], [[2024, 8, 26], False], [[2022, 5, 3], False]], 'pay_date': [2024, 7, 21]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default'), ('normal control', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 14], False], [[2024, 8, 7], True], [[2024, 1, 1], True]], 'pay_date': [2023, 9, 14]}, 'per-form')], [('regression', {'claims': [[[2024, 9, 16], False], [[2024, 2, 20], True]], 'pay_date': [2024, 9, 16]}, 'per-form'), ('regression', {'claims': [[[2024, 5, 13], True], [[2024, 1, 6], False]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 11, 10], False], [[2023, 1, 11], True], [[2024, 5, 22], False]], 'pay_date': [2023, 11, 10]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 8, 13], True], [[2022, 5, 20], True], [[2022, 4, 7], False]], 'pay_date': [2023, 2, 15]}, 'exempt'), ('normal control', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('normal control', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2024, 12, 15], False], [[2023, 9, 28], False]], 'pay_date': [2025, 2, 3]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2024, 7, 6]}, 'single-default')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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 newer W-4 entered before an older one in the list is overridden by the older form.

Input {claims: [[[y,m,d], exempt]], pay_date [y,m,d]}. The active claim is the latest-dated claim on or before the pay date (claims processed by date; equal dates keep input order, last wins). No claim -> 'single-default'. Non-exempt claim -> 'per-form'. Exempt claim is honored through February 15 of the year after it was filed, inclusive; afterwards 'single-default'.

split: open-access


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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in sorted(x['claims'], key=lambda c: tuple(c[0])):
        if tuple(date) < pay:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1]:
        return 'per-form'
    expiry = (active[0][0] + 1, 2, 15)
    return 'exempt' if pay <= expiry else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2022, 4, 21], True], [[2022, 12, 3], False]], 'pay_date': [2022, 4, 21]}, 'exempt'), ('regression', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 11, 25], False], [[2022, 6, 11], True], [[2024, 3, 25], True]], 'pay_date': [2024, 4, 3]}, 'exempt'), ('normal control', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('normal control', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default')], [('regression', {'claims': [[[2024, 3, 28], False], [[2024, 8, 12], True], [[2022, 9, 27], True]], 'pay_date': [2024, 3, 28]}, 'per-form'), ('regression', {'claims': [[[2023, 9, 14], False], [[2024, 8, 7], True], [[2024, 1, 1], True]], 'pay_date': [2023, 9, 14]}, 'per-form'), ('partial-repair probe', {'claims': [[[2023, 3, 12], True]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 8, 16], True], [[2023, 10, 2], True]], 'pay_date': [2023, 2, 18]}, 'single-default'), ('normal control', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default')], [('regression', {'claims': [[[2023, 4, 5], False], [[2023, 8, 19], True]], 'pay_date': [2023, 4, 5]}, 'per-form'), ('regression', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 9, 2], True], [[2024, 9, 25], False], [[2023, 4, 4], True]], 'pay_date': [2024, 2, 26]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 8, 28], False]], 'pay_date': [2024, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt')], [('regression', {'claims': [[[2024, 2, 22], True], [[2023, 11, 10], False], [[2024, 4, 24], False]], 'pay_date': [2024, 2, 22]}, 'exempt'), ('regression', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 4, 16], True], [[2024, 7, 4], True]], 'pay_date': [2024, 2, 15]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 12, 28], True], [[2022, 5, 21], False]], 'pay_date': [2023, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2023, 4, 9], False], [[2024, 8, 26], False], [[2022, 5, 3], False]], 'pay_date': [2024, 7, 21]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default'), ('normal control', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default')], [('regression', {'claims': [[[2023, 2, 24], False], [[2022, 4, 18], True], [[2023, 7, 8], True]], 'pay_date': [2023, 2, 24]}, 'per-form'), ('regression', {'claims': [[[2023, 2, 17], True], [[2024, 9, 16], False]], 'pay_date': [2023, 2, 17]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 3, 6], True], [[2024, 11, 28], True], [[2022, 3, 25], True]], 'pay_date': [2024, 2, 15]}, 'single-default'), ('partial-repair probe', {'claims': [[[2022, 4, 14], True], [[2023, 9, 6], False], [[2023, 3, 2], True]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2024, 12, 15], False], [[2023, 9, 28], False]], 'pay_date': [2025, 2, 3]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2024, 7, 6]}, 'single-default'), ('normal control', {'claims': [[[2022, 7, 16], True], [[2024, 7, 18], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('normal control', {'claims': [[[2022, 1, 12], True], [[2022, 3, 16], True]], 'pay_date': [2024, 5, 17]}, 'single-default')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in sorted(x['claims'], key=lambda c: tuple(c[0])):
        if date[0] <= pay[0]:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1]:
        return 'per-form'
    expiry = (active[0][0] + 1, 2, 15)
    return 'exempt' if pay <= expiry else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2022, 4, 21], True], [[2022, 12, 3], False]], 'pay_date': [2022, 4, 21]}, 'exempt'), ('regression', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('partial-repair probe', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 11, 25], False], [[2022, 6, 11], True], [[2024, 3, 25], True]], 'pay_date': [2024, 4, 3]}, 'exempt'), ('normal control', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('normal control', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default')], [('regression', {'claims': [[[2024, 3, 28], False], [[2024, 8, 12], True], [[2022, 9, 27], True]], 'pay_date': [2024, 3, 28]}, 'per-form'), ('regression', {'claims': [[[2023, 9, 14], False], [[2024, 8, 7], True], [[2024, 1, 1], True]], 'pay_date': [2023, 9, 14]}, 'per-form'), ('partial-repair probe', {'claims': [[[2023, 3, 12], True]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 8, 16], True], [[2023, 10, 2], True]], 'pay_date': [2023, 2, 18]}, 'single-default'), ('normal control', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default')], [('regression', {'claims': [[[2023, 4, 5], False], [[2023, 8, 19], True]], 'pay_date': [2023, 4, 5]}, 'per-form'), ('regression', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt'), ('partial-repair probe', {'claims': [[[2022, 9, 2], True], [[2024, 9, 25], False], [[2023, 4, 4], True]], 'pay_date': [2024, 2, 26]}, 'single-default'), ('partial-repair probe', {'claims': [[[2024, 8, 28], False]], 'pay_date': [2024, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form'), ('normal control', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt')], [('regression', {'claims': [[[2024, 2, 22], True], [[2023, 11, 10], False], [[2024, 4, 24], False]], 'pay_date': [2024, 2, 22]}, 'exempt'), ('regression', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 4, 16], True], [[2024, 7, 4], True]], 'pay_date': [2024, 2, 15]}, 'single-default'), ('partial-repair probe', {'claims': [[[2023, 12, 28], True], [[2022, 5, 21], False]], 'pay_date': [2023, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2023, 4, 9], False], [[2024, 8, 26], False], [[2022, 5, 3], False]], 'pay_date': [2024, 7, 21]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default'), ('normal control', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default')], [('regression', {'claims': [[[2023, 2, 24], False], [[2022, 4, 18], True], [[2023, 7, 8], True]], 'pay_date': [2023, 2, 24]}, 'per-form'), ('regression', {'claims': [[[2023, 2, 17], True], [[2024, 9, 16], False]], 'pay_date': [2023, 2, 17]}, 'exempt'), ('partial-repair probe', {'claims': [[[2024, 3, 6], True], [[2024, 11, 28], True], [[2022, 3, 25], True]], 'pay_date': [2024, 2, 15]}, 'single-default'), ('partial-repair probe', {'claims': [[[2022, 4, 14], True], [[2023, 9, 6], False], [[2023, 3, 2], True]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2024, 12, 15], False], [[2023, 9, 28], False]], 'pay_date': [2025, 2, 3]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2024, 7, 6]}, 'single-default'), ('normal control', {'claims': [[[2022, 7, 16], True], [[2024, 7, 18], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('normal control', {'claims': [[[2022, 1, 12], True], [[2022, 3, 16], True]], 'pay_date': [2024, 5, 17]}, 'single-default')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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 W-4 received on the pay date is ignored for that paycheck.

Input {claims: [[[y,m,d], exempt]], pay_date [y,m,d]}. The active claim is the latest-dated claim on or before the pay date (claims processed by date; equal dates keep input order, last wins). No claim -> 'single-default'. Non-exempt claim -> 'per-form'. Exempt claim is honored through February 15 of the year after it was filed, inclusive; afterwards 'single-default'.

split: open-access


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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in sorted(x['claims'], key=lambda c: tuple(c[0])):
        if tuple(date) <= pay:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1]:
        return 'single-default'
    expiry = (active[0][0] + 1, 2, 15)
    return 'exempt' if pay <= expiry else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('regression', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 11, 7], False]], 'pay_date': [2023, 9, 11]}, 'per-form'), ('normal control', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default')], [('regression', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('regression', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 11, 7], False]], 'pay_date': [2023, 9, 11]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 6, 25], False]], 'pay_date': [2024, 10, 5]}, 'per-form'), ('normal control', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt')], [('regression', {'claims': [[[2022, 11, 7], False]], 'pay_date': [2023, 9, 11]}, 'per-form'), ('regression', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 6, 10], False]], 'pay_date': [2024, 6, 10]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 1, 28], False]], 'pay_date': [2023, 2, 16]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default'), ('normal control', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt')], [('regression', {'claims': [[[2024, 6, 25], False]], 'pay_date': [2024, 10, 5]}, 'per-form'), ('regression', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 5, 25], False]], 'pay_date': [2024, 5, 25]}, 'per-form'), ('partial-repair probe', {'claims': [[[2023, 6, 8], False]], 'pay_date': [2024, 2, 15]}, 'per-form'), ('normal control', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2024, 7, 6]}, 'single-default'), ('normal control', {'claims': [[[2022, 7, 16], True], [[2024, 7, 18], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('normal control', {'claims': [[[2022, 1, 12], True], [[2022, 3, 16], True]], 'pay_date': [2024, 5, 17]}, 'single-default')], [('regression', {'claims': [[[2024, 6, 10], False]], 'pay_date': [2024, 6, 10]}, 'per-form'), ('regression', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 4, 24], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 9, 19], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 3, 17], True]], 'pay_date': [2023, 2, 17]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('normal control', {'claims': [[[2024, 11, 25], False], [[2022, 6, 11], True], [[2024, 3, 25], True]], 'pay_date': [2024, 4, 3]}, 'exempt'), ('normal control', {'claims': [[[2024, 7, 26], True], [[2024, 2, 21], True]], 'pay_date': [2023, 2, 15]}, 'single-default')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    pay = tuple(x['pay_date'])
    active = None
    for date, exempt in sorted(x['claims'], key=lambda c: tuple(c[0])):
        if tuple(date) <= pay:
            active = (tuple(date), exempt)
    if active is None:
        return 'single-default'
    if not active[1] and len(x['claims']) > 1:
        return 'per-form'
    expiry = (active[0][0] + 1, 2, 15)
    return 'exempt' if pay <= expiry else 'single-default'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('regression', {'claims': [[[2022, 2, 13], True], [[2023, 3, 1], False], [[2022, 3, 22], False]], 'pay_date': [2024, 2, 27]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 11, 7], False]], 'pay_date': [2023, 9, 11]}, 'per-form'), ('normal control', {'claims': [[[2023, 9, 19], True], [[2023, 8, 5], True], [[2022, 3, 16], False]], 'pay_date': [2023, 9, 19]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2025, 2, 4]}, 'single-default'), ('normal control', {'claims': [[[2022, 7, 27], False], [[2022, 1, 5], True], [[2022, 8, 16], True]], 'pay_date': [2024, 5, 27]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 5], True]], 'pay_date': [2024, 11, 6]}, 'single-default')], [('regression', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('regression', {'claims': [[[2023, 2, 25], False]], 'pay_date': [2025, 12, 24]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 11, 7], False]], 'pay_date': [2023, 9, 11]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 6, 25], False]], 'pay_date': [2024, 10, 5]}, 'per-form'), ('normal control', {'claims': [[[2023, 10, 8], True], [[2024, 3, 27], True]], 'pay_date': [2023, 10, 8]}, 'exempt'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 15]}, 'single-default'), ('normal control', {'claims': [[[2023, 2, 6], True]], 'pay_date': [2024, 2, 13]}, 'exempt')], [('regression', {'claims': [[[2022, 11, 7], False]], 'pay_date': [2023, 9, 11]}, 'per-form'), ('regression', {'claims': [[[2023, 7, 12], False], [[2023, 2, 5], False], [[2024, 5, 28], False]], 'pay_date': [2024, 2, 16]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 6, 10], False]], 'pay_date': [2024, 6, 10]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 1, 28], False]], 'pay_date': [2023, 2, 16]}, 'per-form'), ('normal control', {'claims': [], 'pay_date': [2023, 2, 27]}, 'single-default'), ('normal control', {'claims': [[[2024, 6, 18], True], [[2024, 1, 24], True], [[2024, 8, 3], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2023, 9, 6], True], [[2023, 1, 17], False], [[2022, 11, 5], True]], 'pay_date': [2025, 2, 16]}, 'single-default'), ('normal control', {'claims': [[[2022, 5, 10], True]], 'pay_date': [2022, 5, 10]}, 'exempt')], [('regression', {'claims': [[[2024, 6, 25], False]], 'pay_date': [2024, 10, 5]}, 'per-form'), ('regression', {'claims': [[[2024, 1, 17], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 5, 25], False]], 'pay_date': [2024, 5, 25]}, 'per-form'), ('partial-repair probe', {'claims': [[[2023, 6, 8], False]], 'pay_date': [2024, 2, 15]}, 'per-form'), ('normal control', {'claims': [[[2023, 10, 8], False], [[2024, 8, 1], False]], 'pay_date': [2023, 2, 16]}, 'single-default'), ('normal control', {'claims': [], 'pay_date': [2024, 7, 6]}, 'single-default'), ('normal control', {'claims': [[[2022, 7, 16], True], [[2024, 7, 18], True]], 'pay_date': [2025, 2, 15]}, 'exempt'), ('normal control', {'claims': [[[2022, 1, 12], True], [[2022, 3, 16], True]], 'pay_date': [2024, 5, 17]}, 'single-default')], [('regression', {'claims': [[[2024, 6, 10], False]], 'pay_date': [2024, 6, 10]}, 'per-form'), ('regression', {'claims': [[[2022, 1, 6], False], [[2024, 2, 7], False]], 'pay_date': [2024, 2, 12]}, 'per-form'), ('partial-repair probe', {'claims': [[[2022, 4, 24], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('partial-repair probe', {'claims': [[[2024, 9, 19], False]], 'pay_date': [2025, 2, 16]}, 'per-form'), ('normal control', {'claims': [[[2022, 3, 17], True]], 'pay_date': [2023, 2, 17]}, 'single-default'), ('normal control', {'claims': [[[2023, 4, 26], True], [[2022, 11, 26], False]], 'pay_date': [2023, 4, 26]}, 'exempt'), ('normal control', {'claims': [[[2024, 11, 25], False], [[2022, 6, 11], True], [[2024, 3, 25], True]], 'pay_date': [2024, 4, 3]}, 'exempt'), ('normal control', {'claims': [[[2024, 7, 26], True], [[2024, 2, 21], True]], 'pay_date': [2023, 2, 15]}, 'single-default')]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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:
Employees who file a regular W-4 are withheld at the default rate, ignoring their form.

Input {claims: [[[y,m,d], exempt]], pay_date [y,m,d]}. The active claim is the latest-dated claim on or before the pay date (claims processed by date; equal dates keep input order, last wins). No claim -> 'single-default'. Non-exempt claim -> 'per-form'. Exempt claim is honored through February 15 of the year after it was filed, inclusive; afterwards 'single-default'.

split: open-access


prompt:
Employees with W-4 extra withholding on regular pay are under-withheld on bonuses paid with that run.

Input {regular, supp, regular_wh or None, table: ascending [[threshold, base, pct]]}. f(w) uses the last row with threshold <= w: base + (w - threshold)*pct/100 half-up. Supplemental withholding = max(0, f(regular + supp) - already), where already is regular_wh when given, otherwise f(regular) (supplemental paid separately from the regular run). Return cents.

split: open-access


prompt:
Bonuses paid in a separate run are withheld as if regular wages had no withholding.

Input {regular, supp, regular_wh or None, table: ascending [[threshold, base, pct]]}. f(w) uses the last row with threshold <= w: base + (w - threshold)*pct/100 half-up. Supplemental withholding = max(0, f(regular + supp) - already), where already is regular_wh when given, otherwise f(regular) (supplemental paid separately from the regular run). Return cents.

split: open-access


prompt:
Bonuses for higher earners are withheld at the bottom bracket.

Input {regular, supp, regular_wh or None, table: ascending [[threshold, base, pct]]}. f(w) uses the last row with threshold <= w: base + (w - threshold)*pct/100 half-up. Supplemental withholding = max(0, f(regular + supp) - already), where already is regular_wh when given, otherwise f(regular) (supplemental paid separately from the regular run). Return cents.

split: open-access


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

N = 1
observations = []
def solve(x):
    rates = [x['federal']] + [r for r in (x['state'], x['local']) if r is not None]
    applicable = rates[-1]
    if x['age'] < 20 and x['days_employed'] <= 90 and x['state'] is None and x['local'] is None:
        applicable = min(applicable, 425)
    return [applicable, max(0, x['hours'] * applicable - x['paid'])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'federal': 725, 'state': 1500, 'local': 900, 'age': 19, 'days_employed': 200, 'hours': 32, 'paid': 60214}, [1500, 0]), ('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 17, 'days_employed': 200, 'hours': 12, 'paid': 62529}, [1500, 0]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 900, 'age': 21, 'days_employed': 10, 'hours': 36, 'paid': 32014}, [900, 386]), ('partial-repair probe', {'federal': 725, 'state': 700, 'local': 900, 'age': 17, 'days_employed': 90, 'hours': 42, 'paid': 43650}, [900, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 17, 'days_employed': 10, 'hours': 44, 'paid': 52557}, [1500, 13443]), ('normal control', {'federal': 725, 'state': None, 'local': None, 'age': 19, 'days_employed': 200, 'hours': 49, 'paid': 66535}, [725, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 19, 'days_employed': 91, 'hours': 13, 'paid': 52409}, [1500, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 21, 'days_employed': 91, 'hours': 3, 'paid': 73893}, [1500, 0])], [('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 17, 'days_employed': 200, 'hours': 12, 'paid': 62529}, [1500, 0]), ('regression', {'federal': 725, 'state': 700, 'local': None, 'age': 35, 'days_employed': 200, 'hours': 25, 'paid': 55516}, [725, 0]), ('partial-repair probe', {'federal': 725, 'state': 700, 'local': 1400, 'age': 20, 'days_employed': 119, 'hours': 50, 'paid': 49362}, [1400, 20638]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 1700, 'age': 21, 'days_employed': 200, 'hours': 31, 'paid': 26649}, [1700, 26051]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 35, 'days_employed': 91, 'hours': 1, 'paid': 31574}, [1500, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 21, 'days_employed': 89, 'hours': 20, 'paid': 19880}, [1500, 10120]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 19, 'days_employed': 100, 'hours': 21, 'paid': 76399}, [1500, 0]), ('normal control', {'federal': 725, 'state': None, 'local': None, 'age': 20, 'days_employed': 91, 'hours': 50, 'paid': 25834}, [725, 10416])], [('regression', {'federal': 725, 'state': 700, 'local': None, 'age': 35, 'days_employed': 200, 'hours': 25, 'paid': 55516}, [725, 0]), ('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 19, 'days_employed': 90, 'hours': 35, 'paid': 10142}, [1500, 42358]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 900, 'age': 35, 'days_employed': 10, 'hours': 44, 'paid': 29457}, [900, 10143]), ('partial-repair probe', {'federal': 725, 'state': 800, 'local': 1400, 'age': 21, 'days_employed': 89, 'hours': 42, 'paid': 70854}, [1400, 0]), ('normal control', {'federal': 725, 'state': 800, 'local': None, 'age': 35, 'days_employed': 200, 'hours': 25, 'paid': 12908}, [800, 7092]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 21, 'days_employed': 90, 'hours': 7, 'paid': 37819}, [1500, 0]), ('normal control', {'federal': 725, 'state': 800, 'local': None, 'age': 21, 'days_employed': 200, 'hours': 28, 'paid': 34186}, [800, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 20, 'days_employed': 119, 'hours': 21, 'paid': 78346}, [1500, 0])], [('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 19, 'days_employed': 90, 'hours': 35, 'paid': 10142}, [1500, 42358]), ('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 21, 'days_employed': 100, 'hours': 38, 'paid': 59758}, [1500, 0]), ('partial-repair probe', {'federal': 725, 'state': 800, 'local': 900, 'age': 35, 'days_employed': 10, 'hours': 27, 'paid': 8188}, [900, 16112]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 900, 'age': 17, 'days_employed': 200, 'hours': 2, 'paid': 39319}, [900, 0]), ('normal control', {'federal': 725, 'state': 800, 'local': None, 'age': 21, 'days_employed': 90, 'hours': 39, 'paid': 35117}, [800, 0]), ('normal control', {'federal': 725, 'state': None, 'local': None, 'age': 19, 'days_employed': 90, 'hours': 23, 'paid': 23235}, [425, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 19, 'days_employed': 100, 'hours': 13, 'paid': 71642}, [1500, 0]), ('normal control', {'federal': 725, 'state': None, 'local': None, 'age': 21, 'days_employed': 200, 'hours': 0, 'paid': 36583}, [725, 0])], [('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 21, 'days_employed': 100, 'hours': 38, 'paid': 59758}, [1500, 0]), ('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 20, 'days_employed': 89, 'hours': 13, 'paid': 20235}, [1500, 0]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 1700, 'age': 19, 'days_employed': 90, 'hours': 1, 'paid': 33812}, [1700, 0]), ('partial-repair probe', {'federal': 725, 'state': 800, 'local': 1700, 'age': 17, 'days_employed': 119, 'hours': 36, 'paid': 42057}, [1700, 19143]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 20, 'days_employed': 119, 'hours': 16, 'paid': 1656}, [1500, 22344]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 35, 'days_employed': 200, 'hours': 26, 'paid': 4444}, [1500, 34556]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 20, 'days_employed': 89, 'hours': 38, 'paid': 44401}, [1500, 12599]), ('normal control', {'federal': 725, 'state': 800, 'local': None, 'age': 20, 'days_employed': 200, 'hours': 12, 'paid': 33515}, [800, 0])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    rates = [x['federal']] + [r for r in (x['state'], x['local']) if r is not None]
    applicable = max(x['federal'], x['state'] or 0)
    if x['age'] < 20 and x['days_employed'] <= 90 and x['state'] is None and x['local'] is None:
        applicable = min(applicable, 425)
    return [applicable, max(0, x['hours'] * applicable - x['paid'])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'federal': 725, 'state': 1500, 'local': 900, 'age': 19, 'days_employed': 200, 'hours': 32, 'paid': 60214}, [1500, 0]), ('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 17, 'days_employed': 200, 'hours': 12, 'paid': 62529}, [1500, 0]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 900, 'age': 21, 'days_employed': 10, 'hours': 36, 'paid': 32014}, [900, 386]), ('partial-repair probe', {'federal': 725, 'state': 700, 'local': 900, 'age': 17, 'days_employed': 90, 'hours': 42, 'paid': 43650}, [900, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 17, 'days_employed': 10, 'hours': 44, 'paid': 52557}, [1500, 13443]), ('normal control', {'federal': 725, 'state': None, 'local': None, 'age': 19, 'days_employed': 200, 'hours': 49, 'paid': 66535}, [725, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 19, 'days_employed': 91, 'hours': 13, 'paid': 52409}, [1500, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 21, 'days_employed': 91, 'hours': 3, 'paid': 73893}, [1500, 0])], [('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 17, 'days_employed': 200, 'hours': 12, 'paid': 62529}, [1500, 0]), ('regression', {'federal': 725, 'state': 700, 'local': None, 'age': 35, 'days_employed': 200, 'hours': 25, 'paid': 55516}, [725, 0]), ('partial-repair probe', {'federal': 725, 'state': 700, 'local': 1400, 'age': 20, 'days_employed': 119, 'hours': 50, 'paid': 49362}, [1400, 20638]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 1700, 'age': 21, 'days_employed': 200, 'hours': 31, 'paid': 26649}, [1700, 26051]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 35, 'days_employed': 91, 'hours': 1, 'paid': 31574}, [1500, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 21, 'days_employed': 89, 'hours': 20, 'paid': 19880}, [1500, 10120]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 19, 'days_employed': 100, 'hours': 21, 'paid': 76399}, [1500, 0]), ('normal control', {'federal': 725, 'state': None, 'local': None, 'age': 20, 'days_employed': 91, 'hours': 50, 'paid': 25834}, [725, 10416])], [('regression', {'federal': 725, 'state': 700, 'local': None, 'age': 35, 'days_employed': 200, 'hours': 25, 'paid': 55516}, [725, 0]), ('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 19, 'days_employed': 90, 'hours': 35, 'paid': 10142}, [1500, 42358]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 900, 'age': 35, 'days_employed': 10, 'hours': 44, 'paid': 29457}, [900, 10143]), ('partial-repair probe', {'federal': 725, 'state': 800, 'local': 1400, 'age': 21, 'days_employed': 89, 'hours': 42, 'paid': 70854}, [1400, 0]), ('normal control', {'federal': 725, 'state': 800, 'local': None, 'age': 35, 'days_employed': 200, 'hours': 25, 'paid': 12908}, [800, 7092]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 21, 'days_employed': 90, 'hours': 7, 'paid': 37819}, [1500, 0]), ('normal control', {'federal': 725, 'state': 800, 'local': None, 'age': 21, 'days_employed': 200, 'hours': 28, 'paid': 34186}, [800, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 20, 'days_employed': 119, 'hours': 21, 'paid': 78346}, [1500, 0])], [('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 19, 'days_employed': 90, 'hours': 35, 'paid': 10142}, [1500, 42358]), ('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 21, 'days_employed': 100, 'hours': 38, 'paid': 59758}, [1500, 0]), ('partial-repair probe', {'federal': 725, 'state': 800, 'local': 900, 'age': 35, 'days_employed': 10, 'hours': 27, 'paid': 8188}, [900, 16112]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 900, 'age': 17, 'days_employed': 200, 'hours': 2, 'paid': 39319}, [900, 0]), ('normal control', {'federal': 725, 'state': 800, 'local': None, 'age': 21, 'days_employed': 90, 'hours': 39, 'paid': 35117}, [800, 0]), ('normal control', {'federal': 725, 'state': None, 'local': None, 'age': 19, 'days_employed': 90, 'hours': 23, 'paid': 23235}, [425, 0]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 19, 'days_employed': 100, 'hours': 13, 'paid': 71642}, [1500, 0]), ('normal control', {'federal': 725, 'state': None, 'local': None, 'age': 21, 'days_employed': 200, 'hours': 0, 'paid': 36583}, [725, 0])], [('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 21, 'days_employed': 100, 'hours': 38, 'paid': 59758}, [1500, 0]), ('regression', {'federal': 725, 'state': 1500, 'local': 1400, 'age': 20, 'days_employed': 89, 'hours': 13, 'paid': 20235}, [1500, 0]), ('partial-repair probe', {'federal': 725, 'state': None, 'local': 1700, 'age': 19, 'days_employed': 90, 'hours': 1, 'paid': 33812}, [1700, 0]), ('partial-repair probe', {'federal': 725, 'state': 800, 'local': 1700, 'age': 17, 'days_employed': 119, 'hours': 36, 'paid': 42057}, [1700, 19143]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 20, 'days_employed': 119, 'hours': 16, 'paid': 1656}, [1500, 22344]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 35, 'days_employed': 200, 'hours': 26, 'paid': 4444}, [1500, 34556]), ('normal control', {'federal': 725, 'state': 1500, 'local': None, 'age': 20, 'days_employed': 89, 'hours': 38, 'paid': 44401}, [1500, 12599]), ('normal control', {'federal': 725, 'state': 800, 'local': None, 'age': 20, 'days_employed': 200, 'hours': 12, 'paid': 33515}, [800, 0])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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:
Employees in cities with a minimum wage below the state rate are underpaid.

Input {federal, state|None, local|None, age, days_employed, hours, paid}. Applicable rate is the highest of the defined federal, state and local minimums. A youth rate of 4.25 may replace it when age < 20, days_employed <= 90 and neither a state nor local minimum is defined. Return [rate, max(0, hours*rate - paid)].

split: open-access