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

N = 1
observations = []
def solve(call_price, S, K, dividend, last_cum_day):
    c = round(call_price * 100)
    intrinsic = max(round(S * 100) - round(K * 100), 0)
    if not last_cum_day:
        return False
    extrinsic = c - intrinsic
    return round(dividend * 100) > extrinsic
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression in-the-money guard 1', [0.25, 105.0, 110.0, 1.0, True], False], ['regression in-the-money guard 2', [1.0, 98.0, 110.0, 1.01, True], False], ['partial repair probe 1', [0.05, 98.0, 110.0, 0.060000000000000005, True], False], ['partial repair probe 2', [0.05, 98.0, 100.0, 0.25, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.5, True], False], ['boundary control 2', [10.5, 110.0, 100.0, 0.51, True], True], ['normal control 1', [1.0, 98.0, 100.0, 1.0, True], False], ['normal control 2', [1.5, 105.0, 110.0, 1.5, False], False]], [['regression in-the-money guard 1', [0.5, 100.0, 100.0, 0.51, True], False], ['regression in-the-money guard 2', [1.5, 98.0, 110.0, 1.51, True], False], ['partial repair probe 1', [0.05, 105.0, 110.0, 1.0, True], False], ['partial repair probe 2', [0.25, 100.0, 110.0, 1.0, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.51, True], True], ['boundary control 2', [10.5, 110.0, 100.0, 0.5, True], False], ['normal control 1', [1.5, 100.0, 110.0, 1.5, False], False], ['normal control 2', [10.5, 120.0, 110.0, 0.25, True], False]], [['regression in-the-money guard 1', [1.0, 98.0, 110.0, 1.01, True], False], ['regression in-the-money guard 2', [0.05, 100.0, 110.0, 0.25, True], False], ['partial repair probe 1', [1.0, 100.0, 100.0, 1.01, True], False], ['partial repair probe 2', [0.25, 100.0, 100.0, 0.26, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.5, True], False], ['boundary control 2', [10.5, 110.0, 100.0, 0.51, True], True], ['normal control 1', [1.0, 98.0, 100.0, 1.0, True], False], ['normal control 2', [5.05, 105.0, 100.0, 0.25, False], False]], [['regression in-the-money guard 1', [0.5, 98.0, 110.0, 1.0, True], False], ['regression in-the-money guard 2', [1.0, 100.0, 110.0, 1.01, True], False], ['partial repair probe 1', [0.05, 98.0, 100.0, 0.060000000000000005, True], False], ['partial repair probe 2', [1.0, 105.0, 110.0, 1.01, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.51, True], True], ['boundary control 2', [10.5, 110.0, 100.0, 0.5, True], False], ['normal control 1', [20.5, 120.0, 100.0, 0.25, False], False], ['normal control 2', [8.25, 98.0, 90.0, 0.25, False], False]], [['regression in-the-money guard 1', [0.5, 100.0, 110.0, 0.51, True], False], ['regression in-the-money guard 2', [1.0, 98.0, 100.0, 1.01, True], False], ['partial repair probe 1', [0.25, 98.0, 110.0, 0.26, True], False], ['partial repair probe 2', [0.5, 98.0, 100.0, 1.0, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.51, True], True], ['boundary control 2', [10.5, 110.0, 100.0, 0.5, True], False], ['normal control 1', [10.05, 120.0, 110.0, 0.05, False], False], ['normal control 2', [16.5, 105.0, 90.0, 1.0, True], False]]]
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(call_price, S, K, dividend, last_cum_day):
    c = round(call_price * 100)
    intrinsic = max(round(S * 100) - round(K * 100), 0)
    if not last_cum_day or intrinsic < 0:
        return False
    extrinsic = c - intrinsic
    return round(dividend * 100) > extrinsic
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression in-the-money guard 1', [0.25, 105.0, 110.0, 1.0, True], False], ['regression in-the-money guard 2', [1.0, 98.0, 110.0, 1.01, True], False], ['partial repair probe 1', [0.05, 98.0, 110.0, 0.060000000000000005, True], False], ['partial repair probe 2', [0.05, 98.0, 100.0, 0.25, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.5, True], False], ['boundary control 2', [10.5, 110.0, 100.0, 0.51, True], True], ['normal control 1', [1.0, 98.0, 100.0, 1.0, True], False], ['normal control 2', [1.5, 105.0, 110.0, 1.5, False], False]], [['regression in-the-money guard 1', [0.5, 100.0, 100.0, 0.51, True], False], ['regression in-the-money guard 2', [1.5, 98.0, 110.0, 1.51, True], False], ['partial repair probe 1', [0.05, 105.0, 110.0, 1.0, True], False], ['partial repair probe 2', [0.25, 100.0, 110.0, 1.0, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.51, True], True], ['boundary control 2', [10.5, 110.0, 100.0, 0.5, True], False], ['normal control 1', [1.5, 100.0, 110.0, 1.5, False], False], ['normal control 2', [10.5, 120.0, 110.0, 0.25, True], False]], [['regression in-the-money guard 1', [1.0, 98.0, 110.0, 1.01, True], False], ['regression in-the-money guard 2', [0.05, 100.0, 110.0, 0.25, True], False], ['partial repair probe 1', [1.0, 100.0, 100.0, 1.01, True], False], ['partial repair probe 2', [0.25, 100.0, 100.0, 0.26, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.5, True], False], ['boundary control 2', [10.5, 110.0, 100.0, 0.51, True], True], ['normal control 1', [1.0, 98.0, 100.0, 1.0, True], False], ['normal control 2', [5.05, 105.0, 100.0, 0.25, False], False]], [['regression in-the-money guard 1', [0.5, 98.0, 110.0, 1.0, True], False], ['regression in-the-money guard 2', [1.0, 100.0, 110.0, 1.01, True], False], ['partial repair probe 1', [0.05, 98.0, 100.0, 0.060000000000000005, True], False], ['partial repair probe 2', [1.0, 105.0, 110.0, 1.01, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.51, True], True], ['boundary control 2', [10.5, 110.0, 100.0, 0.5, True], False], ['normal control 1', [20.5, 120.0, 100.0, 0.25, False], False], ['normal control 2', [8.25, 98.0, 90.0, 0.25, False], False]], [['regression in-the-money guard 1', [0.5, 100.0, 110.0, 0.51, True], False], ['regression in-the-money guard 2', [1.0, 98.0, 100.0, 1.01, True], False], ['partial repair probe 1', [0.25, 98.0, 110.0, 0.26, True], False], ['partial repair probe 2', [0.5, 98.0, 100.0, 1.0, True], False], ['boundary control 1', [10.5, 110.0, 100.0, 0.51, True], True], ['boundary control 2', [10.5, 110.0, 100.0, 0.5, True], False], ['normal control 1', [10.05, 120.0, 110.0, 0.05, False], False], ['normal control 2', [16.5, 105.0, 90.0, 1.0, True], False]]]
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:
Holders exercise worthless calls to capture a dividend they cannot receive profitably.

Inputs call price, spot, strike, dividend and whether today is the last cum-dividend day. Exercise only on the last cum-dividend day, only if the call is in the money, and only if the dividend is strictly greater than the call's extrinsic value (price - intrinsic). Amounts compared exactly in cents. Return true/false.

split: open-access


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

N = 1
observations = []
def solve(call_price, S, K, dividend, last_cum_day):
    c = round(call_price * 100)
    intrinsic = max(round(S * 100) - round(K * 100), 0)
    if not last_cum_day or intrinsic == 0:
        return False
    extrinsic = c - intrinsic
    return round(dividend * 100) >= extrinsic
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression break-even tie 1', [15.5, 105.0, 90.0, 0.5, True], False], ['regression break-even tie 2', [8.5, 98.0, 90.0, 0.5, True], False], ['partial repair probe 1', [15.25, 105.0, 90.0, 0.26, True], True], ['partial repair probe 2', [5.5, 105.0, 100.0, 0.51, True], True], ['normal control 1', [21.0, 120.0, 100.0, 0.5, True], False], ['normal control 2', [0.5, 100.0, 100.0, 0.51, True], False], ['normal control 3', [0.5, 100.0, 100.0, 0.5, False], False], ['normal control 4', [1.5, 100.0, 110.0, 1.51, True], False]], [['regression break-even tie 1', [10.5, 100.0, 90.0, 0.5, True], False], ['regression break-even tie 2', [16.5, 105.0, 90.0, 1.5, True], False], ['partial repair probe 1', [15.5, 105.0, 90.0, 0.51, True], True], ['partial repair probe 2', [10.25, 120.0, 110.0, 0.26, True], True], ['normal control 1', [0.25, 98.0, 110.0, 1.0, True], False], ['normal control 2', [0.5, 98.0, 110.0, 0.5, True], False], ['normal control 3', [1.5, 100.0, 100.0, 1.0, True], False], ['normal control 4', [0.25, 98.0, 100.0, 0.26, True], False]], [['regression break-even tie 1', [8.5, 98.0, 90.0, 0.5, True], False], ['regression break-even tie 2', [11.5, 120.0, 110.0, 1.5, True], False], ['partial repair probe 1', [20.25, 120.0, 100.0, 0.26, True], True], ['partial repair probe 2', [11.5, 120.0, 110.0, 1.51, True], True], ['normal control 1', [5.05, 105.0, 100.0, 0.5, True], True], ['normal control 2', [0.25, 105.0, 110.0, 0.5, True], False], ['normal control 3', [10.5, 120.0, 110.0, 1.0, True], True], ['normal control 4', [1.0, 98.0, 100.0, 0.5, True], False]], [['regression break-even tie 1', [15.5, 105.0, 90.0, 0.5, True], False], ['regression break-even tie 2', [20.25, 120.0, 100.0, 0.25, True], False], ['partial repair probe 1', [11.0, 120.0, 110.0, 1.01, True], True], ['partial repair probe 2', [5.5, 105.0, 100.0, 0.51, True], True], ['normal control 1', [8.05, 98.0, 90.0, 0.05, False], False], ['normal control 2', [0.25, 100.0, 110.0, 0.5, True], False], ['normal control 3', [9.5, 98.0, 90.0, 1.51, False], False], ['normal control 4', [1.0, 98.0, 100.0, 1.0, True], False]], [['regression break-even tie 1', [10.25, 120.0, 110.0, 0.25, True], False], ['regression break-even tie 2', [11.0, 120.0, 110.0, 1.0, True], False], ['partial repair probe 1', [11.0, 120.0, 110.0, 1.01, True], True], ['partial repair probe 2', [6.5, 105.0, 100.0, 1.51, True], True], ['normal control 1', [0.5, 105.0, 110.0, 0.25, True], False], ['normal control 2', [1.0, 98.0, 100.0, 0.5, True], False], ['normal control 3', [8.05, 98.0, 90.0, 0.060000000000000005, False], False], ['normal control 4', [0.25, 98.0, 100.0, 1.0, True], False]]]
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(call_price, S, K, dividend, last_cum_day):
    c = round(call_price * 100)
    intrinsic = max(round(S * 100) - round(K * 100), 0)
    if not last_cum_day or intrinsic == 0:
        return False
    extrinsic = c - intrinsic
    return round(dividend * 100) > extrinsic + 1
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression break-even tie 1', [15.5, 105.0, 90.0, 0.5, True], False], ['regression break-even tie 2', [8.5, 98.0, 90.0, 0.5, True], False], ['partial repair probe 1', [15.25, 105.0, 90.0, 0.26, True], True], ['partial repair probe 2', [5.5, 105.0, 100.0, 0.51, True], True], ['normal control 1', [21.0, 120.0, 100.0, 0.5, True], False], ['normal control 2', [0.5, 100.0, 100.0, 0.51, True], False], ['normal control 3', [0.5, 100.0, 100.0, 0.5, False], False], ['normal control 4', [1.5, 100.0, 110.0, 1.51, True], False]], [['regression break-even tie 1', [10.5, 100.0, 90.0, 0.5, True], False], ['regression break-even tie 2', [16.5, 105.0, 90.0, 1.5, True], False], ['partial repair probe 1', [15.5, 105.0, 90.0, 0.51, True], True], ['partial repair probe 2', [10.25, 120.0, 110.0, 0.26, True], True], ['normal control 1', [0.25, 98.0, 110.0, 1.0, True], False], ['normal control 2', [0.5, 98.0, 110.0, 0.5, True], False], ['normal control 3', [1.5, 100.0, 100.0, 1.0, True], False], ['normal control 4', [0.25, 98.0, 100.0, 0.26, True], False]], [['regression break-even tie 1', [8.5, 98.0, 90.0, 0.5, True], False], ['regression break-even tie 2', [11.5, 120.0, 110.0, 1.5, True], False], ['partial repair probe 1', [20.25, 120.0, 100.0, 0.26, True], True], ['partial repair probe 2', [11.5, 120.0, 110.0, 1.51, True], True], ['normal control 1', [5.05, 105.0, 100.0, 0.5, True], True], ['normal control 2', [0.25, 105.0, 110.0, 0.5, True], False], ['normal control 3', [10.5, 120.0, 110.0, 1.0, True], True], ['normal control 4', [1.0, 98.0, 100.0, 0.5, True], False]], [['regression break-even tie 1', [15.5, 105.0, 90.0, 0.5, True], False], ['regression break-even tie 2', [20.25, 120.0, 100.0, 0.25, True], False], ['partial repair probe 1', [11.0, 120.0, 110.0, 1.01, True], True], ['partial repair probe 2', [5.5, 105.0, 100.0, 0.51, True], True], ['normal control 1', [8.05, 98.0, 90.0, 0.05, False], False], ['normal control 2', [0.25, 100.0, 110.0, 0.5, True], False], ['normal control 3', [9.5, 98.0, 90.0, 1.51, False], False], ['normal control 4', [1.0, 98.0, 100.0, 1.0, True], False]], [['regression break-even tie 1', [10.25, 120.0, 110.0, 0.25, True], False], ['regression break-even tie 2', [11.0, 120.0, 110.0, 1.0, True], False], ['partial repair probe 1', [11.0, 120.0, 110.0, 1.01, True], True], ['partial repair probe 2', [6.5, 105.0, 100.0, 1.51, True], True], ['normal control 1', [0.5, 105.0, 110.0, 0.25, True], False], ['normal control 2', [1.0, 98.0, 100.0, 0.5, True], False], ['normal control 3', [8.05, 98.0, 90.0, 0.060000000000000005, False], False], ['normal control 4', [0.25, 98.0, 100.0, 1.0, True], False]]]
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:
Exercise happens when the holder is indifferent.

Inputs call price, spot, strike, dividend and whether today is the last cum-dividend day. Exercise only on the last cum-dividend day, only if the call is in the money, and only if the dividend is strictly greater than the call's extrinsic value (price - intrinsic). Amounts compared exactly in cents. Return true/false.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(expiry, submit, cutoff, extension, member):
    e = datetime.date(*expiry)
    y, m, d, hh, mm = submit
    sd = datetime.date(y, m, d)
    if sd > e:
        return 'expired'
    if sd < e:
        return 'accepted'
    limit = cutoff[0] * 60 + cutoff[1] + (extension if member else 0)
    return 'accepted' if hh <= limit // 60 and mm <= limit % 60 else 'late'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression cutoff comparison 1', [[2027, 10, 31], [2027, 10, 31, 15, 59], [16, 0], 0, True], 'accepted'], ['regression cutoff comparison 2', [[2030, 2, 28], [2030, 2, 28, 17, 30], [17, 30], 90, True], 'accepted'], ['partial repair probe 1', [[2020, 3, 1], [2020, 3, 1, 17, 0], [17, 0], 0, False], 'accepted'], ['partial repair probe 2', [[2024, 10, 7], [2024, 10, 7, 16, 0], [16, 0], 0, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2029, 6, 27], [2029, 6, 25, 18, 0], [17, 0], 0, True], 'accepted'], ['normal control 2', [[2027, 1, 3], [2027, 1, 1, 19, 30], [17, 30], 30, True], 'accepted'], ['normal control 3', [[2029, 10, 8], [2029, 10, 3, 15, 59], [16, 0], 30, True], 'accepted']], [['regression cutoff comparison 1', [[2022, 10, 14], [2022, 10, 14, 16, 59], [17, 0], 90, False], 'accepted'], ['regression cutoff comparison 2', [[2025, 5, 8], [2025, 5, 8, 15, 59], [16, 0], 30, False], 'accepted'], ['partial repair probe 1', [[2029, 3, 8], [2029, 3, 8, 17, 30], [17, 0], 30, True], 'accepted'], ['partial repair probe 2', [[2030, 4, 30], [2030, 4, 30, 18, 0], [17, 30], 30, True], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2022, 12, 21], [2022, 12, 22, 17, 1], [17, 0], 0, True], 'expired'], ['normal control 2', [[2021, 5, 30], [2021, 5, 29, 19, 0], [17, 30], 0, False], 'accepted'], ['normal control 3', [[2021, 11, 29], [2021, 11, 28, 18, 0], [17, 30], 90, False], 'accepted']], [['regression cutoff comparison 1', [[2030, 1, 24], [2030, 1, 24, 14, 30], [16, 0], 30, False], 'accepted'], ['regression cutoff comparison 2', [[2026, 12, 21], [2026, 12, 21, 16, 29], [17, 0], 0, True], 'accepted'], ['partial repair probe 1', [[2028, 4, 25], [2028, 4, 25, 17, 0], [17, 0], 90, False], 'accepted'], ['partial repair probe 2', [[2023, 7, 4], [2023, 7, 4, 16, 0], [16, 0], 0, True], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2020, 2, 28], [2020, 2, 28, 18, 0], [16, 0], 30, False], 'late'], ['normal control 2', [[2020, 5, 1], [2020, 4, 30, 7, 30], [17, 30], 30, True], 'accepted'], ['normal control 3', [[2025, 4, 1], [2025, 3, 30, 17, 29], [17, 30], 30, True], 'accepted']], [['regression cutoff comparison 1', [[2027, 6, 30], [2027, 6, 30, 15, 30], [17, 0], 90, False], 'accepted'], ['regression cutoff comparison 2', [[2027, 2, 14], [2027, 2, 14, 18, 30], [17, 30], 90, True], 'accepted'], ['partial repair probe 1', [[2030, 11, 18], [2030, 11, 18, 17, 0], [17, 0], 0, True], 'accepted'], ['partial repair probe 2', [[2030, 3, 30], [2030, 3, 30, 17, 0], [17, 0], 0, True], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2026, 5, 10], [2026, 5, 8, 16, 1], [16, 0], 90, False], 'accepted'], ['normal control 2', [[2024, 3, 7], [2024, 3, 6, 17, 29], [17, 30], 0, True], 'accepted'], ['normal control 3', [[2028, 9, 30], [2028, 9, 30, 16, 1], [16, 0], 0, True], 'late']], [['regression cutoff comparison 1', [[2026, 3, 1], [2026, 3, 1, 16, 59], [17, 30], 90, False], 'accepted'], ['regression cutoff comparison 2', [[2020, 12, 30], [2020, 12, 30, 15, 29], [16, 0], 0, False], 'accepted'], ['partial repair probe 1', [[2026, 12, 18], [2026, 12, 18, 17, 30], [17, 30], 0, False], 'accepted'], ['partial repair probe 2', [[2022, 10, 16], [2022, 10, 16, 16, 0], [16, 0], 90, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2026, 9, 30], [2026, 9, 30, 16, 30], [16, 0], 90, False], 'late'], ['normal control 2', [[2027, 6, 25], [2027, 6, 20, 19, 0], [17, 30], 0, False], 'accepted'], ['normal control 3', [[2022, 1, 28], [2022, 1, 27, 6, 0], [16, 0], 30, False], 'accepted']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(expiry, submit, cutoff, extension, member):
    e = datetime.date(*expiry)
    y, m, d, hh, mm = submit
    sd = datetime.date(y, m, d)
    if sd > e:
        return 'expired'
    if sd < e:
        return 'accepted'
    limit = cutoff[0] * 60 + cutoff[1] + (extension if member else 0)
    return 'accepted' if hh * 60 + mm < limit else 'late'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression cutoff comparison 1', [[2027, 10, 31], [2027, 10, 31, 15, 59], [16, 0], 0, True], 'accepted'], ['regression cutoff comparison 2', [[2030, 2, 28], [2030, 2, 28, 17, 30], [17, 30], 90, True], 'accepted'], ['partial repair probe 1', [[2020, 3, 1], [2020, 3, 1, 17, 0], [17, 0], 0, False], 'accepted'], ['partial repair probe 2', [[2024, 10, 7], [2024, 10, 7, 16, 0], [16, 0], 0, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2029, 6, 27], [2029, 6, 25, 18, 0], [17, 0], 0, True], 'accepted'], ['normal control 2', [[2027, 1, 3], [2027, 1, 1, 19, 30], [17, 30], 30, True], 'accepted'], ['normal control 3', [[2029, 10, 8], [2029, 10, 3, 15, 59], [16, 0], 30, True], 'accepted']], [['regression cutoff comparison 1', [[2022, 10, 14], [2022, 10, 14, 16, 59], [17, 0], 90, False], 'accepted'], ['regression cutoff comparison 2', [[2025, 5, 8], [2025, 5, 8, 15, 59], [16, 0], 30, False], 'accepted'], ['partial repair probe 1', [[2029, 3, 8], [2029, 3, 8, 17, 30], [17, 0], 30, True], 'accepted'], ['partial repair probe 2', [[2030, 4, 30], [2030, 4, 30, 18, 0], [17, 30], 30, True], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2022, 12, 21], [2022, 12, 22, 17, 1], [17, 0], 0, True], 'expired'], ['normal control 2', [[2021, 5, 30], [2021, 5, 29, 19, 0], [17, 30], 0, False], 'accepted'], ['normal control 3', [[2021, 11, 29], [2021, 11, 28, 18, 0], [17, 30], 90, False], 'accepted']], [['regression cutoff comparison 1', [[2030, 1, 24], [2030, 1, 24, 14, 30], [16, 0], 30, False], 'accepted'], ['regression cutoff comparison 2', [[2026, 12, 21], [2026, 12, 21, 16, 29], [17, 0], 0, True], 'accepted'], ['partial repair probe 1', [[2028, 4, 25], [2028, 4, 25, 17, 0], [17, 0], 90, False], 'accepted'], ['partial repair probe 2', [[2023, 7, 4], [2023, 7, 4, 16, 0], [16, 0], 0, True], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2020, 2, 28], [2020, 2, 28, 18, 0], [16, 0], 30, False], 'late'], ['normal control 2', [[2020, 5, 1], [2020, 4, 30, 7, 30], [17, 30], 30, True], 'accepted'], ['normal control 3', [[2025, 4, 1], [2025, 3, 30, 17, 29], [17, 30], 30, True], 'accepted']], [['regression cutoff comparison 1', [[2027, 6, 30], [2027, 6, 30, 15, 30], [17, 0], 90, False], 'accepted'], ['regression cutoff comparison 2', [[2027, 2, 14], [2027, 2, 14, 18, 30], [17, 30], 90, True], 'accepted'], ['partial repair probe 1', [[2030, 11, 18], [2030, 11, 18, 17, 0], [17, 0], 0, True], 'accepted'], ['partial repair probe 2', [[2030, 3, 30], [2030, 3, 30, 17, 0], [17, 0], 0, True], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2026, 5, 10], [2026, 5, 8, 16, 1], [16, 0], 90, False], 'accepted'], ['normal control 2', [[2024, 3, 7], [2024, 3, 6, 17, 29], [17, 30], 0, True], 'accepted'], ['normal control 3', [[2028, 9, 30], [2028, 9, 30, 16, 1], [16, 0], 0, True], 'late']], [['regression cutoff comparison 1', [[2026, 3, 1], [2026, 3, 1, 16, 59], [17, 30], 90, False], 'accepted'], ['regression cutoff comparison 2', [[2020, 12, 30], [2020, 12, 30, 15, 29], [16, 0], 0, False], 'accepted'], ['partial repair probe 1', [[2026, 12, 18], [2026, 12, 18, 17, 30], [17, 30], 0, False], 'accepted'], ['partial repair probe 2', [[2022, 10, 16], [2022, 10, 16, 16, 0], [16, 0], 90, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 20, 23, 0], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2026, 9, 30], [2026, 9, 30, 16, 30], [16, 0], 90, False], 'late'], ['normal control 2', [[2027, 6, 25], [2027, 6, 20, 19, 0], [17, 30], 0, False], 'accepted'], ['normal control 3', [[2022, 1, 28], [2022, 1, 27, 6, 0], [16, 0], 30, False], 'accepted']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A 16:45 notice is late against a 17:30 cutoff.

Inputs expiry date, submission [y,m,d,hh,mm], cutoff [hh,mm], extension minutes and member flag. Notices after the expiry date are "expired"; notices on earlier dates are "accepted"; on the expiry date a notice is accepted if its minute of day <= cutoff (+extension for members), else "late".

split: open-access


prompt:
Non-member notices are accepted after the cutoff.

Inputs expiry date, submission [y,m,d,hh,mm], cutoff [hh,mm], extension minutes and member flag. Notices after the expiry date are "expired"; notices on earlier dates are "accepted"; on the expiry date a notice is accepted if its minute of day <= cutoff (+extension for members), else "late".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(expiry, submit, cutoff, extension, member):
    e = datetime.date(*expiry)
    y, m, d, hh, mm = submit
    sd = datetime.date(y, m, d)
    if sd > e:
        return 'expired'
    if (e - sd).days > 1:
        return 'accepted'
    limit = cutoff[0] * 60 + cutoff[1] + (extension if member else 0)
    return 'accepted' if hh * 60 + mm <= limit else 'late'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression earlier-day notices 1', [[2025, 10, 12], [2025, 10, 11, 19, 30], [17, 30], 30, False], 'accepted'], ['regression earlier-day notices 2', [[2022, 7, 29], [2022, 7, 28, 18, 30], [17, 30], 0, False], 'accepted'], ['partial repair probe 1', [[2020, 3, 27], [2020, 3, 25, 16, 30], [16, 0], 0, False], 'accepted'], ['partial repair probe 2', [[2020, 6, 27], [2020, 6, 25, 18, 31], [17, 0], 30, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2023, 11, 14], [2023, 11, 14, 18, 30], [17, 0], 90, False], 'late'], ['normal control 2', [[2029, 7, 24], [2029, 7, 22, 14, 30], [16, 0], 30, False], 'accepted'], ['normal control 3', [[2029, 2, 28], [2029, 2, 23, 15, 29], [16, 0], 90, True], 'accepted']], [['regression earlier-day notices 1', [[2027, 2, 25], [2027, 2, 24, 19, 0], [17, 30], 0, False], 'accepted'], ['regression earlier-day notices 2', [[2021, 2, 28], [2021, 2, 27, 18, 31], [17, 0], 0, True], 'accepted'], ['partial repair probe 1', [[2024, 7, 30], [2024, 7, 25, 18, 0], [17, 30], 30, True], 'accepted'], ['partial repair probe 2', [[2023, 7, 31], [2023, 7, 26, 19, 30], [17, 30], 90, True], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2023, 5, 6], [2023, 5, 6, 18, 0], [17, 30], 90, True], 'accepted'], ['normal control 2', [[2024, 4, 30], [2024, 5, 1, 16, 0], [16, 0], 0, False], 'expired'], ['normal control 3', [[2022, 12, 31], [2022, 12, 31, 18, 0], [17, 0], 0, False], 'late']], [['regression earlier-day notices 1', [[2026, 5, 10], [2026, 5, 9, 19, 30], [17, 30], 90, True], 'accepted'], ['regression earlier-day notices 2', [[2020, 4, 26], [2020, 4, 25, 18, 0], [17, 0], 0, True], 'accepted'], ['partial repair probe 1', [[2026, 12, 31], [2026, 12, 29, 19, 1], [17, 30], 0, False], 'accepted'], ['partial repair probe 2', [[2024, 9, 27], [2024, 9, 25, 19, 0], [17, 30], 0, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2021, 6, 30], [2021, 6, 30, 17, 30], [17, 0], 0, False], 'late'], ['normal control 2', [[2027, 10, 1], [2027, 10, 1, 16, 59], [17, 0], 90, True], 'accepted'], ['normal control 3', [[2020, 1, 31], [2020, 1, 31, 19, 30], [17, 30], 90, True], 'late']], [['regression earlier-day notices 1', [[2021, 7, 12], [2021, 7, 11, 18, 0], [17, 0], 30, True], 'accepted'], ['regression earlier-day notices 2', [[2020, 4, 10], [2020, 4, 9, 18, 31], [17, 0], 30, False], 'accepted'], ['partial repair probe 1', [[2023, 7, 23], [2023, 7, 18, 18, 0], [17, 0], 0, False], 'accepted'], ['partial repair probe 2', [[2021, 3, 13], [2021, 3, 8, 19, 0], [17, 0], 90, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2025, 5, 6], [2025, 5, 1, 17, 29], [17, 30], 0, True], 'accepted'], ['normal control 2', [[2024, 9, 24], [2024, 9, 24, 7, 0], [17, 0], 0, True], 'accepted'], ['normal control 3', [[2024, 6, 27], [2024, 6, 26, 16, 29], [17, 0], 30, True], 'accepted']], [['regression earlier-day notices 1', [[2021, 2, 27], [2021, 2, 26, 17, 30], [16, 0], 90, False], 'accepted'], ['regression earlier-day notices 2', [[2026, 12, 25], [2026, 12, 24, 18, 0], [17, 30], 30, False], 'accepted'], ['partial repair probe 1', [[2023, 1, 30], [2023, 1, 25, 19, 0], [17, 30], 90, True], 'accepted'], ['partial repair probe 2', [[2028, 3, 27], [2028, 3, 22, 18, 0], [17, 0], 0, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2022, 7, 17], [2022, 7, 15, 16, 0], [17, 30], 90, False], 'accepted'], ['normal control 2', [[2030, 2, 28], [2030, 2, 28, 16, 1], [16, 0], 90, False], 'late'], ['normal control 3', [[2024, 3, 29], [2024, 3, 28, 16, 0], [16, 0], 0, False], 'accepted']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(expiry, submit, cutoff, extension, member):
    e = datetime.date(*expiry)
    y, m, d, hh, mm = submit
    sd = datetime.date(y, m, d)
    if sd > e:
        return 'expired'
    if sd < e and hh * 60 + mm <= cutoff[0] * 60 + cutoff[1]:
        return 'accepted'
    if sd < e:
        return 'late'
    limit = cutoff[0] * 60 + cutoff[1] + (extension if member else 0)
    return 'accepted' if hh * 60 + mm <= limit else 'late'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression earlier-day notices 1', [[2025, 10, 12], [2025, 10, 11, 19, 30], [17, 30], 30, False], 'accepted'], ['regression earlier-day notices 2', [[2022, 7, 29], [2022, 7, 28, 18, 30], [17, 30], 0, False], 'accepted'], ['partial repair probe 1', [[2020, 3, 27], [2020, 3, 25, 16, 30], [16, 0], 0, False], 'accepted'], ['partial repair probe 2', [[2020, 6, 27], [2020, 6, 25, 18, 31], [17, 0], 30, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2023, 11, 14], [2023, 11, 14, 18, 30], [17, 0], 90, False], 'late'], ['normal control 2', [[2029, 7, 24], [2029, 7, 22, 14, 30], [16, 0], 30, False], 'accepted'], ['normal control 3', [[2029, 2, 28], [2029, 2, 23, 15, 29], [16, 0], 90, True], 'accepted']], [['regression earlier-day notices 1', [[2027, 2, 25], [2027, 2, 24, 19, 0], [17, 30], 0, False], 'accepted'], ['regression earlier-day notices 2', [[2021, 2, 28], [2021, 2, 27, 18, 31], [17, 0], 0, True], 'accepted'], ['partial repair probe 1', [[2024, 7, 30], [2024, 7, 25, 18, 0], [17, 30], 30, True], 'accepted'], ['partial repair probe 2', [[2023, 7, 31], [2023, 7, 26, 19, 30], [17, 30], 90, True], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2023, 5, 6], [2023, 5, 6, 18, 0], [17, 30], 90, True], 'accepted'], ['normal control 2', [[2024, 4, 30], [2024, 5, 1, 16, 0], [16, 0], 0, False], 'expired'], ['normal control 3', [[2022, 12, 31], [2022, 12, 31, 18, 0], [17, 0], 0, False], 'late']], [['regression earlier-day notices 1', [[2026, 5, 10], [2026, 5, 9, 19, 30], [17, 30], 90, True], 'accepted'], ['regression earlier-day notices 2', [[2020, 4, 26], [2020, 4, 25, 18, 0], [17, 0], 0, True], 'accepted'], ['partial repair probe 1', [[2026, 12, 31], [2026, 12, 29, 19, 1], [17, 30], 0, False], 'accepted'], ['partial repair probe 2', [[2024, 9, 27], [2024, 9, 25, 19, 0], [17, 30], 0, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2021, 6, 30], [2021, 6, 30, 17, 30], [17, 0], 0, False], 'late'], ['normal control 2', [[2027, 10, 1], [2027, 10, 1, 16, 59], [17, 0], 90, True], 'accepted'], ['normal control 3', [[2020, 1, 31], [2020, 1, 31, 19, 30], [17, 30], 90, True], 'late']], [['regression earlier-day notices 1', [[2021, 7, 12], [2021, 7, 11, 18, 0], [17, 0], 30, True], 'accepted'], ['regression earlier-day notices 2', [[2020, 4, 10], [2020, 4, 9, 18, 31], [17, 0], 30, False], 'accepted'], ['partial repair probe 1', [[2023, 7, 23], [2023, 7, 18, 18, 0], [17, 0], 0, False], 'accepted'], ['partial repair probe 2', [[2021, 3, 13], [2021, 3, 8, 19, 0], [17, 0], 90, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2025, 5, 6], [2025, 5, 1, 17, 29], [17, 30], 0, True], 'accepted'], ['normal control 2', [[2024, 9, 24], [2024, 9, 24, 7, 0], [17, 0], 0, True], 'accepted'], ['normal control 3', [[2024, 6, 27], [2024, 6, 26, 16, 29], [17, 0], 30, True], 'accepted']], [['regression earlier-day notices 1', [[2021, 2, 27], [2021, 2, 26, 17, 30], [16, 0], 90, False], 'accepted'], ['regression earlier-day notices 2', [[2026, 12, 25], [2026, 12, 24, 18, 0], [17, 30], 30, False], 'accepted'], ['partial repair probe 1', [[2023, 1, 30], [2023, 1, 25, 19, 0], [17, 30], 90, True], 'accepted'], ['partial repair probe 2', [[2028, 3, 27], [2028, 3, 22, 18, 0], [17, 0], 0, False], 'accepted'], ['boundary control 1', [[2024, 6, 21], [2024, 6, 21, 17, 30], [17, 30], 0, False], 'accepted'], ['normal control 1', [[2022, 7, 17], [2022, 7, 15, 16, 0], [17, 30], 90, False], 'accepted'], ['normal control 2', [[2030, 2, 28], [2030, 2, 28, 16, 1], [16, 0], 90, False], 'late'], ['normal control 3', [[2024, 3, 29], [2024, 3, 28, 16, 0], [16, 0], 0, False], 'accepted']]]
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:
Early exercise notices filed the evening before expiry are rejected.

Inputs expiry date, submission [y,m,d,hh,mm], cutoff [hh,mm], extension minutes and member flag. Notices after the expiry date are "expired"; notices on earlier dates are "accepted"; on the expiry date a notice is accepted if its minute of day <= cutoff (+extension for members), else "late".

split: open-access


prompt:
Parity checks flag every fairly priced pair when rates are positive.

Inputs call price C, put price P, S, K, r, T, dividend yield q and tolerance. v = (C - P) - (S e^{-qT} - K e^{-rT}). If |v| <= tol return ["none", 0.0]; if v > 0 return ["sell call buy put", v]; else ["buy call sell put", -v], amounts rounded to 6.

split: open-access


prompt:
Rich calls are reported as a buy-call trade.

Inputs call price C, put price P, S, K, r, T, dividend yield q and tolerance. v = (C - P) - (S e^{-qT} - K e^{-rT}). If |v| <= tol return ["none", 0.0]; if v > 0 return ["sell call buy put", v]; else ["buy call sell put", -v], amounts rounded to 6.

split: open-access


prompt:
Pairs on dividend-paying underlyings are flagged as violations.

Inputs call price C, put price P, S, K, r, T, dividend yield q and tolerance. v = (C - P) - (S e^{-qT} - K e^{-rT}). If |v| <= tol return ["none", 0.0]; if v > 0 return ["sell call buy put", v]; else ["buy call sell put", -v], amounts rounded to 6.

split: open-access


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

N = 1
observations = []
def solve(price, side, penny):
    m = round(price * 1000)
    small = m < 300
    tick = (10 if penny else 50) if small else (50 if penny else 100)
    if side == 'buy':
        out = m // tick * tick
    else:
        out = -(-m // tick) * tick
    return out / 1000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression tick threshold units 1', [0.549, 'buy', True], 0.54], ['regression tick threshold units 2', [1.242, 'buy', True], 1.24], ['partial repair probe 1', [3.075, 'buy', True], 3.05], ['partial repair probe 2', [4.125, 'sell', True], 4.15], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [2.995, 'sell', False], 3.0], ['normal control 2', [3.002, 'buy', True], 3.0], ['normal control 3', [1.255, 'sell', False], 1.3]], [['regression tick threshold units 1', [1.28, 'buy', True], 1.28], ['regression tick threshold units 2', [1.242, 'buy', True], 1.24], ['partial repair probe 1', [3.14, 'sell', True], 3.15], ['partial repair probe 2', [4.149, 'sell', False], 4.2], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [12.389, 'sell', False], 12.4], ['normal control 2', [3.05, 'sell', True], 3.05], ['normal control 3', [0.549, 'sell', True], 0.55]], [['regression tick threshold units 1', [2.99, 'sell', True], 2.99], ['regression tick threshold units 2', [1.28, 'buy', True], 1.28], ['partial repair probe 1', [3.002, 'sell', True], 3.05], ['partial repair probe 2', [3.039, 'sell', True], 3.05], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [3.049, 'sell', True], 3.05], ['normal control 2', [3.0, 'sell', True], 3.0], ['normal control 3', [1.242, 'sell', True], 1.25]], [['regression tick threshold units 1', [1.231, 'sell', True], 1.24], ['regression tick threshold units 2', [2.954, 'buy', False], 2.95], ['partial repair probe 1', [12.39, 'sell', True], 12.4], ['partial repair probe 2', [12.37, 'buy', False], 12.3], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [0.549, 'sell', True], 0.55], ['normal control 2', [3.1, 'sell', False], 3.1], ['normal control 3', [3.1, 'sell', True], 3.1]], [['regression tick threshold units 1', [0.504, 'sell', False], 0.55], ['regression tick threshold units 2', [2.995, 'buy', True], 2.99], ['partial repair probe 1', [3.082, 'buy', True], 3.05], ['partial repair probe 2', [4.17, 'sell', True], 4.2], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [4.104, 'buy', False], 4.1], ['normal control 2', [1.255, 'buy', True], 1.25], ['normal control 3', [3.12, 'buy', False], 3.1]]]
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(price, side, penny):
    m = round(price * 1000)
    small = m < 30000
    tick = (10 if penny else 50) if small else (50 if penny else 100)
    if side == 'buy':
        out = m // tick * tick
    else:
        out = -(-m // tick) * tick
    return out / 1000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression tick threshold units 1', [0.549, 'buy', True], 0.54], ['regression tick threshold units 2', [1.242, 'buy', True], 1.24], ['partial repair probe 1', [3.075, 'buy', True], 3.05], ['partial repair probe 2', [4.125, 'sell', True], 4.15], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [2.995, 'sell', False], 3.0], ['normal control 2', [3.002, 'buy', True], 3.0], ['normal control 3', [1.255, 'sell', False], 1.3]], [['regression tick threshold units 1', [1.28, 'buy', True], 1.28], ['regression tick threshold units 2', [1.242, 'buy', True], 1.24], ['partial repair probe 1', [3.14, 'sell', True], 3.15], ['partial repair probe 2', [4.149, 'sell', False], 4.2], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [12.389, 'sell', False], 12.4], ['normal control 2', [3.05, 'sell', True], 3.05], ['normal control 3', [0.549, 'sell', True], 0.55]], [['regression tick threshold units 1', [2.99, 'sell', True], 2.99], ['regression tick threshold units 2', [1.28, 'buy', True], 1.28], ['partial repair probe 1', [3.002, 'sell', True], 3.05], ['partial repair probe 2', [3.039, 'sell', True], 3.05], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [3.049, 'sell', True], 3.05], ['normal control 2', [3.0, 'sell', True], 3.0], ['normal control 3', [1.242, 'sell', True], 1.25]], [['regression tick threshold units 1', [1.231, 'sell', True], 1.24], ['regression tick threshold units 2', [2.954, 'buy', False], 2.95], ['partial repair probe 1', [12.39, 'sell', True], 12.4], ['partial repair probe 2', [12.37, 'buy', False], 12.3], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [0.549, 'sell', True], 0.55], ['normal control 2', [3.1, 'sell', False], 3.1], ['normal control 3', [3.1, 'sell', True], 3.1]], [['regression tick threshold units 1', [0.504, 'sell', False], 0.55], ['regression tick threshold units 2', [2.995, 'buy', True], 2.99], ['partial repair probe 1', [3.082, 'buy', True], 3.05], ['partial repair probe 2', [4.17, 'sell', True], 4.2], ['boundary control 1', [3.0, 'buy', False], 3.0], ['normal control 1', [4.104, 'buy', False], 4.1], ['normal control 2', [1.255, 'buy', True], 1.25], ['normal control 3', [3.12, 'buy', False], 3.1]]]
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:
Almost every order is priced on the large tick.

Inputs a limit price (up to 3 decimals), side and penny-program flag. Work in mills. Below 3.000 the tick is 0.01 for penny classes and 0.05 otherwise; at or above 3.000 it is 0.05 for penny classes and 0.10 otherwise. Buy orders round down to a tick, sell orders round up; prices already on a tick are unchanged. Return the price as a float.

split: open-access


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

N = 1
observations = []
def solve(price, side, penny):
    m = round(price * 1000)
    small = m < 3000
    tick = (10 if penny else 50) if small else (50 if penny else 100)
    if side == 'buy':
        out = -(-m // tick) * tick
    else:
        out = m // tick * tick
    return out / 1000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression side rounding direction 1', [12.344, 'sell', True], 12.35], ['regression side rounding direction 2', [4.105, 'buy', True], 4.1], ['partial repair probe 1', [0.53, 'buy', False], 0.5], ['partial repair probe 2', [0.512, 'sell', True], 0.52], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [0.55, 'buy', False], 0.55], ['normal control 2', [3.1, 'sell', False], 3.1]], [['regression side rounding direction 1', [3.06, 'buy', False], 3.0], ['regression side rounding direction 2', [12.345, 'buy', False], 12.3], ['partial repair probe 1', [2.975, 'buy', False], 2.95], ['partial repair probe 2', [2.951, 'sell', False], 3.0], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [3.1, 'sell', False], 3.1], ['normal control 2', [4.1, 'sell', True], 4.1]], [['regression side rounding direction 1', [3.015, 'buy', True], 3.0], ['regression side rounding direction 2', [3.095, 'buy', True], 3.05], ['partial repair probe 1', [4.112, 'sell', True], 4.15], ['partial repair probe 2', [2.999, 'buy', True], 2.99], ['boundary control 1', [2.95, 'sell', False], 2.95], ['boundary control 2', [3.0, 'buy', False], 3.0], ['normal control 1', [0.5, 'buy', True], 0.5], ['normal control 2', [1.26, 'buy', True], 1.26]], [['regression side rounding direction 1', [3.074, 'sell', False], 3.1], ['regression side rounding direction 2', [3.012, 'sell', True], 3.05], ['partial repair probe 1', [12.341, 'sell', False], 12.4], ['partial repair probe 2', [0.501, 'sell', False], 0.55], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [2.95, 'sell', True], 2.95], ['normal control 2', [3.1, 'buy', True], 3.1]], [['regression side rounding direction 1', [3.04, 'sell', False], 3.1], ['regression side rounding direction 2', [3.015, 'buy', False], 3.0], ['partial repair probe 1', [3.075, 'buy', True], 3.05], ['partial repair probe 2', [3.14, 'sell', False], 3.2], ['boundary control 1', [2.95, 'sell', False], 2.95], ['boundary control 2', [3.0, 'buy', False], 3.0], ['normal control 1', [3.1, 'sell', False], 3.1], ['normal control 2', [0.5, 'buy', True], 0.5]]]
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(price, side, penny):
    m = round(price * 1000)
    small = m < 3000
    tick = (10 if penny else 50) if small else (50 if penny else 100)
    out = (m + tick // 2) // tick * tick
    return out / 1000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression side rounding direction 1', [12.344, 'sell', True], 12.35], ['regression side rounding direction 2', [4.105, 'buy', True], 4.1], ['partial repair probe 1', [0.53, 'buy', False], 0.5], ['partial repair probe 2', [0.512, 'sell', True], 0.52], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [0.55, 'buy', False], 0.55], ['normal control 2', [3.1, 'sell', False], 3.1]], [['regression side rounding direction 1', [3.06, 'buy', False], 3.0], ['regression side rounding direction 2', [12.345, 'buy', False], 12.3], ['partial repair probe 1', [2.975, 'buy', False], 2.95], ['partial repair probe 2', [2.951, 'sell', False], 3.0], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [3.1, 'sell', False], 3.1], ['normal control 2', [4.1, 'sell', True], 4.1]], [['regression side rounding direction 1', [3.015, 'buy', True], 3.0], ['regression side rounding direction 2', [3.095, 'buy', True], 3.05], ['partial repair probe 1', [4.112, 'sell', True], 4.15], ['partial repair probe 2', [2.999, 'buy', True], 2.99], ['boundary control 1', [2.95, 'sell', False], 2.95], ['boundary control 2', [3.0, 'buy', False], 3.0], ['normal control 1', [0.5, 'buy', True], 0.5], ['normal control 2', [1.26, 'buy', True], 1.26]], [['regression side rounding direction 1', [3.074, 'sell', False], 3.1], ['regression side rounding direction 2', [3.012, 'sell', True], 3.05], ['partial repair probe 1', [12.341, 'sell', False], 12.4], ['partial repair probe 2', [0.501, 'sell', False], 0.55], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [2.95, 'sell', True], 2.95], ['normal control 2', [3.1, 'buy', True], 3.1]], [['regression side rounding direction 1', [3.04, 'sell', False], 3.1], ['regression side rounding direction 2', [3.015, 'buy', False], 3.0], ['partial repair probe 1', [3.075, 'buy', True], 3.05], ['partial repair probe 2', [3.14, 'sell', False], 3.2], ['boundary control 1', [2.95, 'sell', False], 2.95], ['boundary control 2', [3.0, 'buy', False], 3.0], ['normal control 1', [3.1, 'sell', False], 3.1], ['normal control 2', [0.5, 'buy', True], 0.5]]]
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:
Orders become more aggressive than the trader's limit.

Inputs a limit price (up to 3 decimals), side and penny-program flag. Work in mills. Below 3.000 the tick is 0.01 for penny classes and 0.05 otherwise; at or above 3.000 it is 0.05 for penny classes and 0.10 otherwise. Buy orders round down to a tick, sell orders round up; prices already on a tick are unchanged. Return the price as a float.

split: open-access


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

N = 1
observations = []
def solve(price, side, penny):
    m = round(price * 1000)
    small = m < 3000
    tick = (10 if penny else 50) if small else (10 if penny else 100)
    if side == 'buy':
        out = m // tick * tick
    else:
        out = -(-m // tick) * tick
    return out / 1000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression penny tick above threshold 1', [3.075, 'sell', True], 3.1], ['regression penny tick above threshold 2', [3.03, 'sell', True], 3.05], ['partial repair probe 1', [12.344, 'sell', True], 12.35], ['partial repair probe 2', [3.049, 'sell', True], 3.05], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [12.34, 'sell', False], 12.4], ['normal control 2', [3.074, 'sell', False], 3.1]], [['regression penny tick above threshold 1', [3.082, 'buy', True], 3.05], ['regression penny tick above threshold 2', [3.004, 'sell', True], 3.05], ['partial repair probe 1', [3.049, 'sell', True], 3.05], ['partial repair probe 2', [12.345, 'sell', True], 12.35], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [1.26, 'sell', False], 1.3], ['normal control 2', [2.962, 'buy', False], 2.95]], [['regression penny tick above threshold 1', [3.001, 'sell', True], 3.05], ['regression penny tick above threshold 2', [3.012, 'buy', True], 3.0], ['partial repair probe 1', [4.15, 'sell', True], 4.15], ['partial repair probe 2', [3.05, 'buy', True], 3.05], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [12.389, 'sell', False], 12.4], ['normal control 2', [4.104, 'sell', False], 4.2]], [['regression penny tick above threshold 1', [12.41, 'buy', True], 12.4], ['regression penny tick above threshold 2', [3.02, 'buy', True], 3.0], ['partial repair probe 1', [3.05, 'sell', True], 3.05], ['partial repair probe 2', [4.15, 'buy', True], 4.15], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [12.389, 'sell', False], 12.4], ['normal control 2', [4.104, 'buy', False], 4.1]], [['regression penny tick above threshold 1', [12.344, 'buy', True], 12.3], ['regression penny tick above threshold 2', [3.039, 'buy', True], 3.0], ['partial repair probe 1', [12.352, 'buy', True], 12.35], ['partial repair probe 2', [4.15, 'sell', True], 4.15], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [3.075, 'buy', False], 3.0], ['normal control 2', [3.004, 'buy', True], 3.0]]]
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(price, side, penny):
    m = round(price * 1000)
    small = m < 3000
    tick = (10 if penny else 50) if small else 100
    if side == 'buy':
        out = m // tick * tick
    else:
        out = -(-m // tick) * tick
    return out / 1000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression penny tick above threshold 1', [3.075, 'sell', True], 3.1], ['regression penny tick above threshold 2', [3.03, 'sell', True], 3.05], ['partial repair probe 1', [12.344, 'sell', True], 12.35], ['partial repair probe 2', [3.049, 'sell', True], 3.05], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [12.34, 'sell', False], 12.4], ['normal control 2', [3.074, 'sell', False], 3.1]], [['regression penny tick above threshold 1', [3.082, 'buy', True], 3.05], ['regression penny tick above threshold 2', [3.004, 'sell', True], 3.05], ['partial repair probe 1', [3.049, 'sell', True], 3.05], ['partial repair probe 2', [12.345, 'sell', True], 12.35], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [1.26, 'sell', False], 1.3], ['normal control 2', [2.962, 'buy', False], 2.95]], [['regression penny tick above threshold 1', [3.001, 'sell', True], 3.05], ['regression penny tick above threshold 2', [3.012, 'buy', True], 3.0], ['partial repair probe 1', [4.15, 'sell', True], 4.15], ['partial repair probe 2', [3.05, 'buy', True], 3.05], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [12.389, 'sell', False], 12.4], ['normal control 2', [4.104, 'sell', False], 4.2]], [['regression penny tick above threshold 1', [12.41, 'buy', True], 12.4], ['regression penny tick above threshold 2', [3.02, 'buy', True], 3.0], ['partial repair probe 1', [3.05, 'sell', True], 3.05], ['partial repair probe 2', [4.15, 'buy', True], 4.15], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [12.389, 'sell', False], 12.4], ['normal control 2', [4.104, 'buy', False], 4.1]], [['regression penny tick above threshold 1', [12.344, 'buy', True], 12.3], ['regression penny tick above threshold 2', [3.039, 'buy', True], 3.0], ['partial repair probe 1', [12.352, 'buy', True], 12.35], ['partial repair probe 2', [4.15, 'sell', True], 4.15], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [2.95, 'sell', False], 2.95], ['normal control 1', [3.075, 'buy', False], 3.0], ['normal control 2', [3.004, 'buy', True], 3.0]]]
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:
Penny-class orders above 3.00 are priced in cents.

Inputs a limit price (up to 3 decimals), side and penny-program flag. Work in mills. Below 3.000 the tick is 0.01 for penny classes and 0.05 otherwise; at or above 3.000 it is 0.05 for penny classes and 0.10 otherwise. Buy orders round down to a tick, sell orders round up; prices already on a tick are unchanged. Return the price as a float.

split: open-access


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

N = 1
observations = []
def solve(price, side, penny):
    m = round(price * 1000)
    small = m < 3000
    tick = (10 if penny else 50) if small else (50 if penny else 100)
    if side == 'buy':
        out = m // tick * tick
    else:
        out = (m // tick + 1) * tick
    return out / 1000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression on-tick sell prices 1', [0.53, 'sell', True], 0.53], ['regression on-tick sell prices 2', [3.0, 'sell', True], 3.0], ['partial repair probe 1', [2.95, 'sell', False], 2.95], ['partial repair probe 2', [3.05, 'sell', True], 3.05], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [3.001, 'sell', True], 3.05], ['normal control 1', [3.12, 'buy', True], 3.1], ['normal control 2', [2.951, 'buy', False], 2.95]], [['regression on-tick sell prices 1', [3.0, 'sell', True], 3.0], ['regression on-tick sell prices 2', [2.95, 'sell', True], 2.95], ['partial repair probe 1', [4.15, 'sell', True], 4.15], ['partial repair probe 2', [0.55, 'sell', False], 0.55], ['boundary control 1', [3.001, 'sell', True], 3.05], ['boundary control 2', [3.0, 'buy', False], 3.0], ['normal control 1', [4.13, 'sell', True], 4.15], ['normal control 2', [1.242, 'sell', False], 1.25]], [['regression on-tick sell prices 1', [2.95, 'sell', False], 2.95], ['regression on-tick sell prices 2', [0.55, 'sell', False], 0.55], ['partial repair probe 1', [0.53, 'sell', True], 0.53], ['partial repair probe 2', [0.55, 'sell', True], 0.55], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [3.001, 'sell', True], 3.05], ['normal control 1', [3.07, 'sell', True], 3.1], ['normal control 2', [12.365, 'buy', False], 12.3]], [['regression on-tick sell prices 1', [2.99, 'sell', True], 2.99], ['regression on-tick sell prices 2', [3.0, 'sell', True], 3.0], ['partial repair probe 1', [0.55, 'sell', True], 0.55], ['partial repair probe 2', [4.15, 'sell', True], 4.15], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [3.001, 'sell', True], 3.05], ['normal control 1', [4.17, 'sell', False], 4.2], ['normal control 2', [3.071, 'sell', False], 3.1]], [['regression on-tick sell prices 1', [2.95, 'sell', True], 2.95], ['regression on-tick sell prices 2', [0.55, 'sell', True], 0.55], ['partial repair probe 1', [2.95, 'sell', False], 2.95], ['partial repair probe 2', [4.1, 'sell', False], 4.1], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [3.001, 'sell', True], 3.05], ['normal control 1', [3.005, 'buy', True], 3.0], ['normal control 2', [1.279, 'buy', False], 1.25]]]
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(price, side, penny):
    m = round(price * 1000)
    small = m < 3000
    tick = (10 if penny else 50) if small else (50 if penny else 100)
    if side == 'buy':
        out = m // tick * tick
    else:
        out = round(m / tick + 0.5) * tick
    return out / 1000
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression on-tick sell prices 1', [0.53, 'sell', True], 0.53], ['regression on-tick sell prices 2', [3.0, 'sell', True], 3.0], ['partial repair probe 1', [2.95, 'sell', False], 2.95], ['partial repair probe 2', [3.05, 'sell', True], 3.05], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [3.001, 'sell', True], 3.05], ['normal control 1', [3.12, 'buy', True], 3.1], ['normal control 2', [2.951, 'buy', False], 2.95]], [['regression on-tick sell prices 1', [3.0, 'sell', True], 3.0], ['regression on-tick sell prices 2', [2.95, 'sell', True], 2.95], ['partial repair probe 1', [4.15, 'sell', True], 4.15], ['partial repair probe 2', [0.55, 'sell', False], 0.55], ['boundary control 1', [3.001, 'sell', True], 3.05], ['boundary control 2', [3.0, 'buy', False], 3.0], ['normal control 1', [4.13, 'sell', True], 4.15], ['normal control 2', [1.242, 'sell', False], 1.25]], [['regression on-tick sell prices 1', [2.95, 'sell', False], 2.95], ['regression on-tick sell prices 2', [0.55, 'sell', False], 0.55], ['partial repair probe 1', [0.53, 'sell', True], 0.53], ['partial repair probe 2', [0.55, 'sell', True], 0.55], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [3.001, 'sell', True], 3.05], ['normal control 1', [3.07, 'sell', True], 3.1], ['normal control 2', [12.365, 'buy', False], 12.3]], [['regression on-tick sell prices 1', [2.99, 'sell', True], 2.99], ['regression on-tick sell prices 2', [3.0, 'sell', True], 3.0], ['partial repair probe 1', [0.55, 'sell', True], 0.55], ['partial repair probe 2', [4.15, 'sell', True], 4.15], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [3.001, 'sell', True], 3.05], ['normal control 1', [4.17, 'sell', False], 4.2], ['normal control 2', [3.071, 'sell', False], 3.1]], [['regression on-tick sell prices 1', [2.95, 'sell', True], 2.95], ['regression on-tick sell prices 2', [0.55, 'sell', True], 0.55], ['partial repair probe 1', [2.95, 'sell', False], 2.95], ['partial repair probe 2', [4.1, 'sell', False], 4.1], ['boundary control 1', [3.0, 'buy', False], 3.0], ['boundary control 2', [3.001, 'sell', True], 3.05], ['normal control 1', [3.005, 'buy', True], 3.0], ['normal control 2', [1.279, 'buy', False], 1.25]]]
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:
Valid sell limits are moved one tick higher.

Inputs a limit price (up to 3 decimals), side and penny-program flag. Work in mills. Below 3.000 the tick is 0.01 for penny classes and 0.05 otherwise; at or above 3.000 it is 0.05 for penny classes and 0.10 otherwise. Buy orders round down to a tick, sell orders round up; prices already on a tick are unchanged. Return the price as a float.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy.strip().upper()
    if code not in exps: return 'ERR:unknown-currency'
    e = exps[code]
    x = Decimal(amount)
    q = x.quantize(Decimal('0.01'), rounding=ROUND_HALF_EVEN)
    if q == 0: q = abs(q)
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression quantum-per-currency 1', ('1235.5', 'JPY'), '1236'),
  ('regression quantum-per-currency 2', ('10.0005', 'KWD'), '10.000'),
  ('partial repair guard 2', ('1.23456', 'CLF'), '1.2346'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00'),
  ('control: integer input', ('7', 'BHD'), '7.000')],
 [('regression quantum-per-currency 1', ('1.23456', 'CLF'), '1.2346'),
  ('regression quantum-per-currency 2', ('7', 'BHD'), '7.000'),
  ('partial repair guard 2', ('37643.905', 'CLF'), '37643.9050'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12')],
 [('regression quantum-per-currency 1', ('-2.5', 'KRW'), '-2'),
  ('regression quantum-per-currency 2', ('39257.444', 'KRW'), '39257'),
  ('partial repair guard 1', ('45179.821', 'CLF'), '45179.8210'),
  ('partial repair guard 2', ('10645.65286', 'Kwd '), '10645.653'), ('control: integer input', ('7', 'BHD'), '7.000'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66')],
 [('regression quantum-per-currency 1', ('47295.38', ' jpy'), '47295'),
  ('regression quantum-per-currency 2', ('37643.905', 'CLF'), '37643.9050'),
  ('partial repair guard 1', ('-2451.34', 'KWD'), '-2451.340'),
  ('partial repair guard 2', ('19100.06047', 'BHD'), '19100.060'), ('control: negative tie', ('-2.5', 'KRW'), '-2'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression quantum-per-currency 1', ('45179.821', 'CLF'), '45179.8210'),
  ('regression quantum-per-currency 2', ('4677.317', 'JPY'), '4677'),
  ('partial repair guard 1', ('16193.1040', 'Kwd '), '16193.104'),
  ('partial repair guard 2', ('32233.55636', 'Kwd '), '32233.556'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]
for label, args, expected in cases[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
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy.strip().upper()
    if code not in exps: return 'ERR:unknown-currency'
    e = exps[code]
    x = Decimal(amount)
    q = x.quantize(Decimal(1).scaleb(-min(e, 2)), rounding=ROUND_HALF_EVEN)
    if q == 0: q = abs(q)
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression quantum-per-currency 1', ('1235.5', 'JPY'), '1236'),
  ('regression quantum-per-currency 2', ('10.0005', 'KWD'), '10.000'),
  ('partial repair guard 2', ('1.23456', 'CLF'), '1.2346'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00'),
  ('control: integer input', ('7', 'BHD'), '7.000')],
 [('regression quantum-per-currency 1', ('1.23456', 'CLF'), '1.2346'),
  ('regression quantum-per-currency 2', ('7', 'BHD'), '7.000'),
  ('partial repair guard 2', ('37643.905', 'CLF'), '37643.9050'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12')],
 [('regression quantum-per-currency 1', ('-2.5', 'KRW'), '-2'),
  ('regression quantum-per-currency 2', ('39257.444', 'KRW'), '39257'),
  ('partial repair guard 1', ('45179.821', 'CLF'), '45179.8210'),
  ('partial repair guard 2', ('10645.65286', 'Kwd '), '10645.653'), ('control: integer input', ('7', 'BHD'), '7.000'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66')],
 [('regression quantum-per-currency 1', ('47295.38', ' jpy'), '47295'),
  ('regression quantum-per-currency 2', ('37643.905', 'CLF'), '37643.9050'),
  ('partial repair guard 1', ('-2451.34', 'KWD'), '-2451.340'),
  ('partial repair guard 2', ('19100.06047', 'BHD'), '19100.060'), ('control: negative tie', ('-2.5', 'KRW'), '-2'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression quantum-per-currency 1', ('45179.821', 'CLF'), '45179.8210'),
  ('regression quantum-per-currency 2', ('4677.317', 'JPY'), '4677'),
  ('partial repair guard 1', ('16193.1040', 'Kwd '), '16193.104'),
  ('partial repair guard 2', ('32233.55636', 'Kwd '), '32233.556'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]
for label, args, expected in cases[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:
Yen amounts gain two fraction digits and dinar amounts lose their third minor digit.

solve(amount, ccy): amount is an exact decimal string, ccy an ISO-like code that is trimmed and upper-cased. Minor-unit exponents: USD 2, EUR 2, JPY 0, KRW 0, KWD 3, BHD 3, CLF 4. Round the exact decimal half-even at the currency exponent and return a plain string with exactly that many fraction digits; a zero result is unsigned. Unknown codes return 'ERR:unknown-currency'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy
    if code not in exps: return 'ERR:unknown-currency'
    e = exps[code]
    x = Decimal(amount)
    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)
    if q == 0: q = abs(q)
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression code-normalization 1', ('1.005', ' usd'), '1.00'),
  ('regression code-normalization 2', ('3', 'Jpy '), '3'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],
 [('regression code-normalization 1', ('12.345', ' eur '), '12.34'),
  ('regression code-normalization 2', ('-2562.29293', 'usd'), '-2562.29'),
  ('partial repair guard 2', ('47295.38', ' jpy'), '47295'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: negative small', ('-0.004', 'USD'), '0.00'), ('control: integer input', ('7', 'BHD'), '7.000'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency')],
 [('regression code-normalization 1', ('47295.38', ' jpy'), '47295'),
  ('regression code-normalization 2', ('35094.719', 'usd'), '35094.72'),
  ('partial repair guard 1', ('10645.65286', 'Kwd '), '10645.653'),
  ('partial repair guard 2', ('1600.045697', ' jpy'), '1600'), ('control: integer input', ('7', 'BHD'), '7.000'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2')],
 [('regression code-normalization 1', ('10645.65286', 'Kwd '), '10645.653'),
  ('regression code-normalization 2', ('1600.045697', ' jpy'), '1600'),
  ('partial repair guard 1', ('16193.1040', 'Kwd '), '16193.104'),
  ('partial repair guard 2', ('32233.55636', 'Kwd '), '32233.556'), ('control: negative tie', ('-2.5', 'KRW'), '-2'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression code-normalization 1', ('16193.1040', 'Kwd '), '16193.104'),
  ('regression code-normalization 2', ('32233.55636', 'Kwd '), '32233.556'),
  ('partial repair guard 1', ('5555.23', ' jpy'), '5555'), ('partial repair guard 2', ('4726.8350', ' jpy'), '4727'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]
for label, args, expected in cases[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
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy.upper()
    if code not in exps: return 'ERR:unknown-currency'
    e = exps[code]
    x = Decimal(amount)
    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)
    if q == 0: q = abs(q)
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression code-normalization 1', ('1.005', ' usd'), '1.00'),
  ('regression code-normalization 2', ('3', 'Jpy '), '3'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],
 [('regression code-normalization 1', ('12.345', ' eur '), '12.34'),
  ('regression code-normalization 2', ('-2562.29293', 'usd'), '-2562.29'),
  ('partial repair guard 2', ('47295.38', ' jpy'), '47295'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: negative small', ('-0.004', 'USD'), '0.00'), ('control: integer input', ('7', 'BHD'), '7.000'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency')],
 [('regression code-normalization 1', ('47295.38', ' jpy'), '47295'),
  ('regression code-normalization 2', ('35094.719', 'usd'), '35094.72'),
  ('partial repair guard 1', ('10645.65286', 'Kwd '), '10645.653'),
  ('partial repair guard 2', ('1600.045697', ' jpy'), '1600'), ('control: integer input', ('7', 'BHD'), '7.000'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2')],
 [('regression code-normalization 1', ('10645.65286', 'Kwd '), '10645.653'),
  ('regression code-normalization 2', ('1600.045697', ' jpy'), '1600'),
  ('partial repair guard 1', ('16193.1040', 'Kwd '), '16193.104'),
  ('partial repair guard 2', ('32233.55636', 'Kwd '), '32233.556'), ('control: negative tie', ('-2.5', 'KRW'), '-2'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression code-normalization 1', ('16193.1040', 'Kwd '), '16193.104'),
  ('regression code-normalization 2', ('32233.55636', 'Kwd '), '32233.556'),
  ('partial repair guard 1', ('5555.23', ' jpy'), '5555'), ('partial repair guard 2', ('4726.8350', ' jpy'), '4727'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]
for label, args, expected in cases[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:
Valid amounts tagged ' usd' are rejected as unknown currencies.

solve(amount, ccy): amount is an exact decimal string, ccy an ISO-like code that is trimmed and upper-cased. Minor-unit exponents: USD 2, EUR 2, JPY 0, KRW 0, KWD 3, BHD 3, CLF 4. Round the exact decimal half-even at the currency exponent and return a plain string with exactly that many fraction digits; a zero result is unsigned. Unknown codes return 'ERR:unknown-currency'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy.strip().upper()
    if code not in exps: return 'ERR:unknown-currency'
    e = exps[code]
    x = Decimal(amount)
    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)
    q = q
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],
 [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: integer input', ('7', 'BHD'), '7.000'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency')],
 [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: integer input', ('7', 'BHD'), '7.000'), ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2')],
 [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: integer input', ('7', 'BHD'), '7.000')]]
for label, args, expected in cases[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
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy.strip().upper()
    if code not in exps: return 'ERR:unknown-currency'
    e = exps[code]
    x = Decimal(amount)
    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)
    if q == 0 and q.is_signed(): q = Decimal(0)
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],
 [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: integer input', ('7', 'BHD'), '7.000'),
  ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency')],
 [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: integer input', ('7', 'BHD'), '7.000'), ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2')],
 [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression signed-zero 1', ('-0.004', 'USD'), '0.00'), ('regression signed-zero 2', ('-0.4', 'JPY'), '0'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: integer input', ('7', 'BHD'), '7.000')]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A refund of -0.004 USD is rendered as '-0.00'.

solve(amount, ccy): amount is an exact decimal string, ccy an ISO-like code that is trimmed and upper-cased. Minor-unit exponents: USD 2, EUR 2, JPY 0, KRW 0, KWD 3, BHD 3, CLF 4. Round the exact decimal half-even at the currency exponent and return a plain string with exactly that many fraction digits; a zero result is unsigned. Unknown codes return 'ERR:unknown-currency'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy.strip().upper()
    e = exps.get(code, 2)
    x = Decimal(amount)
    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)
    if q == 0: q = abs(q)
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression unknown-currency 1', ('1.005', 'GBX'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('1.0', 'ABCD'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],
 [('regression unknown-currency 1', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('15200.78697', 'GBX'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('47176.41', 'GBX'), 'ERR:unknown-currency'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00'),
  ('control: integer input', ('7', 'BHD'), '7.000')],
 [('regression unknown-currency 1', ('47176.41', 'GBX'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('24558.1895', 'GBX'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('20428.404', 'GBX'), 'ERR:unknown-currency'),
  ('control: integer input', ('7', 'BHD'), '7.000'), ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2')],
 [('regression unknown-currency 1', ('20428.404', 'GBX'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('11999.89380', 'GBX'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('44143.650', 'GBX'), 'ERR:unknown-currency'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression unknown-currency 1', ('44143.650', 'GBX'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('34654.813830', 'GBX'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('17622.45', 'GBX'), 'ERR:unknown-currency'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]
for label, args, expected in cases[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
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy.strip().upper()
    if code not in exps and len(code) != 3: return 'ERR:unknown-currency'
    e = exps.get(code, 2)
    x = Decimal(amount)
    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)
    if q == 0: q = abs(q)
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression unknown-currency 1', ('1.005', 'GBX'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('1.0', 'ABCD'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],
 [('regression unknown-currency 1', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('15200.78697', 'GBX'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('47176.41', 'GBX'), 'ERR:unknown-currency'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00'),
  ('control: integer input', ('7', 'BHD'), '7.000')],
 [('regression unknown-currency 1', ('47176.41', 'GBX'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('24558.1895', 'GBX'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('20428.404', 'GBX'), 'ERR:unknown-currency'),
  ('control: integer input', ('7', 'BHD'), '7.000'), ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2')],
 [('regression unknown-currency 1', ('20428.404', 'GBX'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('11999.89380', 'GBX'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('44143.650', 'GBX'), 'ERR:unknown-currency'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression unknown-currency 1', ('44143.650', 'GBX'), 'ERR:unknown-currency'),
  ('regression unknown-currency 2', ('34654.813830', 'GBX'), 'ERR:unknown-currency'),
  ('partial repair guard 2', ('17622.45', 'GBX'), 'ERR:unknown-currency'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]
for label, args, expected in cases[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:
An unsupported code such as 'GBX' is formatted as if it were a cent currency.

solve(amount, ccy): amount is an exact decimal string, ccy an ISO-like code that is trimmed and upper-cased. Minor-unit exponents: USD 2, EUR 2, JPY 0, KRW 0, KWD 3, BHD 3, CLF 4. Round the exact decimal half-even at the currency exponent and return a plain string with exactly that many fraction digits; a zero result is unsigned. Unknown codes return 'ERR:unknown-currency'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy.strip().upper()
    if code not in exps: return 'ERR:unknown-currency'
    e = exps[code]
    x = Decimal(float(amount))
    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)
    if q == 0: q = abs(q)
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression exact-decimal-input 1', ('2.675', 'USD'), '2.68'),
  ('regression exact-decimal-input 2', ('0.12500000000000000001', 'USD'), '0.13'),
  ('partial repair guard 2', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],
 [('regression exact-decimal-input 1', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('regression exact-decimal-input 2', ('2.665', 'USD'), '2.66'),
  ('partial repair guard 1', ('0.12500000000000000001', 'USD'), '0.13'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00'),
  ('control: integer input', ('7', 'BHD'), '7.000')],
 [('regression exact-decimal-input 1', ('10.0005', 'KWD'), '10.000'),
  ('regression exact-decimal-input 2', ('12.345', ' eur '), '12.34'),
  ('partial repair guard 1', ('0.12500000000000000001', 'USD'), '0.13'),
  ('partial repair guard 2', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('control: integer input', ('7', 'BHD'), '7.000'), ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2')],
 [('regression exact-decimal-input 1', ('48525.1705', 'Kwd '), '48525.170'),
  ('regression exact-decimal-input 2', ('38174.12705', 'CLF'), '38174.1270'),
  ('partial repair guard 1', ('0.12500000000000000001', 'USD'), '0.13'),
  ('partial repair guard 2', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression exact-decimal-input 1', ('41458.105', 'EUR'), '41458.10'),
  ('regression exact-decimal-input 2', ('24714.6255', 'KWD'), '24714.626'),
  ('partial repair guard 1', ('0.12500000000000000001', 'USD'), '0.13'),
  ('partial repair guard 2', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]
for label, args, expected in cases[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
from decimal import Decimal, ROUND_HALF_EVEN, ROUND_HALF_UP, ROUND_FLOOR, ROUND_CEILING, ROUND_DOWN, ROUND_UP, ROUND_HALF_DOWN
N = 1
observations = []
def solve(amount, ccy):
    exps = {'USD': 2, 'EUR': 2, 'JPY': 0, 'KRW': 0, 'KWD': 3, 'BHD': 3, 'CLF': 4}
    code = ccy.strip().upper()
    if code not in exps: return 'ERR:unknown-currency'
    e = exps[code]
    x = Decimal(repr(float(amount)))
    q = x.quantize(Decimal(1).scaleb(-e), rounding=ROUND_HALF_EVEN)
    if q == 0: q = abs(q)
    return format(q, 'f')
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression exact-decimal-input 1', ('2.675', 'USD'), '2.68'),
  ('regression exact-decimal-input 2', ('0.12500000000000000001', 'USD'), '0.13'),
  ('partial repair guard 2', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('control: cents tie to even', ('2.665', 'USD'), '2.66'), ('control: yen tie', ('1235.5', 'JPY'), '1236'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346')],
 [('regression exact-decimal-input 1', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('regression exact-decimal-input 2', ('2.665', 'USD'), '2.66'),
  ('partial repair guard 1', ('0.12500000000000000001', 'USD'), '0.13'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00'),
  ('control: integer input', ('7', 'BHD'), '7.000')],
 [('regression exact-decimal-input 1', ('10.0005', 'KWD'), '10.000'),
  ('regression exact-decimal-input 2', ('12.345', ' eur '), '12.34'),
  ('partial repair guard 1', ('0.12500000000000000001', 'USD'), '0.13'),
  ('partial repair guard 2', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('control: integer input', ('7', 'BHD'), '7.000'), ('control: unknown code', ('1.00', 'ABC'), 'ERR:unknown-currency'),
  ('control: large amount', ('123456789.125', 'USD'), '123456789.12'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2')],
 [('regression exact-decimal-input 1', ('48525.1705', 'Kwd '), '48525.170'),
  ('regression exact-decimal-input 2', ('38174.12705', 'CLF'), '38174.1270'),
  ('partial repair guard 1', ('0.12500000000000000001', 'USD'), '0.13'),
  ('partial repair guard 2', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('control: negative tie', ('-2.5', 'KRW'), '-2'), ('control: cents tie to even', ('2.665', 'USD'), '2.66'),
  ('control: yen tie', ('1235.5', 'JPY'), '1236'), ('control: dinar three places', ('10.0005', 'KWD'), '10.000')],
 [('regression exact-decimal-input 1', ('41458.105', 'EUR'), '41458.10'),
  ('regression exact-decimal-input 2', ('24714.6255', 'KWD'), '24714.626'),
  ('partial repair guard 1', ('0.12500000000000000001', 'USD'), '0.13'),
  ('partial repair guard 2', ('1.0005000000000000000001', 'KWD'), '1.001'),
  ('control: dinar three places', ('10.0005', 'KWD'), '10.000'),
  ('control: unit of account four places', ('1.23456', 'CLF'), '1.2346'),
  ('control: lowercase code', ('12.345', ' eur '), '12.34'), ('control: negative small', ('-0.004', 'USD'), '0.00')]]
for label, args, expected in cases[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:
'2.675' USD rounds to 2.67 because the binary value is slightly below the tie.

solve(amount, ccy): amount is an exact decimal string, ccy an ISO-like code that is trimmed and upper-cased. Minor-unit exponents: USD 2, EUR 2, JPY 0, KRW 0, KWD 3, BHD 3, CLF 4. Round the exact decimal half-even at the currency exponent and return a plain string with exactly that many fraction digits; a zero result is unsigned. Unknown codes return 'ERR:unknown-currency'.

split: open-access