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

N = 1
observations = []
def solve(x):
    disposable = x['gross'] - x['taxes']
    disposable = max(0, disposable)
    pct = 50 if x['supports_other_family'] else 60
    if x['arrears_weeks'] > 12:
        pct += 5
    support_cap = disposable * pct // 100
    support = min(x['support_ordered'], support_cap)
    general_cap = min(disposable * 25 // 100, max(0, disposable - 30 * x['min_wage']))
    creditor_room = general_cap
    creditor = min(x['creditor_ordered'], creditor_room)
    return [disposable, support, creditor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'gross': 49885, 'taxes': 7577, 'voluntary': 0, 'support_ordered': 11010, 'supports_other_family': False, 'arrears_weeks': 13, 'creditor_ordered': 76774, 'min_wage': 725}, [42308, 11010, 0]), ('regression', {'gross': 148773, 'taxes': 37141, 'voluntary': 0, 'support_ordered': 142131, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 65400, 'min_wage': 1000}, [111632, 55816, 0]), ('partial-repair probe', {'gross': 46826, 'taxes': 741, 'voluntary': 4492, 'support_ordered': 65174, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 1500}, [46085, 27651, 0]), ('partial-repair probe', {'gross': 17708, 'taxes': 3346, 'voluntary': 3682, 'support_ordered': 144082, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [14362, 7181, 0]), ('normal control', {'gross': 44578, 'taxes': 13638, 'voluntary': 18352, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 12101, 'min_wage': 1000}, [30940, 0, 940]), ('normal control', {'gross': 57348, 'taxes': 14511, 'voluntary': 6333, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 37, 'creditor_ordered': 25506, 'min_wage': 1000}, [42837, 0, 10709]), ('normal control', {'gross': 60837, 'taxes': 6384, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 8, 'creditor_ordered': 99104, 'min_wage': 725}, [54453, 0, 13613]), ('normal control', {'gross': 34053, 'taxes': 8230, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [25823, 0, 0])], [('regression', {'gross': 148773, 'taxes': 37141, 'voluntary': 0, 'support_ordered': 142131, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 65400, 'min_wage': 1000}, [111632, 55816, 0]), ('regression', {'gross': 97698, 'taxes': 10309, 'voluntary': 18929, 'support_ordered': 119941, 'supports_other_family': False, 'arrears_weeks': 16, 'creditor_ordered': 20227, 'min_wage': 1500}, [87389, 56802, 0]), ('partial-repair probe', {'gross': 46826, 'taxes': 741, 'voluntary': 4492, 'support_ordered': 65174, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 1500}, [46085, 27651, 0]), ('partial-repair probe', {'gross': 17708, 'taxes': 3346, 'voluntary': 3682, 'support_ordered': 144082, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [14362, 7181, 0]), ('normal control', {'gross': 49631, 'taxes': 10694, 'voluntary': 12100, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 29, 'creditor_ordered': 0, 'min_wage': 1500}, [38937, 0, 0]), ('normal control', {'gross': 152311, 'taxes': 3320, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 13, 'creditor_ordered': 0, 'min_wage': 725}, [148991, 0, 0]), ('normal control', {'gross': 27004, 'taxes': 2084, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 8, 'creditor_ordered': 0, 'min_wage': 725}, [24920, 0, 0]), ('normal control', {'gross': 108575, 'taxes': 133, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 98815, 'min_wage': 725}, [108442, 0, 27110])], [('regression', {'gross': 97698, 'taxes': 10309, 'voluntary': 18929, 'support_ordered': 119941, 'supports_other_family': False, 'arrears_weeks': 16, 'creditor_ordered': 20227, 'min_wage': 1500}, [87389, 56802, 0]), ('regression', {'gross': 43381, 'taxes': 4618, 'voluntary': 0, 'support_ordered': 101047, 'supports_other_family': True, 'arrears_weeks': 27, 'creditor_ordered': 46979, 'min_wage': 1000}, [38763, 21319, 0]), ('partial-repair probe', {'gross': 92812, 'taxes': 14753, 'voluntary': 4255, 'support_ordered': 102328, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1000}, [78059, 39029, 0]), ('partial-repair probe', {'gross': 101914, 'taxes': 33517, 'voluntary': 11339, 'support_ordered': 29483, 'supports_other_family': False, 'arrears_weeks': 8, 'creditor_ordered': 0, 'min_wage': 1000}, [68397, 29483, 0]), ('normal control', {'gross': 36727, 'taxes': 8624, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 13, 'creditor_ordered': 0, 'min_wage': 725}, [28103, 0, 0]), ('normal control', {'gross': 62104, 'taxes': 11775, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1000}, [50329, 0, 0]), ('normal control', {'gross': 190387, 'taxes': 5582, 'voluntary': 18751, 'support_ordered': 13845, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 1000}, [184805, 13845, 0]), ('normal control', {'gross': 47364, 'taxes': 15560, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 13, 'creditor_ordered': 93206, 'min_wage': 725}, [31804, 0, 7951])], [('regression', {'gross': 43381, 'taxes': 4618, 'voluntary': 0, 'support_ordered': 101047, 'supports_other_family': True, 'arrears_weeks': 27, 'creditor_ordered': 46979, 'min_wage': 1000}, [38763, 21319, 0]), ('regression', {'gross': 41424, 'taxes': 1052, 'voluntary': 0, 'support_ordered': 3123, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 47455, 'min_wage': 725}, [40372, 3123, 6970]), ('partial-repair probe', {'gross': 33225, 'taxes': 530, 'voluntary': 0, 'support_ordered': 97991, 'supports_other_family': False, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [32695, 19617, 0]), ('partial-repair probe', {'gross': 44831, 'taxes': 4578, 'voluntary': 17862, 'support_ordered': 124565, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [40253, 24151, 0]), ('normal control', {'gross': 154270, 'taxes': 17528, 'voluntary': 0, 'support_ordered': 12515, 'supports_other_family': True, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [136742, 12515, 0]), ('normal control', {'gross': 132732, 'taxes': 30387, 'voluntary': 14017, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [102345, 0, 0]), ('normal control', {'gross': 52318, 'taxes': 13495, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [38823, 0, 0]), ('normal control', {'gross': 66488, 'taxes': 5345, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1000}, [61143, 0, 0])], [('regression', {'gross': 186250, 'taxes': 17484, 'voluntary': 17531, 'support_ordered': 75379, 'supports_other_family': True, 'arrears_weeks': 37, 'creditor_ordered': 61433, 'min_wage': 725}, [168766, 75379, 0]), ('regression', {'gross': 41424, 'taxes': 1052, 'voluntary': 0, 'support_ordered': 3123, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 47455, 'min_wage': 725}, [40372, 3123, 6970]), ('partial-repair probe', {'gross': 41743, 'taxes': 1120, 'voluntary': 0, 'support_ordered': 64278, 'supports_other_family': True, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [40623, 20311, 0]), ('partial-repair probe', {'gross': 140899, 'taxes': 22866, 'voluntary': 10207, 'support_ordered': 106762, 'supports_other_family': True, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [118033, 59016, 0]), ('normal control', {'gross': 64406, 'taxes': 9686, 'voluntary': 1669, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 1000}, [54720, 0, 0]), ('normal control', {'gross': 32271, 'taxes': 7987, 'voluntary': 3831, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 0, 'min_wage': 1000}, [24284, 0, 0]), ('normal control', {'gross': 39815, 'taxes': 5597, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 89833, 'min_wage': 725}, [34218, 0, 8554]), ('normal control', {'gross': 34057, 'taxes': 7153, 'voluntary': 2558, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 16, 'creditor_ordered': 53546, 'min_wage': 1000}, [26904, 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)

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

N = 1
observations = []
def solve(x):
    disposable = x['gross'] - x['taxes']
    disposable = max(0, disposable)
    pct = 50 if x['supports_other_family'] else 60
    if x['arrears_weeks'] > 12:
        pct += 5
    support_cap = disposable * pct // 100
    support = min(x['support_ordered'], support_cap)
    general_cap = min(disposable * 25 // 100, max(0, disposable - 30 * x['min_wage']))
    creditor_room = general_cap - support
    creditor = min(x['creditor_ordered'], creditor_room)
    return [disposable, support, creditor]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'gross': 49885, 'taxes': 7577, 'voluntary': 0, 'support_ordered': 11010, 'supports_other_family': False, 'arrears_weeks': 13, 'creditor_ordered': 76774, 'min_wage': 725}, [42308, 11010, 0]), ('regression', {'gross': 148773, 'taxes': 37141, 'voluntary': 0, 'support_ordered': 142131, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 65400, 'min_wage': 1000}, [111632, 55816, 0]), ('partial-repair probe', {'gross': 46826, 'taxes': 741, 'voluntary': 4492, 'support_ordered': 65174, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 1500}, [46085, 27651, 0]), ('partial-repair probe', {'gross': 17708, 'taxes': 3346, 'voluntary': 3682, 'support_ordered': 144082, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [14362, 7181, 0]), ('normal control', {'gross': 44578, 'taxes': 13638, 'voluntary': 18352, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 12101, 'min_wage': 1000}, [30940, 0, 940]), ('normal control', {'gross': 57348, 'taxes': 14511, 'voluntary': 6333, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 37, 'creditor_ordered': 25506, 'min_wage': 1000}, [42837, 0, 10709]), ('normal control', {'gross': 60837, 'taxes': 6384, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 8, 'creditor_ordered': 99104, 'min_wage': 725}, [54453, 0, 13613]), ('normal control', {'gross': 34053, 'taxes': 8230, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [25823, 0, 0])], [('regression', {'gross': 148773, 'taxes': 37141, 'voluntary': 0, 'support_ordered': 142131, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 65400, 'min_wage': 1000}, [111632, 55816, 0]), ('regression', {'gross': 97698, 'taxes': 10309, 'voluntary': 18929, 'support_ordered': 119941, 'supports_other_family': False, 'arrears_weeks': 16, 'creditor_ordered': 20227, 'min_wage': 1500}, [87389, 56802, 0]), ('partial-repair probe', {'gross': 46826, 'taxes': 741, 'voluntary': 4492, 'support_ordered': 65174, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 1500}, [46085, 27651, 0]), ('partial-repair probe', {'gross': 17708, 'taxes': 3346, 'voluntary': 3682, 'support_ordered': 144082, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [14362, 7181, 0]), ('normal control', {'gross': 49631, 'taxes': 10694, 'voluntary': 12100, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 29, 'creditor_ordered': 0, 'min_wage': 1500}, [38937, 0, 0]), ('normal control', {'gross': 152311, 'taxes': 3320, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 13, 'creditor_ordered': 0, 'min_wage': 725}, [148991, 0, 0]), ('normal control', {'gross': 27004, 'taxes': 2084, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 8, 'creditor_ordered': 0, 'min_wage': 725}, [24920, 0, 0]), ('normal control', {'gross': 108575, 'taxes': 133, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 98815, 'min_wage': 725}, [108442, 0, 27110])], [('regression', {'gross': 97698, 'taxes': 10309, 'voluntary': 18929, 'support_ordered': 119941, 'supports_other_family': False, 'arrears_weeks': 16, 'creditor_ordered': 20227, 'min_wage': 1500}, [87389, 56802, 0]), ('regression', {'gross': 43381, 'taxes': 4618, 'voluntary': 0, 'support_ordered': 101047, 'supports_other_family': True, 'arrears_weeks': 27, 'creditor_ordered': 46979, 'min_wage': 1000}, [38763, 21319, 0]), ('partial-repair probe', {'gross': 92812, 'taxes': 14753, 'voluntary': 4255, 'support_ordered': 102328, 'supports_other_family': True, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1000}, [78059, 39029, 0]), ('partial-repair probe', {'gross': 101914, 'taxes': 33517, 'voluntary': 11339, 'support_ordered': 29483, 'supports_other_family': False, 'arrears_weeks': 8, 'creditor_ordered': 0, 'min_wage': 1000}, [68397, 29483, 0]), ('normal control', {'gross': 36727, 'taxes': 8624, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 13, 'creditor_ordered': 0, 'min_wage': 725}, [28103, 0, 0]), ('normal control', {'gross': 62104, 'taxes': 11775, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1000}, [50329, 0, 0]), ('normal control', {'gross': 190387, 'taxes': 5582, 'voluntary': 18751, 'support_ordered': 13845, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 1000}, [184805, 13845, 0]), ('normal control', {'gross': 47364, 'taxes': 15560, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 13, 'creditor_ordered': 93206, 'min_wage': 725}, [31804, 0, 7951])], [('regression', {'gross': 43381, 'taxes': 4618, 'voluntary': 0, 'support_ordered': 101047, 'supports_other_family': True, 'arrears_weeks': 27, 'creditor_ordered': 46979, 'min_wage': 1000}, [38763, 21319, 0]), ('regression', {'gross': 41424, 'taxes': 1052, 'voluntary': 0, 'support_ordered': 3123, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 47455, 'min_wage': 725}, [40372, 3123, 6970]), ('partial-repair probe', {'gross': 33225, 'taxes': 530, 'voluntary': 0, 'support_ordered': 97991, 'supports_other_family': False, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [32695, 19617, 0]), ('partial-repair probe', {'gross': 44831, 'taxes': 4578, 'voluntary': 17862, 'support_ordered': 124565, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [40253, 24151, 0]), ('normal control', {'gross': 154270, 'taxes': 17528, 'voluntary': 0, 'support_ordered': 12515, 'supports_other_family': True, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [136742, 12515, 0]), ('normal control', {'gross': 132732, 'taxes': 30387, 'voluntary': 14017, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1500}, [102345, 0, 0]), ('normal control', {'gross': 52318, 'taxes': 13495, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [38823, 0, 0]), ('normal control', {'gross': 66488, 'taxes': 5345, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 0, 'creditor_ordered': 0, 'min_wage': 1000}, [61143, 0, 0])], [('regression', {'gross': 186250, 'taxes': 17484, 'voluntary': 17531, 'support_ordered': 75379, 'supports_other_family': True, 'arrears_weeks': 37, 'creditor_ordered': 61433, 'min_wage': 725}, [168766, 75379, 0]), ('regression', {'gross': 41424, 'taxes': 1052, 'voluntary': 0, 'support_ordered': 3123, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 47455, 'min_wage': 725}, [40372, 3123, 6970]), ('partial-repair probe', {'gross': 41743, 'taxes': 1120, 'voluntary': 0, 'support_ordered': 64278, 'supports_other_family': True, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [40623, 20311, 0]), ('partial-repair probe', {'gross': 140899, 'taxes': 22866, 'voluntary': 10207, 'support_ordered': 106762, 'supports_other_family': True, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 725}, [118033, 59016, 0]), ('normal control', {'gross': 64406, 'taxes': 9686, 'voluntary': 1669, 'support_ordered': 0, 'supports_other_family': False, 'arrears_weeks': 12, 'creditor_ordered': 0, 'min_wage': 1000}, [54720, 0, 0]), ('normal control', {'gross': 32271, 'taxes': 7987, 'voluntary': 3831, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 0, 'min_wage': 1000}, [24284, 0, 0]), ('normal control', {'gross': 39815, 'taxes': 5597, 'voluntary': 0, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 13, 'creditor_ordered': 89833, 'min_wage': 725}, [34218, 0, 8554]), ('normal control', {'gross': 34057, 'taxes': 7153, 'voluntary': 2558, 'support_ordered': 0, 'supports_other_family': True, 'arrears_weeks': 16, 'creditor_ordered': 53546, 'min_wage': 1000}, [26904, 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:
Creditor garnishments are taken in full even when child support already used the 25% limit.

Input weekly {gross, taxes, voluntary, support_ordered, supports_other_family, arrears_weeks, creditor_ordered, min_wage}. Disposable = max(0, gross - taxes); voluntary deductions are not subtracted. Support cap is 60% of disposable (50% if supporting another family), +5 points when arrears exceed 12 weeks, floored to cents. Creditor cap is min(25% of disposable, disposable - 30*min_wage floored at 0) less support already taken, floored at 0. Return [disposable, support, creditor].

split: open-access


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

N = 1
observations = []
def solve(x):
    h = x['hours']
    mw = x['min_wage']
    cash = x['cash_rate']
    reg = min(h, 40)
    ot = max(0, h - 40)
    credit_rate = max(0, min(mw - cash, x['tip_credit_max']))
    credit_total = min(x['tips'], h * credit_rate)
    makeup = h * credit_rate - credit_total
    cash_wages = reg * (mw - credit_rate) + ot * (mw - credit_rate) * 3 // 2 + makeup
    return [cash_wages, makeup]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 42, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [68800, 33600]), ('regression', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('partial-repair probe', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('partial-repair probe', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('normal control', {'hours': 47, 'cash_rate': 1200, 'tips': 1983, 'min_wage': 1200, 'tip_credit_max': 300}, [60600, 0]), ('normal control', {'hours': 23, 'cash_rate': 776, 'tips': 1403, 'min_wage': 726, 'tip_credit_max': 800}, [16698, 0]), ('normal control', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('normal control', {'hours': 27, 'cash_rate': 726, 'tips': 397, 'min_wage': 726, 'tip_credit_max': 300}, [19602, 0])], [('regression', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('regression', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('partial-repair probe', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('partial-repair probe', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('normal control', {'hours': 40, 'cash_rate': 1600, 'tips': 1562, 'min_wage': 1600, 'tip_credit_max': 300}, [64000, 0]), ('normal control', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000]), ('normal control', {'hours': 19, 'cash_rate': 300, 'tips': 3831, 'min_wage': 726, 'tip_credit_max': 512}, [9963, 4263]), ('normal control', {'hours': 22, 'cash_rate': 1200, 'tips': 48563, 'min_wage': 1200, 'tip_credit_max': 300}, [26400, 0])], [('regression', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('regression', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('partial-repair probe', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('partial-repair probe', {'hours': 46, 'cash_rate': 213, 'tips': 3880, 'min_wage': 1200, 'tip_credit_max': 300}, [54920, 9920]), ('normal control', {'hours': 13, 'cash_rate': 300, 'tips': 3600, 'min_wage': 1600, 'tip_credit_max': 512}, [17200, 3056]), ('normal control', {'hours': 15, 'cash_rate': 300, 'tips': 777, 'min_wage': 726, 'tip_credit_max': 800}, [10113, 5613]), ('normal control', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('normal control', {'hours': 12, 'cash_rate': 213, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 512}, [8712, 6144])], [('regression', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('regression', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('partial-repair probe', {'hours': 60, 'cash_rate': 300, 'tips': 25281, 'min_wage': 1200, 'tip_credit_max': 300}, [66000, 0]), ('partial-repair probe', {'hours': 53, 'cash_rate': 300, 'tips': 45712, 'min_wage': 1600, 'tip_credit_max': 512}, [68064, 0]), ('normal control', {'hours': 43, 'cash_rate': 1600, 'tips': 32479, 'min_wage': 1600, 'tip_credit_max': 300}, [71200, 0]), ('normal control', {'hours': 36, 'cash_rate': 500, 'tips': 27434, 'min_wage': 1000, 'tip_credit_max': 300}, [25200, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0])], [('regression', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('regression', {'hours': 46, 'cash_rate': 213, 'tips': 3880, 'min_wage': 1200, 'tip_credit_max': 300}, [54920, 9920]), ('partial-repair probe', {'hours': 57, 'cash_rate': 500, 'tips': 4387, 'min_wage': 1000, 'tip_credit_max': 512}, [61113, 24113]), ('partial-repair probe', {'hours': 41, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 512}, [41500, 20992]), ('normal control', {'hours': 8, 'cash_rate': 726, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 300}, [5808, 0]), ('normal control', {'hours': 19, 'cash_rate': 300, 'tips': 13502, 'min_wage': 1200, 'tip_credit_max': 800}, [9298, 1698]), ('normal control', {'hours': 1, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [1600, 800]), ('normal control', {'hours': 23, 'cash_rate': 1200, 'tips': 3995, 'min_wage': 1200, 'tip_credit_max': 800}, [27600, 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

N = 1
observations = []
def solve(x):
    h = x['hours']
    mw = x['min_wage']
    cash = x['cash_rate']
    reg = min(h, 40)
    ot = max(0, h - 40)
    credit_rate = max(0, min(mw - cash, x['tip_credit_max']))
    credit_total = min(x['tips'], h * credit_rate)
    makeup = h * credit_rate - credit_total
    cash_wages = reg * (mw - credit_rate) + ot * (mw * 3 // 2) + makeup
    return [cash_wages, makeup]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 42, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [68800, 33600]), ('regression', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('partial-repair probe', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('partial-repair probe', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('normal control', {'hours': 47, 'cash_rate': 1200, 'tips': 1983, 'min_wage': 1200, 'tip_credit_max': 300}, [60600, 0]), ('normal control', {'hours': 23, 'cash_rate': 776, 'tips': 1403, 'min_wage': 726, 'tip_credit_max': 800}, [16698, 0]), ('normal control', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('normal control', {'hours': 27, 'cash_rate': 726, 'tips': 397, 'min_wage': 726, 'tip_credit_max': 300}, [19602, 0])], [('regression', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('regression', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('partial-repair probe', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('partial-repair probe', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('normal control', {'hours': 40, 'cash_rate': 1600, 'tips': 1562, 'min_wage': 1600, 'tip_credit_max': 300}, [64000, 0]), ('normal control', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000]), ('normal control', {'hours': 19, 'cash_rate': 300, 'tips': 3831, 'min_wage': 726, 'tip_credit_max': 512}, [9963, 4263]), ('normal control', {'hours': 22, 'cash_rate': 1200, 'tips': 48563, 'min_wage': 1200, 'tip_credit_max': 300}, [26400, 0])], [('regression', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('regression', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('partial-repair probe', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('partial-repair probe', {'hours': 46, 'cash_rate': 213, 'tips': 3880, 'min_wage': 1200, 'tip_credit_max': 300}, [54920, 9920]), ('normal control', {'hours': 13, 'cash_rate': 300, 'tips': 3600, 'min_wage': 1600, 'tip_credit_max': 512}, [17200, 3056]), ('normal control', {'hours': 15, 'cash_rate': 300, 'tips': 777, 'min_wage': 726, 'tip_credit_max': 800}, [10113, 5613]), ('normal control', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('normal control', {'hours': 12, 'cash_rate': 213, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 512}, [8712, 6144])], [('regression', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('regression', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('partial-repair probe', {'hours': 60, 'cash_rate': 300, 'tips': 25281, 'min_wage': 1200, 'tip_credit_max': 300}, [66000, 0]), ('partial-repair probe', {'hours': 53, 'cash_rate': 300, 'tips': 45712, 'min_wage': 1600, 'tip_credit_max': 512}, [68064, 0]), ('normal control', {'hours': 43, 'cash_rate': 1600, 'tips': 32479, 'min_wage': 1600, 'tip_credit_max': 300}, [71200, 0]), ('normal control', {'hours': 36, 'cash_rate': 500, 'tips': 27434, 'min_wage': 1000, 'tip_credit_max': 300}, [25200, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0])], [('regression', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('regression', {'hours': 46, 'cash_rate': 213, 'tips': 3880, 'min_wage': 1200, 'tip_credit_max': 300}, [54920, 9920]), ('partial-repair probe', {'hours': 57, 'cash_rate': 500, 'tips': 4387, 'min_wage': 1000, 'tip_credit_max': 512}, [61113, 24113]), ('partial-repair probe', {'hours': 41, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 512}, [41500, 20992]), ('normal control', {'hours': 8, 'cash_rate': 726, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 300}, [5808, 0]), ('normal control', {'hours': 19, 'cash_rate': 300, 'tips': 13502, 'min_wage': 1200, 'tip_credit_max': 800}, [9298, 1698]), ('normal control', {'hours': 1, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [1600, 800]), ('normal control', {'hours': 23, 'cash_rate': 1200, 'tips': 3995, 'min_wage': 1200, 'tip_credit_max': 800}, [27600, 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:
Tipped employees working overtime receive less cash than the overtime minimum requires.

Input weekly {hours, cash_rate, tips, min_wage (even cents), tip_credit_max}. Tip credit per hour = max(0, min(min_wage - cash_rate, tip_credit_max)). Hours over 40 are paid at 1.5*min_wage minus the same credit. Credit actually taken = min(tips, hours*credit); the unmet credit is paid as makeup. Return [cash_wages, makeup].

split: open-access


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

N = 1
observations = []
def solve(x):
    h = x['hours']
    mw = x['min_wage']
    cash = x['cash_rate']
    reg = min(h, 40)
    ot = max(0, h - 40)
    credit_rate = max(0, min(mw - cash, x['tip_credit_max']))
    credit_total = h * credit_rate
    makeup = h * credit_rate - credit_total
    cash_wages = reg * (mw - credit_rate) + ot * (mw * 3 // 2 - credit_rate) + makeup
    return [cash_wages, makeup]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 58, 'cash_rate': 213, 'tips': 42999, 'min_wage': 1200, 'tip_credit_max': 800}, [37401, 3401]), ('regression', {'hours': 42, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [68800, 33600]), ('partial-repair probe', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('partial-repair probe', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('normal control', {'hours': 47, 'cash_rate': 1200, 'tips': 1983, 'min_wage': 1200, 'tip_credit_max': 300}, [60600, 0]), ('normal control', {'hours': 23, 'cash_rate': 776, 'tips': 1403, 'min_wage': 726, 'tip_credit_max': 800}, [16698, 0]), ('normal control', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('normal control', {'hours': 27, 'cash_rate': 726, 'tips': 397, 'min_wage': 726, 'tip_credit_max': 300}, [19602, 0])], [('regression', {'hours': 57, 'cash_rate': 213, 'tips': 42636, 'min_wage': 1000, 'tip_credit_max': 800}, [22864, 2223]), ('regression', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000]), ('partial-repair probe', {'hours': 60, 'cash_rate': 300, 'tips': 25281, 'min_wage': 1200, 'tip_credit_max': 300}, [66000, 0]), ('partial-repair probe', {'hours': 53, 'cash_rate': 300, 'tips': 45712, 'min_wage': 1600, 'tip_credit_max': 512}, [68064, 0]), ('normal control', {'hours': 40, 'cash_rate': 1600, 'tips': 1562, 'min_wage': 1600, 'tip_credit_max': 300}, [64000, 0]), ('normal control', {'hours': 22, 'cash_rate': 1200, 'tips': 48563, 'min_wage': 1200, 'tip_credit_max': 300}, [26400, 0]), ('normal control', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('normal control', {'hours': 43, 'cash_rate': 1600, 'tips': 32479, 'min_wage': 1600, 'tip_credit_max': 300}, [71200, 0])], [('regression', {'hours': 52, 'cash_rate': 300, 'tips': 22429, 'min_wage': 1200, 'tip_credit_max': 512}, [47171, 4195]), ('regression', {'hours': 19, 'cash_rate': 300, 'tips': 3831, 'min_wage': 726, 'tip_credit_max': 512}, [9963, 4263]), ('partial-repair probe', {'hours': 57, 'cash_rate': 213, 'tips': 25819, 'min_wage': 1600, 'tip_credit_max': 300}, [87700, 0]), ('partial-repair probe', {'hours': 58, 'cash_rate': 213, 'tips': 42999, 'min_wage': 1200, 'tip_credit_max': 800}, [37401, 3401]), ('normal control', {'hours': 36, 'cash_rate': 500, 'tips': 27434, 'min_wage': 1000, 'tip_credit_max': 300}, [25200, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0]), ('normal control', {'hours': 8, 'cash_rate': 726, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 300}, [5808, 0])], [('regression', {'hours': 59, 'cash_rate': 500, 'tips': 29022, 'min_wage': 1200, 'tip_credit_max': 512}, [53178, 1186]), ('regression', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('partial-repair probe', {'hours': 44, 'cash_rate': 300, 'tips': 32620, 'min_wage': 1600, 'tip_credit_max': 512}, [51072, 0]), ('partial-repair probe', {'hours': 57, 'cash_rate': 300, 'tips': 42507, 'min_wage': 726, 'tip_credit_max': 512}, [23271, 0]), ('normal control', {'hours': 23, 'cash_rate': 1200, 'tips': 3995, 'min_wage': 1200, 'tip_credit_max': 800}, [27600, 0]), ('normal control', {'hours': 20, 'cash_rate': 300, 'tips': 26661, 'min_wage': 726, 'tip_credit_max': 800}, [6000, 0]), ('normal control', {'hours': 23, 'cash_rate': 300, 'tips': 12650, 'min_wage': 1000, 'tip_credit_max': 300}, [16100, 0]), ('normal control', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0])], [('regression', {'hours': 56, 'cash_rate': 500, 'tips': 22410, 'min_wage': 1200, 'tip_credit_max': 512}, [54390, 6262]), ('regression', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('partial-repair probe', {'hours': 47, 'cash_rate': 213, 'tips': 39095, 'min_wage': 1000, 'tip_credit_max': 800}, [13511, 0]), ('partial-repair probe', {'hours': 57, 'cash_rate': 213, 'tips': 42636, 'min_wage': 1000, 'tip_credit_max': 800}, [22864, 2223]), ('normal control', {'hours': 19, 'cash_rate': 1000, 'tips': 592, 'min_wage': 1000, 'tip_credit_max': 512}, [19000, 0]), ('normal control', {'hours': 59, 'cash_rate': 1600, 'tips': 1070, 'min_wage': 1600, 'tip_credit_max': 300}, [109600, 0]), ('normal control', {'hours': 51, 'cash_rate': 726, 'tips': 596, 'min_wage': 726, 'tip_credit_max': 800}, [41019, 0]), ('normal control', {'hours': 36, 'cash_rate': 1200, 'tips': 4642, 'min_wage': 1200, 'tip_credit_max': 300}, [43200, 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):
    h = x['hours']
    mw = x['min_wage']
    cash = x['cash_rate']
    reg = min(h, 40)
    ot = max(0, h - 40)
    credit_rate = max(0, min(mw - cash, x['tip_credit_max']))
    credit_total = min(x['tips'], reg * credit_rate)
    makeup = h * credit_rate - credit_total
    cash_wages = reg * (mw - credit_rate) + ot * (mw * 3 // 2 - credit_rate) + makeup
    return [cash_wages, makeup]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 58, 'cash_rate': 213, 'tips': 42999, 'min_wage': 1200, 'tip_credit_max': 800}, [37401, 3401]), ('regression', {'hours': 42, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [68800, 33600]), ('partial-repair probe', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('partial-repair probe', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('normal control', {'hours': 47, 'cash_rate': 1200, 'tips': 1983, 'min_wage': 1200, 'tip_credit_max': 300}, [60600, 0]), ('normal control', {'hours': 23, 'cash_rate': 776, 'tips': 1403, 'min_wage': 726, 'tip_credit_max': 800}, [16698, 0]), ('normal control', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('normal control', {'hours': 27, 'cash_rate': 726, 'tips': 397, 'min_wage': 726, 'tip_credit_max': 300}, [19602, 0])], [('regression', {'hours': 57, 'cash_rate': 213, 'tips': 42636, 'min_wage': 1000, 'tip_credit_max': 800}, [22864, 2223]), ('regression', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000]), ('partial-repair probe', {'hours': 60, 'cash_rate': 300, 'tips': 25281, 'min_wage': 1200, 'tip_credit_max': 300}, [66000, 0]), ('partial-repair probe', {'hours': 53, 'cash_rate': 300, 'tips': 45712, 'min_wage': 1600, 'tip_credit_max': 512}, [68064, 0]), ('normal control', {'hours': 40, 'cash_rate': 1600, 'tips': 1562, 'min_wage': 1600, 'tip_credit_max': 300}, [64000, 0]), ('normal control', {'hours': 22, 'cash_rate': 1200, 'tips': 48563, 'min_wage': 1200, 'tip_credit_max': 300}, [26400, 0]), ('normal control', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('normal control', {'hours': 43, 'cash_rate': 1600, 'tips': 32479, 'min_wage': 1600, 'tip_credit_max': 300}, [71200, 0])], [('regression', {'hours': 52, 'cash_rate': 300, 'tips': 22429, 'min_wage': 1200, 'tip_credit_max': 512}, [47171, 4195]), ('regression', {'hours': 19, 'cash_rate': 300, 'tips': 3831, 'min_wage': 726, 'tip_credit_max': 512}, [9963, 4263]), ('partial-repair probe', {'hours': 57, 'cash_rate': 213, 'tips': 25819, 'min_wage': 1600, 'tip_credit_max': 300}, [87700, 0]), ('partial-repair probe', {'hours': 58, 'cash_rate': 213, 'tips': 42999, 'min_wage': 1200, 'tip_credit_max': 800}, [37401, 3401]), ('normal control', {'hours': 36, 'cash_rate': 500, 'tips': 27434, 'min_wage': 1000, 'tip_credit_max': 300}, [25200, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0]), ('normal control', {'hours': 8, 'cash_rate': 726, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 300}, [5808, 0])], [('regression', {'hours': 59, 'cash_rate': 500, 'tips': 29022, 'min_wage': 1200, 'tip_credit_max': 512}, [53178, 1186]), ('regression', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('partial-repair probe', {'hours': 44, 'cash_rate': 300, 'tips': 32620, 'min_wage': 1600, 'tip_credit_max': 512}, [51072, 0]), ('partial-repair probe', {'hours': 57, 'cash_rate': 300, 'tips': 42507, 'min_wage': 726, 'tip_credit_max': 512}, [23271, 0]), ('normal control', {'hours': 23, 'cash_rate': 1200, 'tips': 3995, 'min_wage': 1200, 'tip_credit_max': 800}, [27600, 0]), ('normal control', {'hours': 20, 'cash_rate': 300, 'tips': 26661, 'min_wage': 726, 'tip_credit_max': 800}, [6000, 0]), ('normal control', {'hours': 23, 'cash_rate': 300, 'tips': 12650, 'min_wage': 1000, 'tip_credit_max': 300}, [16100, 0]), ('normal control', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0])], [('regression', {'hours': 56, 'cash_rate': 500, 'tips': 22410, 'min_wage': 1200, 'tip_credit_max': 512}, [54390, 6262]), ('regression', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('partial-repair probe', {'hours': 47, 'cash_rate': 213, 'tips': 39095, 'min_wage': 1000, 'tip_credit_max': 800}, [13511, 0]), ('partial-repair probe', {'hours': 57, 'cash_rate': 213, 'tips': 42636, 'min_wage': 1000, 'tip_credit_max': 800}, [22864, 2223]), ('normal control', {'hours': 19, 'cash_rate': 1000, 'tips': 592, 'min_wage': 1000, 'tip_credit_max': 512}, [19000, 0]), ('normal control', {'hours': 59, 'cash_rate': 1600, 'tips': 1070, 'min_wage': 1600, 'tip_credit_max': 300}, [109600, 0]), ('normal control', {'hours': 51, 'cash_rate': 726, 'tips': 596, 'min_wage': 726, 'tip_credit_max': 800}, [41019, 0]), ('normal control', {'hours': 36, 'cash_rate': 1200, 'tips': 4642, 'min_wage': 1200, 'tip_credit_max': 300}, [43200, 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:
Slow weeks with few tips leave the employee below minimum wage with no makeup pay.

Input weekly {hours, cash_rate, tips, min_wage (even cents), tip_credit_max}. Tip credit per hour = max(0, min(min_wage - cash_rate, tip_credit_max)). Hours over 40 are paid at 1.5*min_wage minus the same credit. Credit actually taken = min(tips, hours*credit); the unmet credit is paid as makeup. Return [cash_wages, makeup].

split: open-access


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

N = 1
observations = []
def solve(x):
    h = x['hours']
    mw = x['min_wage']
    cash = x['cash_rate']
    reg = min(h, 40)
    ot = max(0, h - 40)
    credit_rate = max(0, mw - cash)
    credit_total = min(x['tips'], h * credit_rate)
    makeup = h * credit_rate - credit_total
    cash_wages = reg * (mw - credit_rate) + ot * (mw * 3 // 2 - credit_rate) + makeup
    return [cash_wages, makeup]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 42, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [68800, 33600]), ('regression', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('partial-repair probe', {'hours': 47, 'cash_rate': 1200, 'tips': 1983, 'min_wage': 1200, 'tip_credit_max': 300}, [60600, 0]), ('partial-repair probe', {'hours': 23, 'cash_rate': 776, 'tips': 1403, 'min_wage': 726, 'tip_credit_max': 800}, [16698, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 213, 'tips': 48885, 'min_wage': 1000, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 1600, 'tips': 15944, 'min_wage': 1600, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2628, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0])], [('regression', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('regression', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('partial-repair probe', {'hours': 27, 'cash_rate': 726, 'tips': 397, 'min_wage': 726, 'tip_credit_max': 300}, [19602, 0]), ('partial-repair probe', {'hours': 40, 'cash_rate': 1600, 'tips': 1562, 'min_wage': 1600, 'tip_credit_max': 300}, [64000, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2732, 'min_wage': 1600, 'tip_credit_max': 512}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 213, 'tips': 48885, 'min_wage': 1000, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 1600, 'tips': 15944, 'min_wage': 1600, 'tip_credit_max': 800}, [0, 0])], [('regression', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('regression', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('partial-repair probe', {'hours': 19, 'cash_rate': 300, 'tips': 3831, 'min_wage': 726, 'tip_credit_max': 512}, [9963, 4263]), ('partial-repair probe', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2628, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2732, 'min_wage': 1600, 'tip_credit_max': 512}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 213, 'tips': 48885, 'min_wage': 1000, 'tip_credit_max': 800}, [0, 0])], [('regression', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('regression', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000]), ('partial-repair probe', {'hours': 22, 'cash_rate': 1200, 'tips': 48563, 'min_wage': 1200, 'tip_credit_max': 300}, [26400, 0]), ('partial-repair probe', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('normal control', {'hours': 0, 'cash_rate': 1600, 'tips': 15944, 'min_wage': 1600, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2628, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2732, 'min_wage': 1600, 'tip_credit_max': 512}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0])], [('regression', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000]), ('regression', {'hours': 13, 'cash_rate': 300, 'tips': 3600, 'min_wage': 1600, 'tip_credit_max': 512}, [17200, 3056]), ('partial-repair probe', {'hours': 15, 'cash_rate': 300, 'tips': 777, 'min_wage': 726, 'tip_credit_max': 800}, [10113, 5613]), ('partial-repair probe', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('normal control', {'hours': 0, 'cash_rate': 213, 'tips': 48885, 'min_wage': 1000, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 1600, 'tips': 15944, 'min_wage': 1600, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2628, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2732, 'min_wage': 1600, 'tip_credit_max': 512}, [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)

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

N = 1
observations = []
def solve(x):
    h = x['hours']
    mw = x['min_wage']
    cash = x['cash_rate']
    reg = min(h, 40)
    ot = max(0, h - 40)
    credit_rate = max(0, x['tip_credit_max'])
    credit_total = min(x['tips'], h * credit_rate)
    makeup = h * credit_rate - credit_total
    cash_wages = reg * (mw - credit_rate) + ot * (mw * 3 // 2 - credit_rate) + makeup
    return [cash_wages, makeup]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 42, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [68800, 33600]), ('regression', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('partial-repair probe', {'hours': 47, 'cash_rate': 1200, 'tips': 1983, 'min_wage': 1200, 'tip_credit_max': 300}, [60600, 0]), ('partial-repair probe', {'hours': 23, 'cash_rate': 776, 'tips': 1403, 'min_wage': 726, 'tip_credit_max': 800}, [16698, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 213, 'tips': 48885, 'min_wage': 1000, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 1600, 'tips': 15944, 'min_wage': 1600, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2628, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0])], [('regression', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('regression', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('partial-repair probe', {'hours': 27, 'cash_rate': 726, 'tips': 397, 'min_wage': 726, 'tip_credit_max': 300}, [19602, 0]), ('partial-repair probe', {'hours': 40, 'cash_rate': 1600, 'tips': 1562, 'min_wage': 1600, 'tip_credit_max': 300}, [64000, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2732, 'min_wage': 1600, 'tip_credit_max': 512}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 213, 'tips': 48885, 'min_wage': 1000, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 1600, 'tips': 15944, 'min_wage': 1600, 'tip_credit_max': 800}, [0, 0])], [('regression', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('regression', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('partial-repair probe', {'hours': 19, 'cash_rate': 300, 'tips': 3831, 'min_wage': 726, 'tip_credit_max': 512}, [9963, 4263]), ('partial-repair probe', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2628, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2732, 'min_wage': 1600, 'tip_credit_max': 512}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 213, 'tips': 48885, 'min_wage': 1000, 'tip_credit_max': 800}, [0, 0])], [('regression', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('regression', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000]), ('partial-repair probe', {'hours': 22, 'cash_rate': 1200, 'tips': 48563, 'min_wage': 1200, 'tip_credit_max': 300}, [26400, 0]), ('partial-repair probe', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348]), ('normal control', {'hours': 0, 'cash_rate': 1600, 'tips': 15944, 'min_wage': 1600, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2628, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2732, 'min_wage': 1600, 'tip_credit_max': 512}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 500, 'tips': 17501, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0])], [('regression', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000]), ('regression', {'hours': 13, 'cash_rate': 300, 'tips': 3600, 'min_wage': 1600, 'tip_credit_max': 512}, [17200, 3056]), ('partial-repair probe', {'hours': 15, 'cash_rate': 300, 'tips': 777, 'min_wage': 726, 'tip_credit_max': 800}, [10113, 5613]), ('partial-repair probe', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('normal control', {'hours': 0, 'cash_rate': 213, 'tips': 48885, 'min_wage': 1000, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 1600, 'tips': 15944, 'min_wage': 1600, 'tip_credit_max': 800}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2628, 'min_wage': 1600, 'tip_credit_max': 300}, [0, 0]), ('normal control', {'hours': 0, 'cash_rate': 300, 'tips': 2732, 'min_wage': 1600, 'tip_credit_max': 512}, [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 with a very low cash rate have more tip credit claimed than the jurisdiction maximum.

Input weekly {hours, cash_rate, tips, min_wage (even cents), tip_credit_max}. Tip credit per hour = max(0, min(min_wage - cash_rate, tip_credit_max)). Hours over 40 are paid at 1.5*min_wage minus the same credit. Credit actually taken = min(tips, hours*credit); the unmet credit is paid as makeup. Return [cash_wages, makeup].

split: open-access


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

N = 1
observations = []
def solve(x):
    h = x['hours']
    mw = x['min_wage']
    cash = x['cash_rate']
    reg = min(h, 40)
    ot = max(0, h - 40)
    credit_rate = (min(mw - cash, x['tip_credit_max']))
    credit_total = min(x['tips'], h * credit_rate)
    makeup = h * credit_rate - credit_total
    cash_wages = reg * (mw - credit_rate) + ot * (mw * 3 // 2 - credit_rate) + makeup
    return [cash_wages, makeup]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 23, 'cash_rate': 776, 'tips': 1403, 'min_wage': 726, 'tip_credit_max': 800}, [16698, 0]), ('regression', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('partial-repair probe', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0]), ('partial-repair probe', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0]), ('normal control', {'hours': 47, 'cash_rate': 1200, 'tips': 1983, 'min_wage': 1200, 'tip_credit_max': 300}, [60600, 0]), ('normal control', {'hours': 42, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [68800, 33600]), ('normal control', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('normal control', {'hours': 27, 'cash_rate': 726, 'tips': 397, 'min_wage': 726, 'tip_credit_max': 300}, [19602, 0])], [('regression', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('regression', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0]), ('partial-repair probe', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0]), ('partial-repair probe', {'hours': 4, 'cash_rate': 1250, 'tips': 3576, 'min_wage': 1200, 'tip_credit_max': 300}, [4800, 0]), ('normal control', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('normal control', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('normal control', {'hours': 40, 'cash_rate': 1600, 'tips': 1562, 'min_wage': 1600, 'tip_credit_max': 300}, [64000, 0]), ('normal control', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000])], [('regression', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0]), ('regression', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0]), ('partial-repair probe', {'hours': 4, 'cash_rate': 1250, 'tips': 3576, 'min_wage': 1200, 'tip_credit_max': 300}, [4800, 0]), ('partial-repair probe', {'hours': 57, 'cash_rate': 776, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 300}, [47553, 0]), ('normal control', {'hours': 19, 'cash_rate': 300, 'tips': 3831, 'min_wage': 726, 'tip_credit_max': 512}, [9963, 4263]), ('normal control', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('normal control', {'hours': 22, 'cash_rate': 1200, 'tips': 48563, 'min_wage': 1200, 'tip_credit_max': 300}, [26400, 0]), ('normal control', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348])], [('regression', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0]), ('regression', {'hours': 4, 'cash_rate': 1250, 'tips': 3576, 'min_wage': 1200, 'tip_credit_max': 300}, [4800, 0]), ('partial-repair probe', {'hours': 32, 'cash_rate': 776, 'tips': 13592, 'min_wage': 726, 'tip_credit_max': 800}, [23232, 0]), ('partial-repair probe', {'hours': 60, 'cash_rate': 776, 'tips': 36208, 'min_wage': 726, 'tip_credit_max': 512}, [50820, 0]), ('normal control', {'hours': 13, 'cash_rate': 300, 'tips': 3600, 'min_wage': 1600, 'tip_credit_max': 512}, [17200, 3056]), ('normal control', {'hours': 46, 'cash_rate': 213, 'tips': 3880, 'min_wage': 1200, 'tip_credit_max': 300}, [54920, 9920]), ('normal control', {'hours': 60, 'cash_rate': 300, 'tips': 25281, 'min_wage': 1200, 'tip_credit_max': 300}, [66000, 0]), ('normal control', {'hours': 15, 'cash_rate': 300, 'tips': 777, 'min_wage': 726, 'tip_credit_max': 800}, [10113, 5613])], [('regression', {'hours': 4, 'cash_rate': 1250, 'tips': 3576, 'min_wage': 1200, 'tip_credit_max': 300}, [4800, 0]), ('regression', {'hours': 57, 'cash_rate': 776, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 300}, [47553, 0]), ('partial-repair probe', {'hours': 47, 'cash_rate': 1650, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [80800, 0]), ('partial-repair probe', {'hours': 35, 'cash_rate': 776, 'tips': 4941, 'min_wage': 726, 'tip_credit_max': 300}, [25410, 0]), ('normal control', {'hours': 12, 'cash_rate': 213, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 512}, [8712, 6144]), ('normal control', {'hours': 43, 'cash_rate': 1600, 'tips': 32479, 'min_wage': 1600, 'tip_credit_max': 300}, [71200, 0]), ('normal control', {'hours': 36, 'cash_rate': 500, 'tips': 27434, 'min_wage': 1000, 'tip_credit_max': 300}, [25200, 0]), ('normal control', {'hours': 53, 'cash_rate': 300, 'tips': 45712, 'min_wage': 1600, 'tip_credit_max': 512}, [68064, 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):
    h = x['hours']
    mw = x['min_wage']
    cash = x['cash_rate']
    reg = min(h, 40)
    ot = max(0, h - 40)
    credit_rate = abs(min(mw - cash, x['tip_credit_max']))
    credit_total = min(x['tips'], h * credit_rate)
    makeup = h * credit_rate - credit_total
    cash_wages = reg * (mw - credit_rate) + ot * (mw * 3 // 2 - credit_rate) + makeup
    return [cash_wages, makeup]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 23, 'cash_rate': 776, 'tips': 1403, 'min_wage': 726, 'tip_credit_max': 800}, [16698, 0]), ('regression', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('partial-repair probe', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0]), ('partial-repair probe', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0]), ('normal control', {'hours': 47, 'cash_rate': 1200, 'tips': 1983, 'min_wage': 1200, 'tip_credit_max': 300}, [60600, 0]), ('normal control', {'hours': 42, 'cash_rate': 300, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [68800, 33600]), ('normal control', {'hours': 21, 'cash_rate': 500, 'tips': 46641, 'min_wage': 1200, 'tip_credit_max': 512}, [14448, 0]), ('normal control', {'hours': 27, 'cash_rate': 726, 'tips': 397, 'min_wage': 726, 'tip_credit_max': 300}, [19602, 0])], [('regression', {'hours': 47, 'cash_rate': 1650, 'tips': 42376, 'min_wage': 1600, 'tip_credit_max': 300}, [80800, 0]), ('regression', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0]), ('partial-repair probe', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0]), ('partial-repair probe', {'hours': 4, 'cash_rate': 1250, 'tips': 3576, 'min_wage': 1200, 'tip_credit_max': 300}, [4800, 0]), ('normal control', {'hours': 58, 'cash_rate': 300, 'tips': 43606, 'min_wage': 1200, 'tip_credit_max': 300}, [63000, 0]), ('normal control', {'hours': 52, 'cash_rate': 213, 'tips': 42918, 'min_wage': 1200, 'tip_credit_max': 300}, [54000, 0]), ('normal control', {'hours': 40, 'cash_rate': 1600, 'tips': 1562, 'min_wage': 1600, 'tip_credit_max': 300}, [64000, 0]), ('normal control', {'hours': 40, 'cash_rate': 213, 'tips': 0, 'min_wage': 1000, 'tip_credit_max': 300}, [40000, 12000])], [('regression', {'hours': 9, 'cash_rate': 1050, 'tips': 1770, 'min_wage': 1000, 'tip_credit_max': 800}, [9000, 0]), ('regression', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0]), ('partial-repair probe', {'hours': 4, 'cash_rate': 1250, 'tips': 3576, 'min_wage': 1200, 'tip_credit_max': 300}, [4800, 0]), ('partial-repair probe', {'hours': 57, 'cash_rate': 776, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 300}, [47553, 0]), ('normal control', {'hours': 19, 'cash_rate': 300, 'tips': 3831, 'min_wage': 726, 'tip_credit_max': 512}, [9963, 4263]), ('normal control', {'hours': 56, 'cash_rate': 213, 'tips': 464, 'min_wage': 1000, 'tip_credit_max': 800}, [63536, 43608]), ('normal control', {'hours': 22, 'cash_rate': 1200, 'tips': 48563, 'min_wage': 1200, 'tip_credit_max': 300}, [26400, 0]), ('normal control', {'hours': 52, 'cash_rate': 300, 'tips': 13052, 'min_wage': 1000, 'tip_credit_max': 800}, [44948, 23348])], [('regression', {'hours': 37, 'cash_rate': 1050, 'tips': 1780, 'min_wage': 1000, 'tip_credit_max': 300}, [37000, 0]), ('regression', {'hours': 4, 'cash_rate': 1250, 'tips': 3576, 'min_wage': 1200, 'tip_credit_max': 300}, [4800, 0]), ('partial-repair probe', {'hours': 32, 'cash_rate': 776, 'tips': 13592, 'min_wage': 726, 'tip_credit_max': 800}, [23232, 0]), ('partial-repair probe', {'hours': 60, 'cash_rate': 776, 'tips': 36208, 'min_wage': 726, 'tip_credit_max': 512}, [50820, 0]), ('normal control', {'hours': 13, 'cash_rate': 300, 'tips': 3600, 'min_wage': 1600, 'tip_credit_max': 512}, [17200, 3056]), ('normal control', {'hours': 46, 'cash_rate': 213, 'tips': 3880, 'min_wage': 1200, 'tip_credit_max': 300}, [54920, 9920]), ('normal control', {'hours': 60, 'cash_rate': 300, 'tips': 25281, 'min_wage': 1200, 'tip_credit_max': 300}, [66000, 0]), ('normal control', {'hours': 15, 'cash_rate': 300, 'tips': 777, 'min_wage': 726, 'tip_credit_max': 800}, [10113, 5613])], [('regression', {'hours': 4, 'cash_rate': 1250, 'tips': 3576, 'min_wage': 1200, 'tip_credit_max': 300}, [4800, 0]), ('regression', {'hours': 57, 'cash_rate': 776, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 300}, [47553, 0]), ('partial-repair probe', {'hours': 47, 'cash_rate': 1650, 'tips': 0, 'min_wage': 1600, 'tip_credit_max': 800}, [80800, 0]), ('partial-repair probe', {'hours': 35, 'cash_rate': 776, 'tips': 4941, 'min_wage': 726, 'tip_credit_max': 300}, [25410, 0]), ('normal control', {'hours': 12, 'cash_rate': 213, 'tips': 0, 'min_wage': 726, 'tip_credit_max': 512}, [8712, 6144]), ('normal control', {'hours': 43, 'cash_rate': 1600, 'tips': 32479, 'min_wage': 1600, 'tip_credit_max': 300}, [71200, 0]), ('normal control', {'hours': 36, 'cash_rate': 500, 'tips': 27434, 'min_wage': 1000, 'tip_credit_max': 300}, [25200, 0]), ('normal control', {'hours': 53, 'cash_rate': 300, 'tips': 45712, 'min_wage': 1600, 'tip_credit_max': 512}, [68064, 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 paid a cash rate above minimum wage get negative makeup and inflated wages.

Input weekly {hours, cash_rate, tips, min_wage (even cents), tip_credit_max}. Tip credit per hour = max(0, min(min_wage - cash_rate, tip_credit_max)). Hours over 40 are paid at 1.5*min_wage minus the same credit. Credit actually taken = min(tips, hours*credit); the unmet credit is paid as makeup. Return [cash_wages, makeup].

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):
    h = x['hours']
    base = h * x['rate'] + x['diff_hours'] * x['diff']
    included = base + x['bonus']
    if h == 0:
        return [0, x['bonus']]
    ot = max(0, h - 40)
    rr = Fraction(included, h)
    premium = rr * ot / 2
    prem_c = math.floor(premium + Fraction(1, 2))
    total = base + x['bonus'] + prem_c
    return [prem_c, total]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('partial-repair probe', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('partial-repair probe', {'hours': 49, 'rate': 2740, 'bonus': 1615, 'discretionary': True, 'diff_hours': 20, 'diff': 0}, [12330, 148205]), ('normal control', {'hours': 56, 'rate': 2894, 'bonus': 0, 'discretionary': True, 'diff_hours': 20, 'diff': 189}, [23692, 189536]), ('normal control', {'hours': 48, 'rate': 2361, 'bonus': 0, 'discretionary': False, 'diff_hours': 15, 'diff': 150}, [9632, 125210]), ('normal control', {'hours': 29, 'rate': 3185, 'bonus': 18960, 'discretionary': True, 'diff_hours': 0, 'diff': 235}, [0, 111325]), ('normal control', {'hours': 15, 'rate': 1913, 'bonus': 0, 'discretionary': False, 'diff_hours': 3, 'diff': 100}, [0, 28995])], [('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('regression', {'hours': 49, 'rate': 2740, 'bonus': 1615, 'discretionary': True, 'diff_hours': 20, 'diff': 0}, [12330, 148205]), ('partial-repair probe', {'hours': 52, 'rate': 2128, 'bonus': 978, 'discretionary': True, 'diff_hours': 9, 'diff': 100}, [12872, 125406]), ('partial-repair probe', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('normal control', {'hours': 42, 'rate': 2619, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [2619, 112617]), ('normal control', {'hours': 36, 'rate': 1564, 'bonus': 12440, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 68744]), ('normal control', {'hours': 36, 'rate': 3124, 'bonus': 20788, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 133252]), ('normal control', {'hours': 38, 'rate': 3803, 'bonus': 0, 'discretionary': False, 'diff_hours': 5, 'diff': 175}, [0, 145389])], [('regression', {'hours': 49, 'rate': 2740, 'bonus': 1615, 'discretionary': True, 'diff_hours': 20, 'diff': 0}, [12330, 148205]), ('regression', {'hours': 52, 'rate': 2128, 'bonus': 978, 'discretionary': True, 'diff_hours': 9, 'diff': 100}, [12872, 125406]), ('partial-repair probe', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('partial-repair probe', {'hours': 45, 'rate': 3318, 'bonus': 32787, 'discretionary': False, 'diff_hours': 15, 'diff': 100}, [10200, 193797]), ('normal control', {'hours': 42, 'rate': 1092, 'bonus': 0, 'discretionary': False, 'diff_hours': 2, 'diff': 157}, [1099, 47277]), ('normal control', {'hours': 40, 'rate': 2368, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 94720]), ('normal control', {'hours': 41, 'rate': 1051, 'bonus': 26, 'discretionary': False, 'diff_hours': 0, 'diff': 259}, [526, 43643]), ('normal control', {'hours': 41, 'rate': 1070, 'bonus': 0, 'discretionary': False, 'diff_hours': 14, 'diff': 300}, [586, 48656])], [('regression', {'hours': 52, 'rate': 2128, 'bonus': 978, 'discretionary': True, 'diff_hours': 9, 'diff': 100}, [12872, 125406]), ('regression', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('partial-repair probe', {'hours': 45, 'rate': 3318, 'bonus': 32787, 'discretionary': False, 'diff_hours': 15, 'diff': 100}, [10200, 193797]), ('partial-repair probe', {'hours': 58, 'rate': 1280, 'bonus': 145, 'discretionary': False, 'diff_hours': 5, 'diff': 0}, [11543, 85928]), ('normal control', {'hours': 15, 'rate': 1275, 'bonus': 16297, 'discretionary': False, 'diff_hours': 0, 'diff': 100}, [0, 35422]), ('normal control', {'hours': 0, 'rate': 1235, 'bonus': 452, 'discretionary': False, 'diff_hours': 15, 'diff': 0}, [0, 452]), ('normal control', {'hours': 25, 'rate': 2784, 'bonus': 431, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 70031]), ('normal control', {'hours': 4, 'rate': 2630, 'bonus': 24821, 'discretionary': False, 'diff_hours': 10, 'diff': 100}, [0, 36341])], [('regression', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('regression', {'hours': 42, 'rate': 3763, 'bonus': 30604, 'discretionary': True, 'diff_hours': 0, 'diff': 260}, [3763, 192413]), ('partial-repair probe', {'hours': 55, 'rate': 1200, 'bonus': 40992, 'discretionary': False, 'diff_hours': 10, 'diff': 89}, [14711, 122593]), ('partial-repair probe', {'hours': 50, 'rate': 3473, 'bonus': 15335, 'discretionary': False, 'diff_hours': 14, 'diff': 0}, [18899, 207884]), ('normal control', {'hours': 36, 'rate': 3824, 'bonus': 0, 'discretionary': False, 'diff_hours': 12, 'diff': 100}, [0, 138864]), ('normal control', {'hours': 36, 'rate': 3363, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 0}, [0, 121068]), ('normal control', {'hours': 55, 'rate': 3779, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [28343, 236188]), ('normal control', {'hours': 25, 'rate': 1555, 'bonus': 17670, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 56545])]]
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):
    h = x['hours']
    base = h * x['rate'] + x['diff_hours'] * x['diff']
    included = base + (x['bonus'] if x['discretionary'] else 0)
    if h == 0:
        return [0, x['bonus']]
    ot = max(0, h - 40)
    rr = Fraction(included, h)
    premium = rr * ot / 2
    prem_c = math.floor(premium + Fraction(1, 2))
    total = base + x['bonus'] + prem_c
    return [prem_c, total]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('partial-repair probe', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('partial-repair probe', {'hours': 49, 'rate': 2740, 'bonus': 1615, 'discretionary': True, 'diff_hours': 20, 'diff': 0}, [12330, 148205]), ('normal control', {'hours': 56, 'rate': 2894, 'bonus': 0, 'discretionary': True, 'diff_hours': 20, 'diff': 189}, [23692, 189536]), ('normal control', {'hours': 48, 'rate': 2361, 'bonus': 0, 'discretionary': False, 'diff_hours': 15, 'diff': 150}, [9632, 125210]), ('normal control', {'hours': 29, 'rate': 3185, 'bonus': 18960, 'discretionary': True, 'diff_hours': 0, 'diff': 235}, [0, 111325]), ('normal control', {'hours': 15, 'rate': 1913, 'bonus': 0, 'discretionary': False, 'diff_hours': 3, 'diff': 100}, [0, 28995])], [('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('regression', {'hours': 49, 'rate': 2740, 'bonus': 1615, 'discretionary': True, 'diff_hours': 20, 'diff': 0}, [12330, 148205]), ('partial-repair probe', {'hours': 52, 'rate': 2128, 'bonus': 978, 'discretionary': True, 'diff_hours': 9, 'diff': 100}, [12872, 125406]), ('partial-repair probe', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('normal control', {'hours': 42, 'rate': 2619, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [2619, 112617]), ('normal control', {'hours': 36, 'rate': 1564, 'bonus': 12440, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 68744]), ('normal control', {'hours': 36, 'rate': 3124, 'bonus': 20788, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 133252]), ('normal control', {'hours': 38, 'rate': 3803, 'bonus': 0, 'discretionary': False, 'diff_hours': 5, 'diff': 175}, [0, 145389])], [('regression', {'hours': 49, 'rate': 2740, 'bonus': 1615, 'discretionary': True, 'diff_hours': 20, 'diff': 0}, [12330, 148205]), ('regression', {'hours': 52, 'rate': 2128, 'bonus': 978, 'discretionary': True, 'diff_hours': 9, 'diff': 100}, [12872, 125406]), ('partial-repair probe', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('partial-repair probe', {'hours': 45, 'rate': 3318, 'bonus': 32787, 'discretionary': False, 'diff_hours': 15, 'diff': 100}, [10200, 193797]), ('normal control', {'hours': 42, 'rate': 1092, 'bonus': 0, 'discretionary': False, 'diff_hours': 2, 'diff': 157}, [1099, 47277]), ('normal control', {'hours': 40, 'rate': 2368, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 94720]), ('normal control', {'hours': 41, 'rate': 1051, 'bonus': 26, 'discretionary': False, 'diff_hours': 0, 'diff': 259}, [526, 43643]), ('normal control', {'hours': 41, 'rate': 1070, 'bonus': 0, 'discretionary': False, 'diff_hours': 14, 'diff': 300}, [586, 48656])], [('regression', {'hours': 52, 'rate': 2128, 'bonus': 978, 'discretionary': True, 'diff_hours': 9, 'diff': 100}, [12872, 125406]), ('regression', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('partial-repair probe', {'hours': 45, 'rate': 3318, 'bonus': 32787, 'discretionary': False, 'diff_hours': 15, 'diff': 100}, [10200, 193797]), ('partial-repair probe', {'hours': 58, 'rate': 1280, 'bonus': 145, 'discretionary': False, 'diff_hours': 5, 'diff': 0}, [11543, 85928]), ('normal control', {'hours': 15, 'rate': 1275, 'bonus': 16297, 'discretionary': False, 'diff_hours': 0, 'diff': 100}, [0, 35422]), ('normal control', {'hours': 0, 'rate': 1235, 'bonus': 452, 'discretionary': False, 'diff_hours': 15, 'diff': 0}, [0, 452]), ('normal control', {'hours': 25, 'rate': 2784, 'bonus': 431, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 70031]), ('normal control', {'hours': 4, 'rate': 2630, 'bonus': 24821, 'discretionary': False, 'diff_hours': 10, 'diff': 100}, [0, 36341])], [('regression', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('regression', {'hours': 42, 'rate': 3763, 'bonus': 30604, 'discretionary': True, 'diff_hours': 0, 'diff': 260}, [3763, 192413]), ('partial-repair probe', {'hours': 55, 'rate': 1200, 'bonus': 40992, 'discretionary': False, 'diff_hours': 10, 'diff': 89}, [14711, 122593]), ('partial-repair probe', {'hours': 50, 'rate': 3473, 'bonus': 15335, 'discretionary': False, 'diff_hours': 14, 'diff': 0}, [18899, 207884]), ('normal control', {'hours': 36, 'rate': 3824, 'bonus': 0, 'discretionary': False, 'diff_hours': 12, 'diff': 100}, [0, 138864]), ('normal control', {'hours': 36, 'rate': 3363, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 0}, [0, 121068]), ('normal control', {'hours': 55, 'rate': 3779, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [28343, 236188]), ('normal control', {'hours': 25, 'rate': 1555, 'bonus': 17670, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 56545])]]
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:
Overtime premiums rise when a discretionary spot bonus is paid.

Input weekly {hours, rate, bonus, discretionary, diff_hours, diff}. Straight pay = hours*rate + diff_hours*diff. Regular rate = (straight pay + bonus unless discretionary) / hours. Overtime premium = regular rate * max(0, hours-40) / 2, rounded half-up to the cent. Total = straight pay + bonus + premium. Zero hours returns [0, bonus]. Return [premium, total].

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):
    h = x['hours']
    base = h * x['rate'] + x['diff_hours'] * x['diff']
    included = base + (0 if x['discretionary'] else x['bonus'])
    if h == 0:
        return [0, x['bonus']]
    ot = max(0, h - 40)
    rr = Fraction(included, h)
    premium = rr * ot * 3 / 2
    prem_c = math.floor(premium + Fraction(1, 2))
    total = base + x['bonus'] + prem_c
    return [prem_c, total]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 56, 'rate': 2894, 'bonus': 0, 'discretionary': True, 'diff_hours': 20, 'diff': 189}, [23692, 189536]), ('regression', {'hours': 48, 'rate': 2361, 'bonus': 0, 'discretionary': False, 'diff_hours': 15, 'diff': 150}, [9632, 125210]), ('partial-repair probe', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('partial-repair probe', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('normal control', {'hours': 29, 'rate': 3185, 'bonus': 18960, 'discretionary': True, 'diff_hours': 0, 'diff': 235}, [0, 111325]), ('normal control', {'hours': 15, 'rate': 1913, 'bonus': 0, 'discretionary': False, 'diff_hours': 3, 'diff': 100}, [0, 28995]), ('normal control', {'hours': 36, 'rate': 1564, 'bonus': 12440, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 68744]), ('normal control', {'hours': 36, 'rate': 3124, 'bonus': 20788, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 133252])], [('regression', {'hours': 48, 'rate': 2361, 'bonus': 0, 'discretionary': False, 'diff_hours': 15, 'diff': 150}, [9632, 125210]), ('regression', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('partial-repair probe', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('partial-repair probe', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('normal control', {'hours': 38, 'rate': 3803, 'bonus': 0, 'discretionary': False, 'diff_hours': 5, 'diff': 175}, [0, 145389]), ('normal control', {'hours': 40, 'rate': 2368, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 94720]), ('normal control', {'hours': 15, 'rate': 1275, 'bonus': 16297, 'discretionary': False, 'diff_hours': 0, 'diff': 100}, [0, 35422]), ('normal control', {'hours': 0, 'rate': 1235, 'bonus': 452, 'discretionary': False, 'diff_hours': 15, 'diff': 0}, [0, 452])], [('regression', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('regression', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('partial-repair probe', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('partial-repair probe', {'hours': 42, 'rate': 1092, 'bonus': 0, 'discretionary': False, 'diff_hours': 2, 'diff': 157}, [1099, 47277]), ('normal control', {'hours': 25, 'rate': 2784, 'bonus': 431, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 70031]), ('normal control', {'hours': 4, 'rate': 2630, 'bonus': 24821, 'discretionary': False, 'diff_hours': 10, 'diff': 100}, [0, 36341]), ('normal control', {'hours': 36, 'rate': 3824, 'bonus': 0, 'discretionary': False, 'diff_hours': 12, 'diff': 100}, [0, 138864]), ('normal control', {'hours': 36, 'rate': 3363, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 0}, [0, 121068])], [('regression', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('partial-repair probe', {'hours': 41, 'rate': 1070, 'bonus': 0, 'discretionary': False, 'diff_hours': 14, 'diff': 300}, [586, 48656]), ('partial-repair probe', {'hours': 52, 'rate': 2128, 'bonus': 978, 'discretionary': True, 'diff_hours': 9, 'diff': 100}, [12872, 125406]), ('normal control', {'hours': 25, 'rate': 1555, 'bonus': 17670, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 56545]), ('normal control', {'hours': 13, 'rate': 3420, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 44460]), ('normal control', {'hours': 17, 'rate': 3366, 'bonus': 396, 'discretionary': True, 'diff_hours': 8, 'diff': 0}, [0, 57618]), ('normal control', {'hours': 1, 'rate': 1458, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 1458])], [('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('regression', {'hours': 42, 'rate': 2619, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [2619, 112617]), ('partial-repair probe', {'hours': 45, 'rate': 3318, 'bonus': 32787, 'discretionary': False, 'diff_hours': 15, 'diff': 100}, [10200, 193797]), ('partial-repair probe', {'hours': 58, 'rate': 1280, 'bonus': 145, 'discretionary': False, 'diff_hours': 5, 'diff': 0}, [11543, 85928]), ('normal control', {'hours': 40, 'rate': 2719, 'bonus': 0, 'discretionary': False, 'diff_hours': 13, 'diff': 100}, [0, 110060]), ('normal control', {'hours': 32, 'rate': 3242, 'bonus': 990, 'discretionary': True, 'diff_hours': 0, 'diff': 48}, [0, 104734]), ('normal control', {'hours': 23, 'rate': 2339, 'bonus': 720, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 54517]), ('normal control', {'hours': 22, 'rate': 2030, 'bonus': 44512, 'discretionary': False, 'diff_hours': 13, 'diff': 183}, [0, 91551])]]
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):
    h = x['hours']
    base = h * x['rate'] + x['diff_hours'] * x['diff']
    included = base + (0 if x['discretionary'] else x['bonus'])
    if h == 0:
        return [0, x['bonus']]
    ot = max(0, h - 40)
    rr = Fraction(included, h)
    premium = Fraction(x['rate']) * ot / 2
    prem_c = math.floor(premium + Fraction(1, 2))
    total = base + x['bonus'] + prem_c
    return [prem_c, total]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 56, 'rate': 2894, 'bonus': 0, 'discretionary': True, 'diff_hours': 20, 'diff': 189}, [23692, 189536]), ('regression', {'hours': 48, 'rate': 2361, 'bonus': 0, 'discretionary': False, 'diff_hours': 15, 'diff': 150}, [9632, 125210]), ('partial-repair probe', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('partial-repair probe', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('normal control', {'hours': 29, 'rate': 3185, 'bonus': 18960, 'discretionary': True, 'diff_hours': 0, 'diff': 235}, [0, 111325]), ('normal control', {'hours': 15, 'rate': 1913, 'bonus': 0, 'discretionary': False, 'diff_hours': 3, 'diff': 100}, [0, 28995]), ('normal control', {'hours': 36, 'rate': 1564, 'bonus': 12440, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 68744]), ('normal control', {'hours': 36, 'rate': 3124, 'bonus': 20788, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 133252])], [('regression', {'hours': 48, 'rate': 2361, 'bonus': 0, 'discretionary': False, 'diff_hours': 15, 'diff': 150}, [9632, 125210]), ('regression', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('partial-repair probe', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('partial-repair probe', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('normal control', {'hours': 38, 'rate': 3803, 'bonus': 0, 'discretionary': False, 'diff_hours': 5, 'diff': 175}, [0, 145389]), ('normal control', {'hours': 40, 'rate': 2368, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 94720]), ('normal control', {'hours': 15, 'rate': 1275, 'bonus': 16297, 'discretionary': False, 'diff_hours': 0, 'diff': 100}, [0, 35422]), ('normal control', {'hours': 0, 'rate': 1235, 'bonus': 452, 'discretionary': False, 'diff_hours': 15, 'diff': 0}, [0, 452])], [('regression', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('regression', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('partial-repair probe', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('partial-repair probe', {'hours': 42, 'rate': 1092, 'bonus': 0, 'discretionary': False, 'diff_hours': 2, 'diff': 157}, [1099, 47277]), ('normal control', {'hours': 25, 'rate': 2784, 'bonus': 431, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 70031]), ('normal control', {'hours': 4, 'rate': 2630, 'bonus': 24821, 'discretionary': False, 'diff_hours': 10, 'diff': 100}, [0, 36341]), ('normal control', {'hours': 36, 'rate': 3824, 'bonus': 0, 'discretionary': False, 'diff_hours': 12, 'diff': 100}, [0, 138864]), ('normal control', {'hours': 36, 'rate': 3363, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 0}, [0, 121068])], [('regression', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('partial-repair probe', {'hours': 41, 'rate': 1070, 'bonus': 0, 'discretionary': False, 'diff_hours': 14, 'diff': 300}, [586, 48656]), ('partial-repair probe', {'hours': 52, 'rate': 2128, 'bonus': 978, 'discretionary': True, 'diff_hours': 9, 'diff': 100}, [12872, 125406]), ('normal control', {'hours': 25, 'rate': 1555, 'bonus': 17670, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 56545]), ('normal control', {'hours': 13, 'rate': 3420, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 44460]), ('normal control', {'hours': 17, 'rate': 3366, 'bonus': 396, 'discretionary': True, 'diff_hours': 8, 'diff': 0}, [0, 57618]), ('normal control', {'hours': 1, 'rate': 1458, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 1458])], [('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('regression', {'hours': 42, 'rate': 2619, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [2619, 112617]), ('partial-repair probe', {'hours': 45, 'rate': 3318, 'bonus': 32787, 'discretionary': False, 'diff_hours': 15, 'diff': 100}, [10200, 193797]), ('partial-repair probe', {'hours': 58, 'rate': 1280, 'bonus': 145, 'discretionary': False, 'diff_hours': 5, 'diff': 0}, [11543, 85928]), ('normal control', {'hours': 40, 'rate': 2719, 'bonus': 0, 'discretionary': False, 'diff_hours': 13, 'diff': 100}, [0, 110060]), ('normal control', {'hours': 32, 'rate': 3242, 'bonus': 990, 'discretionary': True, 'diff_hours': 0, 'diff': 48}, [0, 104734]), ('normal control', {'hours': 23, 'rate': 2339, 'bonus': 720, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 54517]), ('normal control', {'hours': 22, 'rate': 2030, 'bonus': 44512, 'discretionary': False, 'diff_hours': 13, 'diff': 183}, [0, 91551])]]
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:
Overtime hours are paid at two and a half times the rate in total.

Input weekly {hours, rate, bonus, discretionary, diff_hours, diff}. Straight pay = hours*rate + diff_hours*diff. Regular rate = (straight pay + bonus unless discretionary) / hours. Overtime premium = regular rate * max(0, hours-40) / 2, rounded half-up to the cent. Total = straight pay + bonus + premium. Zero hours returns [0, bonus]. Return [premium, total].

split: open-access