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

N = 1
observations = []
def solve(x):
    paid = x['paid']
    fare_part = paid - x['cancel_fee']
    if x['status'] == 'PARTIAL':
        fare_part -= x['used_fare']
    fare_part = max(0.0, fare_part)
    taxes = sum(a for code, a, refundable, used in x['taxes'] if (refundable or x['status'] == 'UNUSED') and not used)
    return round(fare_part + taxes, 2)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['unused refundable', {'paid': 481.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 418.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 421.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 366.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 38.2, True, False]]}, 38.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 201.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 27.0, True, False]]}, 652.0], ['sampled case 1', {'paid': 386.27, 'cancel_fee': 250.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 51.02, True, False], ['YQ', 5.59, False, False], ['XF', 3.57, True, False], ['DE', 99.09, True, False]]}, 289.95], ['sampled case 2', {'paid': 1007.21, 'cancel_fee': 50.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['XF', 29.38, True, False]]}, 986.59], ['sampled case 3', {'paid': 176.19, 'cancel_fee': 0.0, 'used_fare': 203.14, 'status': 'PARTIAL', 'taxes': [['DE', 94.53, True, True], ['GB', 107.54, False, True], ['XF', 23.26, True, True]]}, 0.0]], [['unused refundable', {'paid': 482.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 419.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 422.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 365.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 39.2, True, False]]}, 39.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 202.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 28.0, True, False]]}, 653.0], ['sampled case 1', {'paid': 1076.29, 'cancel_fee': 50.0, 'used_fare': 538.9, 'status': 'PARTIAL', 'taxes': [['YQ', 84.65, True, False], ['XF', 108.03, True, False]]}, 680.07], ['sampled case 2', {'paid': 193.38, 'cancel_fee': 250.0, 'used_fare': 218.71, 'status': 'PARTIAL', 'taxes': [['YQ', 67.48, True, False], ['GB', 86.2, True, False], ['AY', 96.45, True, False]]}, 250.13], ['sampled case 3', {'paid': 640.4, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['AY', 115.97, True, False], ['DE', 57.82, False, False]]}, 606.37]], [['unused refundable', {'paid': 483.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 420.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 423.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 364.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 40.2, True, False]]}, 40.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 203.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 29.0, True, False]]}, 654.0], ['sampled case 1', {'paid': 502.45, 'cancel_fee': 100.0, 'used_fare': 464.12, 'status': 'PARTIAL', 'taxes': [['US', 99.3, False, True], ['AY', 85.33, True, True], ['DE', 48.94, True, False]]}, 48.94], ['sampled case 2', {'paid': 638.36, 'cancel_fee': 150.0, 'used_fare': 498.2, 'status': 'PARTIAL', 'taxes': [['GB', 89.81, True, False], ['US', 67.48, False, True]]}, 89.81], ['sampled case 3', {'paid': 311.77, 'cancel_fee': 50.0, 'used_fare': 120.66, 'status': 'PARTIAL', 'taxes': []}, 141.11]], [['unused refundable', {'paid': 484.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 421.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 424.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 363.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 41.2, True, False]]}, 41.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 204.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 30.0, True, False]]}, 655.0], ['sampled case 1', {'paid': 716.18, 'cancel_fee': 50.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 62.57, True, False], ['US', 60.18, True, False], ['AY', 40.23, True, False]]}, 829.16], ['sampled case 2', {'paid': 304.89, 'cancel_fee': 250.0, 'used_fare': 353.1, 'status': 'PARTIAL', 'taxes': [['DE', 109.57, False, True], ['YQ', 82.61, True, False]]}, 82.61], ['sampled case 3', {'paid': 1425.61, 'cancel_fee': 100.0, 'used_fare': 1346.54, 'status': 'PARTIAL', 'taxes': [['GB', 93.65, True, False], ['AY', 56.1, True, True], ['DE', 105.73, False, False]]}, 93.65]], [['unused refundable', {'paid': 485.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 422.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 425.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 362.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 42.2, True, False]]}, 42.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 205.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 31.0, True, False]]}, 656.0], ['sampled case 1', {'paid': 1477.45, 'cancel_fee': 100.0, 'used_fare': 1174.26, 'status': 'PARTIAL', 'taxes': [['AY', 80.91, True, True], ['XF', 91.97, True, False]]}, 295.16], ['sampled case 2', {'paid': 441.62, 'cancel_fee': 50.0, 'used_fare': 285.82, 'status': 'PARTIAL', 'taxes': []}, 105.8], ['sampled case 3', {'paid': 1459.32, 'cancel_fee': 50.0, 'used_fare': 1488.81, 'status': 'PARTIAL', 'taxes': [['YQ', 64.57, False, True]]}, 0.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(x):
    paid = x['paid']
    fare_part = paid - x['cancel_fee']
    if x['status'] == 'PARTIAL':
        fare_part -= x['used_fare']
    fare_part = max(0.0, fare_part)
    taxes = sum(a for code, a, refundable, used in x['taxes'] if refundable or x['status'] == 'UNUSED')
    return round(fare_part + taxes, 2)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['unused refundable', {'paid': 481.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 418.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 421.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 366.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 38.2, True, False]]}, 38.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 201.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 27.0, True, False]]}, 652.0], ['sampled case 1', {'paid': 386.27, 'cancel_fee': 250.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 51.02, True, False], ['YQ', 5.59, False, False], ['XF', 3.57, True, False], ['DE', 99.09, True, False]]}, 289.95], ['sampled case 2', {'paid': 1007.21, 'cancel_fee': 50.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['XF', 29.38, True, False]]}, 986.59], ['sampled case 3', {'paid': 176.19, 'cancel_fee': 0.0, 'used_fare': 203.14, 'status': 'PARTIAL', 'taxes': [['DE', 94.53, True, True], ['GB', 107.54, False, True], ['XF', 23.26, True, True]]}, 0.0]], [['unused refundable', {'paid': 482.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 419.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 422.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 365.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 39.2, True, False]]}, 39.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 202.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 28.0, True, False]]}, 653.0], ['sampled case 1', {'paid': 1076.29, 'cancel_fee': 50.0, 'used_fare': 538.9, 'status': 'PARTIAL', 'taxes': [['YQ', 84.65, True, False], ['XF', 108.03, True, False]]}, 680.07], ['sampled case 2', {'paid': 193.38, 'cancel_fee': 250.0, 'used_fare': 218.71, 'status': 'PARTIAL', 'taxes': [['YQ', 67.48, True, False], ['GB', 86.2, True, False], ['AY', 96.45, True, False]]}, 250.13], ['sampled case 3', {'paid': 640.4, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['AY', 115.97, True, False], ['DE', 57.82, False, False]]}, 606.37]], [['unused refundable', {'paid': 483.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 420.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 423.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 364.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 40.2, True, False]]}, 40.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 203.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 29.0, True, False]]}, 654.0], ['sampled case 1', {'paid': 502.45, 'cancel_fee': 100.0, 'used_fare': 464.12, 'status': 'PARTIAL', 'taxes': [['US', 99.3, False, True], ['AY', 85.33, True, True], ['DE', 48.94, True, False]]}, 48.94], ['sampled case 2', {'paid': 638.36, 'cancel_fee': 150.0, 'used_fare': 498.2, 'status': 'PARTIAL', 'taxes': [['GB', 89.81, True, False], ['US', 67.48, False, True]]}, 89.81], ['sampled case 3', {'paid': 311.77, 'cancel_fee': 50.0, 'used_fare': 120.66, 'status': 'PARTIAL', 'taxes': []}, 141.11]], [['unused refundable', {'paid': 484.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 421.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 424.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 363.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 41.2, True, False]]}, 41.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 204.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 30.0, True, False]]}, 655.0], ['sampled case 1', {'paid': 716.18, 'cancel_fee': 50.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 62.57, True, False], ['US', 60.18, True, False], ['AY', 40.23, True, False]]}, 829.16], ['sampled case 2', {'paid': 304.89, 'cancel_fee': 250.0, 'used_fare': 353.1, 'status': 'PARTIAL', 'taxes': [['DE', 109.57, False, True], ['YQ', 82.61, True, False]]}, 82.61], ['sampled case 3', {'paid': 1425.61, 'cancel_fee': 100.0, 'used_fare': 1346.54, 'status': 'PARTIAL', 'taxes': [['GB', 93.65, True, False], ['AY', 56.1, True, True], ['DE', 105.73, False, False]]}, 93.65]], [['unused refundable', {'paid': 485.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 422.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 425.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 362.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 42.2, True, False]]}, 42.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 205.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 31.0, True, False]]}, 656.0], ['sampled case 1', {'paid': 1477.45, 'cancel_fee': 100.0, 'used_fare': 1174.26, 'status': 'PARTIAL', 'taxes': [['AY', 80.91, True, True], ['XF', 91.97, True, False]]}, 295.16], ['sampled case 2', {'paid': 441.62, 'cancel_fee': 50.0, 'used_fare': 285.82, 'status': 'PARTIAL', 'taxes': []}, 105.8], ['sampled case 3', {'paid': 1459.32, 'cancel_fee': 50.0, 'used_fare': 1488.81, 'status': 'PARTIAL', 'taxes': [['YQ', 64.57, False, True]]}, 0.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:
An unused ticket refunds its non-refundable carrier-imposed charge.

Input {'paid' base fare,'cancel_fee','used_fare','status' UNUSED|PARTIAL,'taxes':[[code, amount, refundable, used]]}. Fare portion = paid - cancel fee - (used fare only when PARTIAL), floored at 0 before taxes are added. Taxes are refunded only if refundable and not used. Return refund rounded 2.

split: open-access


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

N = 1
observations = []
def solve(x):
    paid = x['paid']
    fare_part = paid - x['cancel_fee']
    if x['used_fare']:
        fare_part -= x['used_fare']
    fare_part = max(0.0, fare_part)
    taxes = sum(a for code, a, refundable, used in x['taxes'] if refundable and not used)
    return round(fare_part + taxes, 2)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['unused refundable', {'paid': 481.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 418.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 421.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 366.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 38.2, True, False]]}, 38.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 201.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 27.0, True, False]]}, 652.0], ['sampled case 1', {'paid': 386.27, 'cancel_fee': 250.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 51.02, True, False], ['YQ', 5.59, False, False], ['XF', 3.57, True, False], ['DE', 99.09, True, False]]}, 289.95], ['sampled case 2', {'paid': 1007.21, 'cancel_fee': 50.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['XF', 29.38, True, False]]}, 986.59], ['sampled case 3', {'paid': 176.19, 'cancel_fee': 0.0, 'used_fare': 203.14, 'status': 'PARTIAL', 'taxes': [['DE', 94.53, True, True], ['GB', 107.54, False, True], ['XF', 23.26, True, True]]}, 0.0]], [['unused refundable', {'paid': 482.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 419.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 422.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 365.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 39.2, True, False]]}, 39.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 202.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 28.0, True, False]]}, 653.0], ['sampled case 1', {'paid': 1076.29, 'cancel_fee': 50.0, 'used_fare': 538.9, 'status': 'PARTIAL', 'taxes': [['YQ', 84.65, True, False], ['XF', 108.03, True, False]]}, 680.07], ['sampled case 2', {'paid': 193.38, 'cancel_fee': 250.0, 'used_fare': 218.71, 'status': 'PARTIAL', 'taxes': [['YQ', 67.48, True, False], ['GB', 86.2, True, False], ['AY', 96.45, True, False]]}, 250.13], ['sampled case 3', {'paid': 640.4, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['AY', 115.97, True, False], ['DE', 57.82, False, False]]}, 606.37]], [['unused refundable', {'paid': 483.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 420.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 423.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 364.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 40.2, True, False]]}, 40.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 203.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 29.0, True, False]]}, 654.0], ['sampled case 1', {'paid': 502.45, 'cancel_fee': 100.0, 'used_fare': 464.12, 'status': 'PARTIAL', 'taxes': [['US', 99.3, False, True], ['AY', 85.33, True, True], ['DE', 48.94, True, False]]}, 48.94], ['sampled case 2', {'paid': 638.36, 'cancel_fee': 150.0, 'used_fare': 498.2, 'status': 'PARTIAL', 'taxes': [['GB', 89.81, True, False], ['US', 67.48, False, True]]}, 89.81], ['sampled case 3', {'paid': 311.77, 'cancel_fee': 50.0, 'used_fare': 120.66, 'status': 'PARTIAL', 'taxes': []}, 141.11]], [['unused refundable', {'paid': 484.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 421.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 424.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 363.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 41.2, True, False]]}, 41.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 204.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 30.0, True, False]]}, 655.0], ['sampled case 1', {'paid': 716.18, 'cancel_fee': 50.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 62.57, True, False], ['US', 60.18, True, False], ['AY', 40.23, True, False]]}, 829.16], ['sampled case 2', {'paid': 304.89, 'cancel_fee': 250.0, 'used_fare': 353.1, 'status': 'PARTIAL', 'taxes': [['DE', 109.57, False, True], ['YQ', 82.61, True, False]]}, 82.61], ['sampled case 3', {'paid': 1425.61, 'cancel_fee': 100.0, 'used_fare': 1346.54, 'status': 'PARTIAL', 'taxes': [['GB', 93.65, True, False], ['AY', 56.1, True, True], ['DE', 105.73, False, False]]}, 93.65]], [['unused refundable', {'paid': 485.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 422.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 425.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 362.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 42.2, True, False]]}, 42.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 205.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 31.0, True, False]]}, 656.0], ['sampled case 1', {'paid': 1477.45, 'cancel_fee': 100.0, 'used_fare': 1174.26, 'status': 'PARTIAL', 'taxes': [['AY', 80.91, True, True], ['XF', 91.97, True, False]]}, 295.16], ['sampled case 2', {'paid': 441.62, 'cancel_fee': 50.0, 'used_fare': 285.82, 'status': 'PARTIAL', 'taxes': []}, 105.8], ['sampled case 3', {'paid': 1459.32, 'cancel_fee': 50.0, 'used_fare': 1488.81, 'status': 'PARTIAL', 'taxes': [['YQ', 64.57, False, True]]}, 0.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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(x):
    paid = x['paid']
    fare_part = paid - x['cancel_fee']
    if x['status'] == 'PARTIAL' or x['used_fare'] > x['cancel_fee']:
        fare_part -= x['used_fare']
    fare_part = max(0.0, fare_part)
    taxes = sum(a for code, a, refundable, used in x['taxes'] if refundable and not used)
    return round(fare_part + taxes, 2)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['unused refundable', {'paid': 481.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 418.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 421.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 366.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 38.2, True, False]]}, 38.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 201.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 27.0, True, False]]}, 652.0], ['sampled case 1', {'paid': 386.27, 'cancel_fee': 250.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 51.02, True, False], ['YQ', 5.59, False, False], ['XF', 3.57, True, False], ['DE', 99.09, True, False]]}, 289.95], ['sampled case 2', {'paid': 1007.21, 'cancel_fee': 50.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['XF', 29.38, True, False]]}, 986.59], ['sampled case 3', {'paid': 176.19, 'cancel_fee': 0.0, 'used_fare': 203.14, 'status': 'PARTIAL', 'taxes': [['DE', 94.53, True, True], ['GB', 107.54, False, True], ['XF', 23.26, True, True]]}, 0.0]], [['unused refundable', {'paid': 482.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 419.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 422.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 365.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 39.2, True, False]]}, 39.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 202.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 28.0, True, False]]}, 653.0], ['sampled case 1', {'paid': 1076.29, 'cancel_fee': 50.0, 'used_fare': 538.9, 'status': 'PARTIAL', 'taxes': [['YQ', 84.65, True, False], ['XF', 108.03, True, False]]}, 680.07], ['sampled case 2', {'paid': 193.38, 'cancel_fee': 250.0, 'used_fare': 218.71, 'status': 'PARTIAL', 'taxes': [['YQ', 67.48, True, False], ['GB', 86.2, True, False], ['AY', 96.45, True, False]]}, 250.13], ['sampled case 3', {'paid': 640.4, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['AY', 115.97, True, False], ['DE', 57.82, False, False]]}, 606.37]], [['unused refundable', {'paid': 483.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 420.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 423.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 364.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 40.2, True, False]]}, 40.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 203.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 29.0, True, False]]}, 654.0], ['sampled case 1', {'paid': 502.45, 'cancel_fee': 100.0, 'used_fare': 464.12, 'status': 'PARTIAL', 'taxes': [['US', 99.3, False, True], ['AY', 85.33, True, True], ['DE', 48.94, True, False]]}, 48.94], ['sampled case 2', {'paid': 638.36, 'cancel_fee': 150.0, 'used_fare': 498.2, 'status': 'PARTIAL', 'taxes': [['GB', 89.81, True, False], ['US', 67.48, False, True]]}, 89.81], ['sampled case 3', {'paid': 311.77, 'cancel_fee': 50.0, 'used_fare': 120.66, 'status': 'PARTIAL', 'taxes': []}, 141.11]], [['unused refundable', {'paid': 484.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 421.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 424.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 363.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 41.2, True, False]]}, 41.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 204.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 30.0, True, False]]}, 655.0], ['sampled case 1', {'paid': 716.18, 'cancel_fee': 50.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 62.57, True, False], ['US', 60.18, True, False], ['AY', 40.23, True, False]]}, 829.16], ['sampled case 2', {'paid': 304.89, 'cancel_fee': 250.0, 'used_fare': 353.1, 'status': 'PARTIAL', 'taxes': [['DE', 109.57, False, True], ['YQ', 82.61, True, False]]}, 82.61], ['sampled case 3', {'paid': 1425.61, 'cancel_fee': 100.0, 'used_fare': 1346.54, 'status': 'PARTIAL', 'taxes': [['GB', 93.65, True, False], ['AY', 56.1, True, True], ['DE', 105.73, False, False]]}, 93.65]], [['unused refundable', {'paid': 485.0, 'cancel_fee': 100.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 37.2, True, False], ['YQ', 80.0, False, False]]}, 422.2], ['partial with used taxes', {'paid': 900.0, 'cancel_fee': 150.0, 'used_fare': 425.0, 'status': 'PARTIAL', 'taxes': [['US', 37.2, True, False], ['XF', 4.5, True, True], ['YQ', 80.0, False, False], ['AY', 5.6, True, True]]}, 362.2], ['fee larger than fare', {'paid': 90.0, 'cancel_fee': 150.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['US', 42.2, True, False]]}, 42.2], ['used portion exceeds paid', {'paid': 300.0, 'cancel_fee': 50.0, 'used_fare': 310.0, 'status': 'PARTIAL', 'taxes': [['US', 18.6, True, False], ['XF', 4.5, True, True]]}, 18.6], ['unused with stale used estimate', {'paid': 650.0, 'cancel_fee': 0.0, 'used_fare': 205.0, 'status': 'UNUSED', 'taxes': [['US', 20.0, True, False]]}, 670.0], ['non-refundable carrier charges', {'paid': 700.0, 'cancel_fee': 75.0, 'used_fare': 0.0, 'status': 'UNUSED', 'taxes': [['YQ', 120.0, False, False], ['GB', 31.0, True, False]]}, 656.0], ['sampled case 1', {'paid': 1477.45, 'cancel_fee': 100.0, 'used_fare': 1174.26, 'status': 'PARTIAL', 'taxes': [['AY', 80.91, True, True], ['XF', 91.97, True, False]]}, 295.16], ['sampled case 2', {'paid': 441.62, 'cancel_fee': 50.0, 'used_fare': 285.82, 'status': 'PARTIAL', 'taxes': []}, 105.8], ['sampled case 3', {'paid': 1459.32, 'cancel_fee': 50.0, 'used_fare': 1488.81, 'status': 'PARTIAL', 'taxes': [['YQ', 64.57, False, True]]}, 0.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:
An unused ticket carrying a stale used-fare estimate refunds less than it should.

Input {'paid' base fare,'cancel_fee','used_fare','status' UNUSED|PARTIAL,'taxes':[[code, amount, refundable, used]]}. Fare portion = paid - cancel fee - (used fare only when PARTIAL), floored at 0 before taxes are added. Taxes are refunded only if refundable and not used. Return refund rounded 2.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    wk = x['weekend_days']
    def sur(ds):
        return x['surcharge'] if str(datetime.date.fromisoformat(ds).isoweekday()) in wk else 0
    total = sur(x['outbound'])
    if x['inbound'] is not None and x['rt_rule'] == 'EACH':
        total += sur(x['outbound'])
    return total * x['pax']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 30], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2027-08-29', 'inbound': '2027-09-14', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 5}, 125], ['sampled case 2', {'outbound': '2029-05-04', 'inbound': '2029-05-06', 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 40], ['sampled case 3', {'outbound': '2029-02-23', 'inbound': '2029-03-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 1}, 10]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 2}, 60], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-10-08', 'inbound': None, 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-10-14', 'inbound': '2028-10-29', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2027-01-22', 'inbound': '2027-01-27', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 3}, 0]], [['weekday out weekend back', {'outbound': '2027-03-01', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-15', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 3}, 90], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2028-10-14', 'inbound': None, 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 5}, 0], ['sampled case 2', {'outbound': '2027-03-30', 'inbound': '2027-04-13', 'weekend_days': '7', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-09-18', 'inbound': '2028-09-29', 'weekend_days': '67', 'surcharge': 10, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0]], [['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 120], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-09-11', 'inbound': '2029-09-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 2', {'outbound': '2027-09-08', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-08-06', 'inbound': '2028-08-16', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 2}, 60]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 5}, 150], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-06-29', 'inbound': '2029-07-16', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-01-20', 'inbound': None, 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 0], ['sampled case 3', {'outbound': '2028-07-21', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 100]]]
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(x):
    wk = x['weekend_days']
    def sur(ds):
        return x['surcharge'] if str(datetime.date.fromisoformat(ds).isoweekday()) in wk else 0
    total = sur(x['outbound'])
    if x['inbound'] is not None and x['rt_rule'] == 'EACH':
        total += sur(x['inbound']) if total else 0
    return total * x['pax']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 30], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2027-08-29', 'inbound': '2027-09-14', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 5}, 125], ['sampled case 2', {'outbound': '2029-05-04', 'inbound': '2029-05-06', 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 40], ['sampled case 3', {'outbound': '2029-02-23', 'inbound': '2029-03-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 1}, 10]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 2}, 60], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-10-08', 'inbound': None, 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-10-14', 'inbound': '2028-10-29', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2027-01-22', 'inbound': '2027-01-27', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 3}, 0]], [['weekday out weekend back', {'outbound': '2027-03-01', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-15', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 3}, 90], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2028-10-14', 'inbound': None, 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 5}, 0], ['sampled case 2', {'outbound': '2027-03-30', 'inbound': '2027-04-13', 'weekend_days': '7', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-09-18', 'inbound': '2028-09-29', 'weekend_days': '67', 'surcharge': 10, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0]], [['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 120], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-09-11', 'inbound': '2029-09-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 2', {'outbound': '2027-09-08', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-08-06', 'inbound': '2028-08-16', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 2}, 60]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 5}, 150], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-06-29', 'inbound': '2029-07-16', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-01-20', 'inbound': None, 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 0], ['sampled case 3', {'outbound': '2028-07-21', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 100]]]
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 weekend return after a weekday departure is not surcharged, while a weekday return after a weekend departure is.

Input {'outbound','inbound' (ISO or None),'weekend_days' ISO digits,'surcharge','rt_rule' EACH|OUTBOUND,'pax'}. Each direction is surcharged by its own departure weekday; with OUTBOUND only the outbound direction is assessed. The per-passenger total is multiplied by pax.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    wk = x['weekend_days']
    def sur(ds):
        return x['surcharge'] if str(datetime.date.fromisoformat(ds).isoweekday()) in wk else 0
    total = sur(x['outbound'])
    if x['inbound'] is not None:
        total += sur(x['inbound'])
    return total * x['pax']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 30], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2027-08-29', 'inbound': '2027-09-14', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 5}, 125], ['sampled case 2', {'outbound': '2029-05-04', 'inbound': '2029-05-06', 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 40], ['sampled case 3', {'outbound': '2029-02-23', 'inbound': '2029-03-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 1}, 10]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 2}, 60], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-10-08', 'inbound': None, 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-10-14', 'inbound': '2028-10-29', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2027-01-22', 'inbound': '2027-01-27', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 3}, 0]], [['weekday out weekend back', {'outbound': '2027-03-01', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-15', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 3}, 90], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2028-10-14', 'inbound': None, 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 5}, 0], ['sampled case 2', {'outbound': '2027-03-30', 'inbound': '2027-04-13', 'weekend_days': '7', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-09-18', 'inbound': '2028-09-29', 'weekend_days': '67', 'surcharge': 10, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0]], [['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 120], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-09-11', 'inbound': '2029-09-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 2', {'outbound': '2027-09-08', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-08-06', 'inbound': '2028-08-16', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 2}, 60]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 5}, 150], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-06-29', 'inbound': '2029-07-16', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-01-20', 'inbound': None, 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 0], ['sampled case 3', {'outbound': '2028-07-21', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 100]]]
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(x):
    wk = x['weekend_days']
    def sur(ds):
        return x['surcharge'] if str(datetime.date.fromisoformat(ds).isoweekday()) in wk else 0
    total = sur(x['outbound'])
    if x['inbound'] is not None and x['rt_rule'] != 'NONE':
        total += sur(x['inbound'])
    return total * x['pax']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 30], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2027-08-29', 'inbound': '2027-09-14', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 5}, 125], ['sampled case 2', {'outbound': '2029-05-04', 'inbound': '2029-05-06', 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 40], ['sampled case 3', {'outbound': '2029-02-23', 'inbound': '2029-03-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 1}, 10]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 2}, 60], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-10-08', 'inbound': None, 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-10-14', 'inbound': '2028-10-29', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2027-01-22', 'inbound': '2027-01-27', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 3}, 0]], [['weekday out weekend back', {'outbound': '2027-03-01', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-15', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 3}, 90], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2028-10-14', 'inbound': None, 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 5}, 0], ['sampled case 2', {'outbound': '2027-03-30', 'inbound': '2027-04-13', 'weekend_days': '7', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-09-18', 'inbound': '2028-09-29', 'weekend_days': '67', 'surcharge': 10, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0]], [['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 120], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-09-11', 'inbound': '2029-09-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 2', {'outbound': '2027-09-08', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-08-06', 'inbound': '2028-08-16', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 2}, 60]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 5}, 150], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-06-29', 'inbound': '2029-07-16', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-01-20', 'inbound': None, 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 0], ['sampled case 3', {'outbound': '2028-07-21', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 100]]]
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:
Fares with an OUTBOUND rule add a second weekend surcharge on the return.

Input {'outbound','inbound' (ISO or None),'weekend_days' ISO digits,'surcharge','rt_rule' EACH|OUTBOUND,'pax'}. Each direction is surcharged by its own departure weekday; with OUTBOUND only the outbound direction is assessed. The per-passenger total is multiplied by pax.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    wk = x['weekend_days']
    def sur(ds):
        return x['surcharge'] if str(datetime.date.fromisoformat(ds).isoweekday()) in wk else 0
    total = sur(x['outbound']) * x['pax']
    if x['inbound'] is not None and x['rt_rule'] == 'EACH':
        total += sur(x['inbound'])
    return total
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 30], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2027-08-29', 'inbound': '2027-09-14', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 5}, 125], ['sampled case 2', {'outbound': '2029-05-04', 'inbound': '2029-05-06', 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 40], ['sampled case 3', {'outbound': '2029-02-23', 'inbound': '2029-03-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 1}, 10]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 2}, 60], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-10-08', 'inbound': None, 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-10-14', 'inbound': '2028-10-29', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2027-01-22', 'inbound': '2027-01-27', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 3}, 0]], [['weekday out weekend back', {'outbound': '2027-03-01', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-15', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 3}, 90], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2028-10-14', 'inbound': None, 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 5}, 0], ['sampled case 2', {'outbound': '2027-03-30', 'inbound': '2027-04-13', 'weekend_days': '7', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-09-18', 'inbound': '2028-09-29', 'weekend_days': '67', 'surcharge': 10, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0]], [['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 120], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-09-11', 'inbound': '2029-09-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 2', {'outbound': '2027-09-08', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-08-06', 'inbound': '2028-08-16', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 2}, 60]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 5}, 150], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-06-29', 'inbound': '2029-07-16', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-01-20', 'inbound': None, 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 0], ['sampled case 3', {'outbound': '2028-07-21', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 100]]]
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(x):
    wk = x['weekend_days']
    def sur(ds):
        return x['surcharge'] if str(datetime.date.fromisoformat(ds).isoweekday()) in wk else 0
    total = sur(x['outbound']) * x['pax']
    if x['inbound'] is not None and x['rt_rule'] == 'EACH':
        total += sur(x['inbound'])
    return total * x['pax']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 30], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2027-08-29', 'inbound': '2027-09-14', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 5}, 125], ['sampled case 2', {'outbound': '2029-05-04', 'inbound': '2029-05-06', 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 40], ['sampled case 3', {'outbound': '2029-02-23', 'inbound': '2029-03-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 1}, 10]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 2}, 60], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-10-08', 'inbound': None, 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-10-14', 'inbound': '2028-10-29', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2027-01-22', 'inbound': '2027-01-27', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 3}, 0]], [['weekday out weekend back', {'outbound': '2027-03-01', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-15', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 3}, 90], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2028-10-14', 'inbound': None, 'weekend_days': '7', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 5}, 0], ['sampled case 2', {'outbound': '2027-03-30', 'inbound': '2027-04-13', 'weekend_days': '7', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-09-18', 'inbound': '2028-09-29', 'weekend_days': '67', 'surcharge': 10, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0]], [['weekday out weekend back', {'outbound': '2027-03-02', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-16', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 4}, 120], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-03', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-09-11', 'inbound': '2029-09-13', 'weekend_days': '57', 'surcharge': 10, 'rt_rule': 'EACH', 'pax': 4}, 0], ['sampled case 2', {'outbound': '2027-09-08', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 0], ['sampled case 3', {'outbound': '2028-08-06', 'inbound': '2028-08-16', 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 2}, 60]], [['weekday out weekend back', {'outbound': '2027-03-03', 'inbound': '2027-03-13', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 2}, 50], ['weekend out weekday back', {'outbound': '2027-03-12', 'inbound': '2027-03-17', 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'EACH', 'pax': 1}, 25], ['outbound-only rule', {'outbound': '2027-03-13', 'inbound': '2027-03-20', 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 5}, 150], ['one-way weekend', {'outbound': '2027-03-14', 'inbound': None, 'weekend_days': '67', 'surcharge': 30, 'rt_rule': 'EACH', 'pax': 3}, 90], ['both weekend family', {'outbound': '2027-03-12', 'inbound': '2027-03-14', 'weekend_days': '567', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 4}, 160], ['no surcharge', {'outbound': '2027-03-02', 'inbound': '2027-03-04', 'weekend_days': '67', 'surcharge': 20, 'rt_rule': 'EACH', 'pax': 2}, 0], ['sampled case 1', {'outbound': '2029-06-29', 'inbound': '2029-07-16', 'weekend_days': '7', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 2}, 0], ['sampled case 2', {'outbound': '2028-01-20', 'inbound': None, 'weekend_days': '57', 'surcharge': 30, 'rt_rule': 'OUTBOUND', 'pax': 1}, 0], ['sampled case 3', {'outbound': '2028-07-21', 'inbound': None, 'weekend_days': '567', 'surcharge': 25, 'rt_rule': 'OUTBOUND', 'pax': 4}, 100]]]
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 family of four is charged four outbound weekend surcharges but a single inbound one.

Input {'outbound','inbound' (ISO or None),'weekend_days' ISO digits,'surcharge','rt_rule' EACH|OUTBOUND,'pax'}. Each direction is surcharged by its own departure weekday; with OUTBOUND only the outbound direction is assessed. The per-passenger total is multiplied by pax.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    halves = []
    for amt, carrier, tariff in x['components']:
        halves.append(math.ceil(amt / 2))
    tariffs = {c[2] for c in x['components']}
    carriers = {c[1] for c in x['components']}
    if len(tariffs) > 1: return 'ERR_TARIFF'
    if len(carriers) > 1 and not x['interline_ok']: return 'ERR_CARRIER'
    return math.ceil(sum(c[0] for c in x['components']) / 2)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [659, 'AA', 'PUB']], 'interline_ok': False}, 731], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [601, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1202, 'LH', 'NEG']], 'interline_ok': False}, 601], ['sampled case 1', {'components': [[1106, 'AA', 'PUB'], [904, 'AA', 'PUB'], [1089, 'AA', 'PUB'], [355, 'LH', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['sampled case 2', {'components': [[898, 'AA', 'PUB'], [1009, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['sampled case 3', {'components': [[350, 'AA', 'NEG'], [1535, 'BA', 'NEG'], [587, 'BA', 'PUB'], [220, 'AA', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF']], [['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [661, 'AA', 'PUB']], 'interline_ok': False}, 732], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1002, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [602, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1204, 'LH', 'NEG']], 'interline_ok': False}, 602], ['sampled case 1', {'components': [[1455, 'LH', 'NEG'], [1654, 'AA', 'NEG'], [1091, 'BA', 'NEG'], [1846, 'LH', 'NEG']], 'interline_ok': True}, 3024], ['sampled case 2', {'components': [[887, 'LH', 'NEG']], 'interline_ok': False}, 444], ['sampled case 3', {'components': [[600, 'BA', 'PUB']], 'interline_ok': False}, 300]], [['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [663, 'AA', 'PUB']], 'interline_ok': False}, 733], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1003, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [603, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1206, 'LH', 'NEG']], 'interline_ok': False}, 603], ['sampled case 1', {'components': [[1872, 'AA', 'NEG'], [1205, 'AA', 'NEG'], [851, 'AA', 'NEG'], [434, 'LH', 'NEG']], 'interline_ok': True}, 2182], ['sampled case 2', {'components': [[1006, 'AA', 'NEG'], [1939, 'BA', 'PUB'], [850, 'AA', 'PUB'], [1563, 'AA', 'PUB']], 'interline_ok': False}, 'ERR_TARIFF'], ['sampled case 3', {'components': [[305, 'BA', 'PUB']], 'interline_ok': False}, 153]], [['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [665, 'AA', 'PUB']], 'interline_ok': False}, 734], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1004, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [604, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1208, 'LH', 'NEG']], 'interline_ok': False}, 604], ['sampled case 1', {'components': [[873, 'AA', 'PUB'], [230, 'BA', 'PUB']], 'interline_ok': True}, 552], ['sampled case 2', {'components': [[1819, 'AA', 'NEG'], [1744, 'AA', 'NEG'], [1758, 'BA', 'NEG']], 'interline_ok': False}, 'ERR_CARRIER'], ['sampled case 3', {'components': [[818, 'LH', 'NEG'], [1794, 'AA', 'NEG'], [1837, 'AA', 'NEG'], [631, 'AA', 'NEG']], 'interline_ok': True}, 2541]], [['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [667, 'AA', 'PUB']], 'interline_ok': False}, 735], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1005, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [605, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1210, 'LH', 'NEG']], 'interline_ok': False}, 605], ['sampled case 1', {'components': [[1193, 'BA', 'NEG'], [1868, 'AA', 'PUB']], 'interline_ok': False}, 'ERR_TARIFF'], ['sampled case 2', {'components': [[1981, 'AA', 'NEG']], 'interline_ok': True}, 991], ['sampled case 3', {'components': [[1746, 'LH', 'NEG'], [1675, 'LH', 'NEG'], [1321, 'AA', 'PUB']], 'interline_ok': True}, 'ERR_TARIFF']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    halves = []
    for amt, carrier, tariff in x['components']:
        halves.append(amt // 2)
    tariffs = {c[2] for c in x['components']}
    carriers = {c[1] for c in x['components']}
    if len(tariffs) > 1: return 'ERR_TARIFF'
    if len(carriers) > 1 and not x['interline_ok']: return 'ERR_CARRIER'
    return sum(halves)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [659, 'AA', 'PUB']], 'interline_ok': False}, 731], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [601, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1202, 'LH', 'NEG']], 'interline_ok': False}, 601], ['sampled case 1', {'components': [[1106, 'AA', 'PUB'], [904, 'AA', 'PUB'], [1089, 'AA', 'PUB'], [355, 'LH', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['sampled case 2', {'components': [[898, 'AA', 'PUB'], [1009, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['sampled case 3', {'components': [[350, 'AA', 'NEG'], [1535, 'BA', 'NEG'], [587, 'BA', 'PUB'], [220, 'AA', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF']], [['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [661, 'AA', 'PUB']], 'interline_ok': False}, 732], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1002, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [602, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1204, 'LH', 'NEG']], 'interline_ok': False}, 602], ['sampled case 1', {'components': [[1455, 'LH', 'NEG'], [1654, 'AA', 'NEG'], [1091, 'BA', 'NEG'], [1846, 'LH', 'NEG']], 'interline_ok': True}, 3024], ['sampled case 2', {'components': [[887, 'LH', 'NEG']], 'interline_ok': False}, 444], ['sampled case 3', {'components': [[600, 'BA', 'PUB']], 'interline_ok': False}, 300]], [['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [663, 'AA', 'PUB']], 'interline_ok': False}, 733], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1003, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [603, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1206, 'LH', 'NEG']], 'interline_ok': False}, 603], ['sampled case 1', {'components': [[1872, 'AA', 'NEG'], [1205, 'AA', 'NEG'], [851, 'AA', 'NEG'], [434, 'LH', 'NEG']], 'interline_ok': True}, 2182], ['sampled case 2', {'components': [[1006, 'AA', 'NEG'], [1939, 'BA', 'PUB'], [850, 'AA', 'PUB'], [1563, 'AA', 'PUB']], 'interline_ok': False}, 'ERR_TARIFF'], ['sampled case 3', {'components': [[305, 'BA', 'PUB']], 'interline_ok': False}, 153]], [['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [665, 'AA', 'PUB']], 'interline_ok': False}, 734], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1004, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [604, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1208, 'LH', 'NEG']], 'interline_ok': False}, 604], ['sampled case 1', {'components': [[873, 'AA', 'PUB'], [230, 'BA', 'PUB']], 'interline_ok': True}, 552], ['sampled case 2', {'components': [[1819, 'AA', 'NEG'], [1744, 'AA', 'NEG'], [1758, 'BA', 'NEG']], 'interline_ok': False}, 'ERR_CARRIER'], ['sampled case 3', {'components': [[818, 'LH', 'NEG'], [1794, 'AA', 'NEG'], [1837, 'AA', 'NEG'], [631, 'AA', 'NEG']], 'interline_ok': True}, 2541]], [['odd RT fares open jaw', {'components': [[801, 'AA', 'PUB'], [667, 'AA', 'PUB']], 'interline_ok': False}, 735], ['interline allowed', {'components': [[900, 'AA', 'PUB'], [1001, 'BA', 'PUB']], 'interline_ok': True}, 951], ['interline forbidden', {'components': [[900, 'AA', 'PUB'], [1005, 'BA', 'PUB']], 'interline_ok': False}, 'ERR_CARRIER'], ['third component other tariff', {'components': [[500, 'AA', 'PUB'], [601, 'AA', 'PUB'], [703, 'AA', 'NEG']], 'interline_ok': True}, 'ERR_TARIFF'], ['tariff and carrier both differ', {'components': [[500, 'AA', 'PUB'], [605, 'LH', 'NEG']], 'interline_ok': False}, 'ERR_TARIFF'], ['single even component', {'components': [[1210, 'LH', 'NEG']], 'interline_ok': False}, 605], ['sampled case 1', {'components': [[1193, 'BA', 'NEG'], [1868, 'AA', 'PUB']], 'interline_ok': False}, 'ERR_TARIFF'], ['sampled case 2', {'components': [[1981, 'AA', 'NEG']], 'interline_ok': True}, 991], ['sampled case 3', {'components': [[1746, 'LH', 'NEG'], [1675, 'LH', 'NEG'], [1321, 'AA', 'PUB']], 'interline_ok': True}, 'ERR_TARIFF']]]
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:
Two odd round-trip fares combine one unit cheaper than their rounded halves.

Input {'components':[[RT amount, carrier, tariff]],'interline_ok'}. Each component contributes half its RT amount rounded up to a whole unit. All components must share one tariff ('ERR_TARIFF', checked first); multiple carriers require interline_ok ('ERR_CARRIER'). Return the summed halves.

split: open-access