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

N = 1
observations = []
def solve(x):
    bal = x['balance']
    order = x['order_cents']
    if bal < 500:
        return {'error': 'below minimum'}
    blk = 100
    cap_cents = order * x['max_pct'] // 100
    cap = cap_cents // blk * blk
    use = min(x['request_pts'] // blk * blk, bal // blk * blk, cap)
    return {'points_used': use, 'cash_due': order - use * x['cpp']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal', {'balance': 2750, 'order_cents': 4001, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2201}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5001, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1291, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 51, 'cpp': 2}, {'points_used': 1200, 'cash_due': 2600}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1285, 'max_pct': 90, 'cpp': 1}, {'points_used': 1200, 'cash_due': 8800}]], [['normal', {'balance': 2750, 'order_cents': 4002, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2202}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5002, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 2}, {'points_used': 500, 'cash_due': 8999}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1292, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 52, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1295, 'max_pct': 90, 'cpp': 1}, {'points_used': 1200, 'cash_due': 8800}]], [['normal', {'balance': 2750, 'order_cents': 4003, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2203}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5003, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1293, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 53, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1305, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]], [['normal', {'balance': 2750, 'order_cents': 4004, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2204}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5004, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 2}, {'points_used': 500, 'cash_due': 8999}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1294, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 54, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1315, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]], [['normal', {'balance': 2750, 'order_cents': 4005, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2205}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5005, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1295, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 55, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1325, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    bal = x['balance']
    order = x['order_cents']
    if bal < 500:
        return {'error': 'below minimum'}
    blk = 100
    cap_cents = order * x['max_pct'] // 100
    cap = cap_cents * x['cpp'] // blk * blk
    use = min(x['request_pts'] // blk * blk, bal // blk * blk, cap)
    return {'points_used': use, 'cash_due': order - use * x['cpp']}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal', {'balance': 2750, 'order_cents': 4001, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2201}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5001, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1291, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 51, 'cpp': 2}, {'points_used': 1200, 'cash_due': 2600}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1285, 'max_pct': 90, 'cpp': 1}, {'points_used': 1200, 'cash_due': 8800}]], [['normal', {'balance': 2750, 'order_cents': 4002, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2202}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5002, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 2}, {'points_used': 500, 'cash_due': 8999}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1292, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 52, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1295, 'max_pct': 90, 'cpp': 1}, {'points_used': 1200, 'cash_due': 8800}]], [['normal', {'balance': 2750, 'order_cents': 4003, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2203}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5003, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1293, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 53, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1305, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]], [['normal', {'balance': 2750, 'order_cents': 4004, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2204}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5004, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 2}, {'points_used': 500, 'cash_due': 8999}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1294, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 54, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1315, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]], [['normal', {'balance': 2750, 'order_cents': 4005, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2205}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5005, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1295, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 55, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1325, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
At two cents per point the redemption cap allows twice the intended discount.

Input {balance, order_cents, request_pts, max_pct, cpp (cents per point)}. Balance below 500 returns {"error":"below minimum"}. Points are used in blocks of 100: used = min(request floored to a block, balance floored to a block, cap) where cap = floor(order*max_pct/100 / cpp) floored to a block. Cash due = order - used*cpp. Return {points_used, cash_due}.

split: open-access


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

N = 1
observations = []
def solve(x):
    bal = x['balance']
    order = x['order_cents']
    if bal < 500:
        return {'error': 'below minimum'}
    blk = 100
    cap_cents = order * x['max_pct'] // 100
    cap = cap_cents // x['cpp'] // blk * blk
    use = min(x['request_pts'] // blk * blk, bal // blk * blk, cap)
    return {'points_used': use, 'cash_due': order - use}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal', {'balance': 2750, 'order_cents': 4001, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2201}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5001, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1291, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 51, 'cpp': 2}, {'points_used': 1200, 'cash_due': 2600}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1285, 'max_pct': 90, 'cpp': 1}, {'points_used': 1200, 'cash_due': 8800}]], [['normal', {'balance': 2750, 'order_cents': 4002, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2202}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5002, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 2}, {'points_used': 500, 'cash_due': 8999}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1292, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 52, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1295, 'max_pct': 90, 'cpp': 1}, {'points_used': 1200, 'cash_due': 8800}]], [['normal', {'balance': 2750, 'order_cents': 4003, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2203}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5003, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1293, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 53, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1305, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]], [['normal', {'balance': 2750, 'order_cents': 4004, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2204}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5004, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 2}, {'points_used': 500, 'cash_due': 8999}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1294, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 54, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1315, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]], [['normal', {'balance': 2750, 'order_cents': 4005, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2205}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5005, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1295, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 55, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1325, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(x):
    bal = x['balance']
    order = x['order_cents']
    if bal < 500:
        return {'error': 'below minimum'}
    blk = 100
    cap_cents = order * x['max_pct'] // 100
    cap = cap_cents // x['cpp'] // blk * blk
    use = min(x['request_pts'] // blk * blk, bal // blk * blk, cap)
    return {'points_used': use, 'cash_due': max(0, order - use - x['cpp'])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal', {'balance': 2750, 'order_cents': 4001, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2201}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5001, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1291, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 51, 'cpp': 2}, {'points_used': 1200, 'cash_due': 2600}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1285, 'max_pct': 90, 'cpp': 1}, {'points_used': 1200, 'cash_due': 8800}]], [['normal', {'balance': 2750, 'order_cents': 4002, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2202}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5002, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 2}, {'points_used': 500, 'cash_due': 8999}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1292, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 52, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1295, 'max_pct': 90, 'cpp': 1}, {'points_used': 1200, 'cash_due': 8800}]], [['normal', {'balance': 2750, 'order_cents': 4003, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2203}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5003, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1293, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 53, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1305, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]], [['normal', {'balance': 2750, 'order_cents': 4004, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2204}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5004, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 2}, {'points_used': 500, 'cash_due': 8999}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1294, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 54, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1315, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]], [['normal', {'balance': 2750, 'order_cents': 4005, 'request_pts': 1850, 'max_pct': 50, 'cpp': 1}, {'points_used': 1800, 'cash_due': 2205}], ['cap binds', {'balance': 9000, 'order_cents': 3000, 'request_pts': 5005, 'max_pct': 40, 'cpp': 1}, {'points_used': 1200, 'cash_due': 1800}], ['minimum balance edge', {'balance': 500, 'order_cents': 9999, 'request_pts': 500, 'max_pct': 100, 'cpp': 3}, {'points_used': 500, 'cash_due': 8499}], ['below minimum', {'balance': 499, 'order_cents': 9999, 'request_pts': 400, 'max_pct': 100, 'cpp': 1}, {'error': 'below minimum'}], ['balance binds', {'balance': 1295, 'order_cents': 50000, 'request_pts': 3000, 'max_pct': 60, 'cpp': 1}, {'points_used': 1200, 'cash_due': 48800}], ['two cents per point', {'balance': 5000, 'order_cents': 5000, 'request_pts': 4000, 'max_pct': 55, 'cpp': 2}, {'points_used': 1300, 'cash_due': 2400}], ['odd request', {'balance': 3000, 'order_cents': 10000, 'request_pts': 1325, 'max_pct': 90, 'cpp': 1}, {'points_used': 1300, 'cash_due': 8700}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Cash due is wrong for programs where a point is worth more than one cent.

Input {balance, order_cents, request_pts, max_pct, cpp (cents per point)}. Balance below 500 returns {"error":"below minimum"}. Points are used in blocks of 100: used = min(request floored to a block, balance floored to a block, cap) where cap = floor(order*max_pct/100 / cpp) floored to a block. Cash due = order - used*cpp. Return {points_used, cash_due}.

split: open-access


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

N = 1
observations = []
def solve(x):
    order = ['member', 'silver', 'gold', 'platinum']
    m = x['eval_month']
    q = sum(p for mo, p in x['events'] if m - 12 <= mo <= m)
    earned = 'member'
    for t in order[1:]:
        if q >= x['thresholds'][t]:
            earned = t
    cur = order.index(x['current_tier'])
    e = order.index(earned)
    new = e if e >= cur else cur - 1
    return {'qualifying': q, 'earned': earned, 'tier': order[new]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3501]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15501, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1001]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5001, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 7, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15999]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15999, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 1]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45001, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6001], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6101, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3502]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15502, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1002]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5002, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 8, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15998]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15998, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 2]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45002, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6002], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6102, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3503]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15503, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1003]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5003, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 9, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15997]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15997, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 3]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45003, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6003], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6103, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3504]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15504, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1004]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5004, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 10, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15996]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15996, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 4]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45004, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6004], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6104, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3505]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15505, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1005]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5005, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 11, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15995]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15995, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 5]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45005, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6005], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6105, 'earned': 'silver', 'tier': 'silver'}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    order = ['member', 'silver', 'gold', 'platinum']
    m = x['eval_month']
    q = sum(p for mo, p in x['events'] if m - 11 < mo <= m)
    earned = 'member'
    for t in order[1:]:
        if q >= x['thresholds'][t]:
            earned = t
    cur = order.index(x['current_tier'])
    e = order.index(earned)
    new = e if e >= cur else cur - 1
    return {'qualifying': q, 'earned': earned, 'tier': order[new]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3501]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15501, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1001]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5001, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 7, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15999]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15999, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 1]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45001, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6001], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6101, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3502]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15502, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1002]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5002, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 8, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15998]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15998, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 2]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45002, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6002], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6102, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3503]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15503, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1003]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5003, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 9, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15997]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15997, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 3]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45003, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6003], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6103, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3504]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15504, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1004]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5004, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 10, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15996]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15996, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 4]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45004, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6004], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6104, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3505]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15505, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1005]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5005, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 11, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15995]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15995, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 5]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45005, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6005], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6105, 'earned': 'silver', 'tier': 'silver'}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Activity from thirteen months ago still counts toward status.

Input {events:[[month,qualifying pts]], eval_month, current_tier, thresholds}. Qualifying points are summed over months eval-11..eval inclusive. The earned tier is the highest tier whose threshold is met (>=). Upgrades take effect fully; downgrades drop at most one level per evaluation. Tiers: member < silver < gold < platinum. Return {qualifying, earned, tier}.

split: open-access


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

N = 1
observations = []
def solve(x):
    order = ['member', 'silver', 'gold', 'platinum']
    m = x['eval_month']
    q = sum(p for mo, p in x['events'] if m - 11 <= mo)
    earned = 'member'
    for t in order[1:]:
        if q >= x['thresholds'][t]:
            earned = t
    cur = order.index(x['current_tier'])
    e = order.index(earned)
    new = e if e >= cur else cur - 1
    return {'qualifying': q, 'earned': earned, 'tier': order[new]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3501]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15501, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1001]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5001, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 7, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15999]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15999, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 1]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45001, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6001], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6101, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3502]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15502, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1002]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5002, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 8, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15998]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15998, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 2]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45002, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6002], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6102, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3503]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15503, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1003]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5003, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 9, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15997]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15997, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 3]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45003, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6003], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6103, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3504]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15504, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1004]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5004, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 10, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15996]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15996, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 4]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45004, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6004], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6104, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3505]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15505, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1005]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5005, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 11, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15995]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15995, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 5]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45005, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6005], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6105, 'earned': 'silver', 'tier': 'silver'}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    order = ['member', 'silver', 'gold', 'platinum']
    m = x['eval_month']
    q = sum(p for mo, p in x['events'] if m - 11 <= mo < m)
    earned = 'member'
    for t in order[1:]:
        if q >= x['thresholds'][t]:
            earned = t
    cur = order.index(x['current_tier'])
    e = order.index(earned)
    new = e if e >= cur else cur - 1
    return {'qualifying': q, 'earned': earned, 'tier': order[new]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3501]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15501, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1001]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5001, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 7, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15999]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15999, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 1]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45001, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6001], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6101, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3502]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15502, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1002]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5002, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 8, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15998]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15998, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 2]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45002, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6002], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6102, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3503]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15503, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1003]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5003, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 9, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15997]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15997, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 3]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45003, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6003], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6103, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3504]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15504, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1004]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5004, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 10, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15996]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15996, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 4]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45004, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6004], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6104, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3505]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15505, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1005]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5005, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 11, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15995]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15995, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 5]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45005, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6005], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6105, 'earned': 'silver', 'tier': 'silver'}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Future-dated corrections posted for later months qualify members early.

Input {events:[[month,qualifying pts]], eval_month, current_tier, thresholds}. Qualifying points are summed over months eval-11..eval inclusive. The earned tier is the highest tier whose threshold is met (>=). Upgrades take effect fully; downgrades drop at most one level per evaluation. Tiers: member < silver < gold < platinum. Return {qualifying, earned, tier}.

split: open-access


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

N = 1
observations = []
def solve(x):
    order = ['member', 'silver', 'gold', 'platinum']
    m = x['eval_month']
    q = sum(p for mo, p in x['events'] if m - 11 <= mo <= m)
    earned = 'member'
    for t in order[1:]:
        if q > x['thresholds'][t]:
            earned = t
    cur = order.index(x['current_tier'])
    e = order.index(earned)
    new = e if e >= cur else cur - 1
    return {'qualifying': q, 'earned': earned, 'tier': order[new]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3501]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15501, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1001]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5001, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 7, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15999]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15999, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 1]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45001, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6001], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6101, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3502]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15502, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1002]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5002, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 8, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15998]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15998, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 2]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45002, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6002], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6102, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3503]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15503, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1003]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5003, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 9, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15997]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15997, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 3]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45003, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6003], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6103, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3504]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15504, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1004]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5004, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 10, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15996]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15996, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 4]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45004, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6004], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6104, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3505]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15505, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1005]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5005, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 11, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15995]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15995, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 5]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45005, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6005], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6105, 'earned': 'silver', 'tier': 'silver'}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    order = ['member', 'silver', 'gold', 'platinum']
    m = x['eval_month']
    q = sum(p for mo, p in x['events'] if m - 11 <= mo <= m)
    earned = 'member'
    for t in order[1:]:
        if q > x['thresholds'][t] - 1 and q != x['thresholds'][t]:
            earned = t
    cur = order.index(x['current_tier'])
    e = order.index(earned)
    new = e if e >= cur else cur - 1
    return {'qualifying': q, 'earned': earned, 'tier': order[new]}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3501]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15501, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1001]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5001, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 7, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15999]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15999, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 1]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45001, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6001], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6101, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3502]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15502, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1002]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5002, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 8, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15998]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15998, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 2]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45002, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6002], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6102, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3503]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15503, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1003]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5003, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 9, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15997]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15997, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 3]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45003, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6003], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6103, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3504]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15504, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1004]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5004, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 10, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15996]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15996, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 4]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45004, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6004], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6104, 'earned': 'silver', 'tier': 'silver'}]], [['upgrade', {'events': [[1, 3000], [5, 9000], [11, 3505]], 'eval_month': 12, 'current_tier': 'silver', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15505, 'earned': 'gold', 'tier': 'gold'}], ['window edges', {'events': [[0, 20000], [1, 4000], [12, 1005]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 5005, 'earned': 'silver', 'tier': 'silver'}], ['future month', {'events': [[10, 4000], [13, 20000]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 4000, 'earned': 'member', 'tier': 'member'}], ['exact threshold', {'events': [[6, 15000]], 'eval_month': 11, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15000, 'earned': 'gold', 'tier': 'gold'}], ['soft landing', {'events': [[3, 1000]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 1000, 'earned': 'member', 'tier': 'gold'}], ['one step down', {'events': [[8, 15995]], 'eval_month': 12, 'current_tier': 'platinum', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 15995, 'earned': 'gold', 'tier': 'gold'}], ['big jump', {'events': [[12, 45000], [2, 5]], 'eval_month': 12, 'current_tier': 'member', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 45005, 'earned': 'platinum', 'tier': 'platinum'}], ['current month', {'events': [[20, 6005], [9, 100]], 'eval_month': 20, 'current_tier': 'gold', 'thresholds': {'silver': 5000, 'gold': 15000, 'platinum': 40000}}, {'qualifying': 6105, 'earned': 'silver', 'tier': 'silver'}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Members who hit a tier threshold exactly are not promoted.

Input {events:[[month,qualifying pts]], eval_month, current_tier, thresholds}. Qualifying points are summed over months eval-11..eval inclusive. The earned tier is the highest tier whose threshold is met (>=). Upgrades take effect fully; downgrades drop at most one level per evaluation. Tiers: member < silver < gold < platinum. Return {qualifying, earned, tier}.

split: open-access