broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import decimal
N = 1
observations = []
def solve(x):
    b = datetime.date.fromisoformat(x['birth'])
    d = datetime.date.fromisoformat(x['depart'])
    try:
        bday = b.replace(year=d.year)
    except ValueError:
        bday = datetime.date(d.year, 2, 28)
    age = d.year - b.year - (1 if d < bday else 0)
    if age < 2: ptc, pct = 'INF', 10
    elif age < 12: ptc, pct = 'CHD', 75
    else: ptc, pct = 'ADT', 100
    amt = (decimal.Decimal(str(x['fare'])) * pct / 100).quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_HALF_UP)
    return [ptc, float(amt)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['child day before 12th birthday', {'birth': '2016-05-11', 'depart': '2028-05-10', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 413.5}, ['ADT', 413.5]], ['infant turns two on travel day', {'birth': '2026-03-01', 'depart': '2028-03-01', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 301.0}, ['INF', 30.1]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-11', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-01', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2015-02-22', 'depart': '2027-02-15', 'fare': 171.9}, ['CHD', 128.93]], ['sampled case 2', {'birth': '2023-11-19', 'depart': '2029-03-25', 'fare': 1444.58}, ['CHD', 1083.44]], ['sampled case 3', {'birth': '2027-08-22', 'depart': '2029-08-21', 'fare': 608.88}, ['INF', 60.89]]], [['child day before 12th birthday', {'birth': '2016-05-12', 'depart': '2028-05-11', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 414.5}, ['ADT', 414.5]], ['infant turns two on travel day', {'birth': '2026-03-02', 'depart': '2028-03-02', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 302.0}, ['INF', 30.2]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-12', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-02', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2025-04-03', 'depart': '2027-04-02', 'fare': 516.1}, ['INF', 51.61]], ['sampled case 2', {'birth': '2026-06-08', 'depart': '2028-06-06', 'fare': 952.7}, ['INF', 95.27]], ['sampled case 3', {'birth': '2017-05-05', 'depart': '2029-05-02', 'fare': 942.13}, ['CHD', 706.6]]], [['child day before 12th birthday', {'birth': '2016-05-13', 'depart': '2028-05-12', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 415.5}, ['ADT', 415.5]], ['infant turns two on travel day', {'birth': '2026-03-03', 'depart': '2028-03-03', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 303.0}, ['INF', 30.3]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-13', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-03', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2017-10-23', 'depart': '2029-10-19', 'fare': 1447.34}, ['CHD', 1085.51]], ['sampled case 2', {'birth': '2016-03-06', 'depart': '2028-02-28', 'fare': 1074.9}, ['CHD', 806.18]], ['sampled case 3', {'birth': '2015-06-23', 'depart': '2027-06-20', 'fare': 768.6}, ['CHD', 576.45]]], [['child day before 12th birthday', {'birth': '2016-05-14', 'depart': '2028-05-13', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 416.5}, ['ADT', 416.5]], ['infant turns two on travel day', {'birth': '2026-03-04', 'depart': '2028-03-04', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 304.0}, ['INF', 30.4]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-14', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-04', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2028-06-21', 'depart': '2029-08-22', 'fare': 642.31}, ['INF', 64.23]], ['sampled case 2', {'birth': '2019-06-26', 'depart': '2027-12-23', 'fare': 211.9}, ['CHD', 158.93]], ['sampled case 3', {'birth': '2025-09-18', 'depart': '2027-09-19', 'fare': 1456.7}, ['CHD', 1092.53]]], [['child day before 12th birthday', {'birth': '2016-05-15', 'depart': '2028-05-14', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 417.5}, ['ADT', 417.5]], ['infant turns two on travel day', {'birth': '2026-03-05', 'depart': '2028-03-05', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 305.0}, ['INF', 30.5]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-15', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-05', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2026-08-03', 'depart': '2028-07-31', 'fare': 265.0}, ['INF', 26.5]], ['sampled case 2', {'birth': '2026-08-19', 'depart': '2028-08-19', 'fare': 820.15}, ['CHD', 615.11]], ['sampled case 3', {'birth': '2017-09-28', 'depart': '2029-09-26', 'fare': 855.8}, ['CHD', 641.85]]]]
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
import decimal
N = 1
observations = []
def solve(x):
    b = datetime.date.fromisoformat(x['birth'])
    d = datetime.date.fromisoformat(x['depart'])
    try:
        bday = b.replace(year=d.year)
    except ValueError:
        bday = datetime.date(d.year, 2, 28) if d.month == 2 else datetime.date(d.year, 3, 1)
    age = d.year - b.year - (1 if d < bday else 0)
    if age < 2: ptc, pct = 'INF', 10
    elif age < 12: ptc, pct = 'CHD', 75
    else: ptc, pct = 'ADT', 100
    amt = (decimal.Decimal(str(x['fare'])) * pct / 100).quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_HALF_UP)
    return [ptc, float(amt)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['child day before 12th birthday', {'birth': '2016-05-11', 'depart': '2028-05-10', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 413.5}, ['ADT', 413.5]], ['infant turns two on travel day', {'birth': '2026-03-01', 'depart': '2028-03-01', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 301.0}, ['INF', 30.1]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-11', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-01', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2015-02-22', 'depart': '2027-02-15', 'fare': 171.9}, ['CHD', 128.93]], ['sampled case 2', {'birth': '2023-11-19', 'depart': '2029-03-25', 'fare': 1444.58}, ['CHD', 1083.44]], ['sampled case 3', {'birth': '2027-08-22', 'depart': '2029-08-21', 'fare': 608.88}, ['INF', 60.89]]], [['child day before 12th birthday', {'birth': '2016-05-12', 'depart': '2028-05-11', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 414.5}, ['ADT', 414.5]], ['infant turns two on travel day', {'birth': '2026-03-02', 'depart': '2028-03-02', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 302.0}, ['INF', 30.2]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-12', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-02', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2025-04-03', 'depart': '2027-04-02', 'fare': 516.1}, ['INF', 51.61]], ['sampled case 2', {'birth': '2026-06-08', 'depart': '2028-06-06', 'fare': 952.7}, ['INF', 95.27]], ['sampled case 3', {'birth': '2017-05-05', 'depart': '2029-05-02', 'fare': 942.13}, ['CHD', 706.6]]], [['child day before 12th birthday', {'birth': '2016-05-13', 'depart': '2028-05-12', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 415.5}, ['ADT', 415.5]], ['infant turns two on travel day', {'birth': '2026-03-03', 'depart': '2028-03-03', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 303.0}, ['INF', 30.3]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-13', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-03', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2017-10-23', 'depart': '2029-10-19', 'fare': 1447.34}, ['CHD', 1085.51]], ['sampled case 2', {'birth': '2016-03-06', 'depart': '2028-02-28', 'fare': 1074.9}, ['CHD', 806.18]], ['sampled case 3', {'birth': '2015-06-23', 'depart': '2027-06-20', 'fare': 768.6}, ['CHD', 576.45]]], [['child day before 12th birthday', {'birth': '2016-05-14', 'depart': '2028-05-13', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 416.5}, ['ADT', 416.5]], ['infant turns two on travel day', {'birth': '2026-03-04', 'depart': '2028-03-04', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 304.0}, ['INF', 30.4]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-14', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-04', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2028-06-21', 'depart': '2029-08-22', 'fare': 642.31}, ['INF', 64.23]], ['sampled case 2', {'birth': '2019-06-26', 'depart': '2027-12-23', 'fare': 211.9}, ['CHD', 158.93]], ['sampled case 3', {'birth': '2025-09-18', 'depart': '2027-09-19', 'fare': 1456.7}, ['CHD', 1092.53]]], [['child day before 12th birthday', {'birth': '2016-05-15', 'depart': '2028-05-14', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 417.5}, ['ADT', 417.5]], ['infant turns two on travel day', {'birth': '2026-03-05', 'depart': '2028-03-05', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 305.0}, ['INF', 30.5]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-15', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-05', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2026-08-03', 'depart': '2028-07-31', 'fare': 265.0}, ['INF', 26.5]], ['sampled case 2', {'birth': '2026-08-19', 'depart': '2028-08-19', 'fare': 820.15}, ['CHD', 615.11]], ['sampled case 3', {'birth': '2017-09-28', 'depart': '2029-09-26', 'fare': 855.8}, ['CHD', 641.85]]]]
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 child born on 29 February turns 12 a day early in non-leap years.

Input {'birth','depart' ISO dates,'fare'}. Age is completed years on the departure date; a 29 February birthday falls on 1 March in non-leap years. Under 2 -> INF 10%; 2 to 11 -> CHD 75%; otherwise ADT 100%. Amount = fare*pct/100 rounded half-up to cents. Return [ptc, amount].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import decimal
N = 1
observations = []
def solve(x):
    b = datetime.date.fromisoformat(x['birth'])
    d = datetime.date.fromisoformat(x['depart'])
    try:
        bday = b.replace(year=d.year)
    except ValueError:
        bday = datetime.date(d.year, 3, 1)
    age = d.year - b.year - (1 if d < bday else 0)
    if age < 2: ptc, pct = 'INF', 10
    elif age < 12: ptc, pct = 'CHD', 75
    else: ptc, pct = 'ADT', 100
    amt = (decimal.Decimal(str(x['fare'])) * pct / 100).quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_HALF_EVEN)
    return [ptc, float(amt)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['child day before 12th birthday', {'birth': '2016-05-11', 'depart': '2028-05-10', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 413.5}, ['ADT', 413.5]], ['infant turns two on travel day', {'birth': '2026-03-01', 'depart': '2028-03-01', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 301.0}, ['INF', 30.1]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-11', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-01', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2015-02-22', 'depart': '2027-02-15', 'fare': 171.9}, ['CHD', 128.93]], ['sampled case 2', {'birth': '2023-11-19', 'depart': '2029-03-25', 'fare': 1444.58}, ['CHD', 1083.44]], ['sampled case 3', {'birth': '2027-08-22', 'depart': '2029-08-21', 'fare': 608.88}, ['INF', 60.89]]], [['child day before 12th birthday', {'birth': '2016-05-12', 'depart': '2028-05-11', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 414.5}, ['ADT', 414.5]], ['infant turns two on travel day', {'birth': '2026-03-02', 'depart': '2028-03-02', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 302.0}, ['INF', 30.2]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-12', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-02', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2025-04-03', 'depart': '2027-04-02', 'fare': 516.1}, ['INF', 51.61]], ['sampled case 2', {'birth': '2026-06-08', 'depart': '2028-06-06', 'fare': 952.7}, ['INF', 95.27]], ['sampled case 3', {'birth': '2017-05-05', 'depart': '2029-05-02', 'fare': 942.13}, ['CHD', 706.6]]], [['child day before 12th birthday', {'birth': '2016-05-13', 'depart': '2028-05-12', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 415.5}, ['ADT', 415.5]], ['infant turns two on travel day', {'birth': '2026-03-03', 'depart': '2028-03-03', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 303.0}, ['INF', 30.3]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-13', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-03', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2017-10-23', 'depart': '2029-10-19', 'fare': 1447.34}, ['CHD', 1085.51]], ['sampled case 2', {'birth': '2016-03-06', 'depart': '2028-02-28', 'fare': 1074.9}, ['CHD', 806.18]], ['sampled case 3', {'birth': '2015-06-23', 'depart': '2027-06-20', 'fare': 768.6}, ['CHD', 576.45]]], [['child day before 12th birthday', {'birth': '2016-05-14', 'depart': '2028-05-13', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 416.5}, ['ADT', 416.5]], ['infant turns two on travel day', {'birth': '2026-03-04', 'depart': '2028-03-04', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 304.0}, ['INF', 30.4]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-14', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-04', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2028-06-21', 'depart': '2029-08-22', 'fare': 642.31}, ['INF', 64.23]], ['sampled case 2', {'birth': '2019-06-26', 'depart': '2027-12-23', 'fare': 211.9}, ['CHD', 158.93]], ['sampled case 3', {'birth': '2025-09-18', 'depart': '2027-09-19', 'fare': 1456.7}, ['CHD', 1092.53]]], [['child day before 12th birthday', {'birth': '2016-05-15', 'depart': '2028-05-14', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 417.5}, ['ADT', 417.5]], ['infant turns two on travel day', {'birth': '2026-03-05', 'depart': '2028-03-05', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 305.0}, ['INF', 30.5]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-15', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-05', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2026-08-03', 'depart': '2028-07-31', 'fare': 265.0}, ['INF', 26.5]], ['sampled case 2', {'birth': '2026-08-19', 'depart': '2028-08-19', 'fare': 820.15}, ['CHD', 615.11]], ['sampled case 3', {'birth': '2017-09-28', 'depart': '2029-09-26', 'fare': 855.8}, ['CHD', 641.85]]]]
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
import datetime
import decimal
N = 1
observations = []
def solve(x):
    b = datetime.date.fromisoformat(x['birth'])
    d = datetime.date.fromisoformat(x['depart'])
    try:
        bday = b.replace(year=d.year)
    except ValueError:
        bday = datetime.date(d.year, 3, 1)
    age = d.year - b.year - (1 if d < bday else 0)
    if age < 2: ptc, pct = 'INF', 10
    elif age < 12: ptc, pct = 'CHD', 75
    else: ptc, pct = 'ADT', 100
    amt = decimal.Decimal(str(round(x['fare'] * pct / 100, 2)))
    return [ptc, float(amt)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['child day before 12th birthday', {'birth': '2016-05-11', 'depart': '2028-05-10', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 413.5}, ['ADT', 413.5]], ['infant turns two on travel day', {'birth': '2026-03-01', 'depart': '2028-03-01', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 301.0}, ['INF', 30.1]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-11', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-01', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2015-02-22', 'depart': '2027-02-15', 'fare': 171.9}, ['CHD', 128.93]], ['sampled case 2', {'birth': '2023-11-19', 'depart': '2029-03-25', 'fare': 1444.58}, ['CHD', 1083.44]], ['sampled case 3', {'birth': '2027-08-22', 'depart': '2029-08-21', 'fare': 608.88}, ['INF', 60.89]]], [['child day before 12th birthday', {'birth': '2016-05-12', 'depart': '2028-05-11', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 414.5}, ['ADT', 414.5]], ['infant turns two on travel day', {'birth': '2026-03-02', 'depart': '2028-03-02', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 302.0}, ['INF', 30.2]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-12', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-02', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2025-04-03', 'depart': '2027-04-02', 'fare': 516.1}, ['INF', 51.61]], ['sampled case 2', {'birth': '2026-06-08', 'depart': '2028-06-06', 'fare': 952.7}, ['INF', 95.27]], ['sampled case 3', {'birth': '2017-05-05', 'depart': '2029-05-02', 'fare': 942.13}, ['CHD', 706.6]]], [['child day before 12th birthday', {'birth': '2016-05-13', 'depart': '2028-05-12', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 415.5}, ['ADT', 415.5]], ['infant turns two on travel day', {'birth': '2026-03-03', 'depart': '2028-03-03', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 303.0}, ['INF', 30.3]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-13', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-03', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2017-10-23', 'depart': '2029-10-19', 'fare': 1447.34}, ['CHD', 1085.51]], ['sampled case 2', {'birth': '2016-03-06', 'depart': '2028-02-28', 'fare': 1074.9}, ['CHD', 806.18]], ['sampled case 3', {'birth': '2015-06-23', 'depart': '2027-06-20', 'fare': 768.6}, ['CHD', 576.45]]], [['child day before 12th birthday', {'birth': '2016-05-14', 'depart': '2028-05-13', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 416.5}, ['ADT', 416.5]], ['infant turns two on travel day', {'birth': '2026-03-04', 'depart': '2028-03-04', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 304.0}, ['INF', 30.4]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-14', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-04', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2028-06-21', 'depart': '2029-08-22', 'fare': 642.31}, ['INF', 64.23]], ['sampled case 2', {'birth': '2019-06-26', 'depart': '2027-12-23', 'fare': 211.9}, ['CHD', 158.93]], ['sampled case 3', {'birth': '2025-09-18', 'depart': '2027-09-19', 'fare': 1456.7}, ['CHD', 1092.53]]], [['child day before 12th birthday', {'birth': '2016-05-15', 'depart': '2028-05-14', 'fare': 412.5}, ['CHD', 309.38]], ['12th birthday on departure', {'birth': '2016-05-10', 'depart': '2028-05-10', 'fare': 417.5}, ['ADT', 417.5]], ['infant turns two on travel day', {'birth': '2026-03-05', 'depart': '2028-03-05', 'fare': 399.9}, ['CHD', 299.93]], ['infant one day before second birthday', {'birth': '2026-03-15', 'depart': '2028-03-14', 'fare': 250.05}, ['INF', 25.01]], ['leap day birthday on Feb 28', {'birth': '2016-02-29', 'depart': '2028-02-28', 'fare': 300.0}, ['CHD', 225.0]], ['leap day infant in non-leap year', {'birth': '2024-02-29', 'depart': '2026-02-28', 'fare': 305.0}, ['INF', 30.5]], ['leap day infant on 1 March', {'birth': '2024-02-29', 'depart': '2026-03-01', 'fare': 310.0}, ['CHD', 232.5]], ['half-cent child fare', {'birth': '2020-07-01', 'depart': '2027-01-15', 'fare': 100.1}, ['CHD', 75.08]], ['adult later in year', {'birth': '1990-11-30', 'depart': '2027-06-05', 'fare': 823.33}, ['ADT', 823.33]], ['sampled case 1', {'birth': '2026-08-03', 'depart': '2028-07-31', 'fare': 265.0}, ['INF', 26.5]], ['sampled case 2', {'birth': '2026-08-19', 'depart': '2028-08-19', 'fare': 820.15}, ['CHD', 615.11]], ['sampled case 3', {'birth': '2017-09-28', 'depart': '2029-09-26', 'fare': 855.8}, ['CHD', 641.85]]]]
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 child fare of 75.075 is quoted as 75.07 instead of 75.08.

Input {'birth','depart' ISO dates,'fare'}. Age is completed years on the departure date; a 29 February birthday falls on 1 March in non-leap years. Under 2 -> INF 10%; 2 to 11 -> CHD 75%; otherwise ADT 100%. Amount = fare*pct/100 rounded half-up to cents. Return [ptc, amount].

split: open-access


prompt:
A routing exactly 5% over MPM is charged a 10M surcharge.

Input {'tpm':[segment miles],'tpd':deduction miles,'mpm'}. Total = sum(TPM) - TPD. Total <= MPM -> ['M',0]; else the smallest band b in 5,10,15,20,25 with total <= MPM*(1+b/100) -> ['bM', b]; beyond 25% -> 'ERR_EXCEEDS'. Comparisons are exact integer arithmetic.

split: open-access


prompt:
A routing 5.1% over MPM is charged only the 5M surcharge.

Input {'tpm':[segment miles],'tpd':deduction miles,'mpm'}. Total = sum(TPM) - TPD. Total <= MPM -> ['M',0]; else the smallest band b in 5,10,15,20,25 with total <= MPM*(1+b/100) -> ['bM', b]; beyond 25% -> 'ERR_EXCEEDS'. Comparisons are exact integer arithmetic.

split: open-access


prompt:
Routings entitled to a mileage deduction are surcharged more heavily.

Input {'tpm':[segment miles],'tpd':deduction miles,'mpm'}. Total = sum(TPM) - TPD. Total <= MPM -> ['M',0]; else the smallest band b in 5,10,15,20,25 with total <= MPM*(1+b/100) -> ['bM', b]; beyond 25% -> 'ERR_EXCEEDS'. Comparisons are exact integer arithmetic.

split: open-access


prompt:
A routing 40% over MPM is sold with a 25M surcharge instead of being rejected.

Input {'tpm':[segment miles],'tpd':deduction miles,'mpm'}. Total = sum(TPM) - TPD. Total <= MPM -> ['M',0]; else the smallest band b in 5,10,15,20,25 with total <= MPM*(1+b/100) -> ['bM', b]; beyond 25% -> 'ERR_EXCEEDS'. Comparisons are exact integer arithmetic.

split: open-access


prompt:
Routings 1-5% over MPM are charged a 10M surcharge.

Input {'tpm':[segment miles],'tpd':deduction miles,'mpm'}. Total = sum(TPM) - TPD. Total <= MPM -> ['M',0]; else the smallest band b in 5,10,15,20,25 with total <= MPM*(1+b/100) -> ['bM', b]; beyond 25% -> 'ERR_EXCEEDS'. Comparisons are exact integer arithmetic.

split: open-access


prompt:
A round trip is quoted with an expensive RT fare although two cheap one-way fares are open.

Input {'fares':[[basis, amount, rbd, min AP days, 'OW'|'RT']],'trip','ap_days','rbd_open'}. A fare applies if its AP requirement <= ap_days and its booking class is open. OW trips use OW fares only; RT trips use an RT fare or two of the same OW fare. Pick the lowest total; ties prefer the booking class earlier in 'YBMHQVLKTN'. Return [[bases], total] or 'NO_FARE'.

split: open-access


prompt:
A 7-day advance purchase fare is not offered to a customer booking exactly seven days ahead.

Input {'fares':[[basis, amount, rbd, min AP days, 'OW'|'RT']],'trip','ap_days','rbd_open'}. A fare applies if its AP requirement <= ap_days and its booking class is open. OW trips use OW fares only; RT trips use an RT fare or two of the same OW fare. Pick the lowest total; ties prefer the booking class earlier in 'YBMHQVLKTN'. Return [[bases], total] or 'NO_FARE'.

split: open-access


prompt:
The lowest quote uses a class with no seats left.

Input {'fares':[[basis, amount, rbd, min AP days, 'OW'|'RT']],'trip','ap_days','rbd_open'}. A fare applies if its AP requirement <= ap_days and its booking class is open. OW trips use OW fares only; RT trips use an RT fare or two of the same OW fare. Pick the lowest total; ties prefer the booking class earlier in 'YBMHQVLKTN'. Return [[bases], total] or 'NO_FARE'.

split: open-access


prompt:
Two fares with the same price produce the one filed first rather than the higher class.

Input {'fares':[[basis, amount, rbd, min AP days, 'OW'|'RT']],'trip','ap_days','rbd_open'}. A fare applies if its AP requirement <= ap_days and its booking class is open. OW trips use OW fares only; RT trips use an RT fare or two of the same OW fare. Pick the lowest total; ties prefer the booking class earlier in 'YBMHQVLKTN'. Return [[bases], total] or 'NO_FARE'.

split: open-access


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

N = 1
observations = []
def solve(x):
    ap = x['ap_days']
    open_ = set(x['rbd_open'])
    order = 'YBMHQVLKTN'
    ok = [f for f in x['fares'] if f[3] <= ap and f[2] in open_]
    opts = []
    for basis, amt, rbd, minap, kind in ok:
        if x['trip'] == 'OW' and kind == 'RT':
            opts.append((amt / 2, order.index(rbd), [basis]))
        if x['trip'] == 'OW' and kind == 'OW':
            opts.append((amt, order.index(rbd), [basis]))
        if x['trip'] == 'RT' and kind == 'RT':
            opts.append((amt, order.index(rbd), [basis]))
        if x['trip'] == 'RT' and kind == 'OW':
            opts.append((2 * amt, order.index(rbd), [basis, basis]))
    if not opts: return 'NO_FARE'
    opts.sort(key=lambda o: (o[0], o[1]))
    return [opts[0][2], opts[0][0]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 15, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 11, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['BOW0', 1090, 'B', 3, 'OW'], ['TRT1', 1190, 'T', 7, 'RT'], ['TRT2', 570, 'T', 0, 'RT'], ['MOW3', 1370, 'M', 3, 'OW']], 'trip': 'RT', 'ap_days': 0, 'rbd_open': ['B', 'H', 'K', 'L', 'M', 'N', 'T', 'Y']}, [['TRT2'], 570]], ['sampled case 2', {'fares': [['TRT0', 970, 'T', 0, 'RT'], ['TOW1', 780, 'T', 3, 'OW'], ['LRT2', 800, 'L', 7, 'RT'], ['VRT3', 1290, 'V', 14, 'RT'], ['BOW4', 1450, 'B', 21, 'OW']], 'trip': 'OW', 'ap_days': 30, 'rbd_open': ['Y']}, 'NO_FARE'], ['sampled case 3', {'fares': [['KRT0', 550, 'K', 3, 'RT'], ['HRT1', 1290, 'H', 3, 'RT'], ['TOW2', 1300, 'T', 7, 'OW'], ['MOW3', 480, 'M', 21, 'OW']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['B', 'H', 'M', 'T', 'Y']}, [['TOW2'], 1300]]], [['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 16, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 12, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['NOW0', 1290, 'N', 0, 'OW'], ['YRT1', 1250, 'Y', 0, 'RT'], ['LOW2', 190, 'L', 7, 'OW']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['K', 'T']}, 'NO_FARE'], ['sampled case 2', {'fares': [['TRT0', 1050, 'T', 3, 'RT'], ['KOW1', 890, 'K', 21, 'OW'], ['TOW2', 1070, 'T', 3, 'OW'], ['HOW3', 880, 'H', 14, 'OW'], ['VOW4', 480, 'V', 0, 'OW']], 'trip': 'RT', 'ap_days': 3, 'rbd_open': ['B', 'H', 'K', 'L', 'N', 'Q', 'V', 'Y']}, [['VOW4', 'VOW4'], 960]], ['sampled case 3', {'fares': [['QOW0', 1370, 'Q', 14, 'OW'], ['HRT1', 320, 'H', 3, 'RT'], ['BOW2', 860, 'B', 21, 'OW'], ['LRT3', 1490, 'L', 3, 'RT'], ['LOW4', 1320, 'L', 0, 'OW']], 'trip': 'RT', 'ap_days': 3, 'rbd_open': ['H', 'K', 'L', 'M', 'N', 'Q', 'T', 'V', 'Y']}, [['HRT1'], 320]]], [['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 17, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 13, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['KOW0', 1090, 'K', 21, 'OW'], ['YRT1', 1120, 'Y', 14, 'RT'], ['YOW2', 200, 'Y', 14, 'OW'], ['TOW3', 770, 'T', 3, 'OW'], ['QRT4', 600, 'Q', 3, 'RT'], ['MOW5', 360, 'M', 0, 'OW']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['K', 'L', 'M', 'Q', 'T']}, [['QRT4'], 600]], ['sampled case 2', {'fares': [['QOW0', 280, 'Q', 21, 'OW'], ['TRT1', 1200, 'T', 3, 'RT'], ['MOW2', 110, 'M', 14, 'OW']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['H']}, 'NO_FARE'], ['sampled case 3', {'fares': [['YRT0', 1040, 'Y', 0, 'RT'], ['HRT1', 1310, 'H', 14, 'RT'], ['QRT2', 450, 'Q', 3, 'RT'], ['BOW3', 1430, 'B', 0, 'OW'], ['BRT4', 760, 'B', 3, 'RT']], 'trip': 'OW', 'ap_days': 14, 'rbd_open': ['B', 'H', 'M', 'V', 'Y']}, [['BOW3'], 1430]]], [['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 18, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 14, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['NRT0', 450, 'N', 21, 'RT'], ['KOW1', 1370, 'K', 21, 'OW'], ['KOW2', 1250, 'K', 21, 'OW'], ['LOW3', 610, 'L', 0, 'OW'], ['NOW4', 1400, 'N', 7, 'OW']], 'trip': 'RT', 'ap_days': 10, 'rbd_open': ['B', 'M', 'N', 'Q', 'V', 'Y']}, [['NOW4', 'NOW4'], 2800]], ['sampled case 2', {'fares': [['BRT0', 1180, 'B', 0, 'RT'], ['LOW1', 850, 'L', 7, 'OW'], ['MRT2', 120, 'M', 3, 'RT']], 'trip': 'RT', 'ap_days': 3, 'rbd_open': ['H', 'M', 'N', 'V', 'Y']}, [['MRT2'], 120]], ['sampled case 3', {'fares': [['NOW0', 1490, 'N', 7, 'OW'], ['QRT1', 590, 'Q', 7, 'RT'], ['KOW2', 580, 'K', 14, 'OW']], 'trip': 'OW', 'ap_days': 3, 'rbd_open': ['H', 'L', 'M', 'N', 'Q', 'T', 'V', 'Y']}, 'NO_FARE']], [['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 19, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 15, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['KOW0', 390, 'K', 3, 'OW'], ['QOW1', 520, 'Q', 3, 'OW'], ['HRT2', 930, 'H', 0, 'RT'], ['YOW3', 280, 'Y', 14, 'OW']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Q', 'T']}, [['QOW1', 'QOW1'], 1040]], ['sampled case 2', {'fares': [['HOW0', 550, 'H', 14, 'OW'], ['TOW1', 1070, 'T', 3, 'OW'], ['MRT2', 770, 'M', 0, 'RT'], ['BRT3', 290, 'B', 14, 'RT']], 'trip': 'OW', 'ap_days': 10, 'rbd_open': ['B']}, 'NO_FARE'], ['sampled case 3', {'fares': [['KOW0', 800, 'K', 21, 'OW'], ['NOW1', 1390, 'N', 21, 'OW'], ['VOW2', 780, 'V', 21, 'OW'], ['YOW3', 200, 'Y', 0, 'OW']], 'trip': 'RT', 'ap_days': 3, 'rbd_open': ['H', 'L', 'Q', 'V', 'Y']}, [['YOW3', 'YOW3'], 400]]]]
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):
    ap = x['ap_days']
    open_ = set(x['rbd_open'])
    order = 'YBMHQVLKTN'
    ok = [f for f in x['fares'] if f[3] <= ap and f[2] in open_]
    opts = []
    for basis, amt, rbd, minap, kind in ok:
        if x['trip'] == 'OW' and kind == 'RT':
            opts.append((amt, order.index(rbd), [basis]))
        if x['trip'] == 'OW' and kind == 'OW':
            opts.append((amt, order.index(rbd), [basis]))
        if x['trip'] == 'RT' and kind == 'RT':
            opts.append((amt, order.index(rbd), [basis]))
        if x['trip'] == 'RT' and kind == 'OW':
            opts.append((2 * amt, order.index(rbd), [basis, basis]))
    if not opts: return 'NO_FARE'
    opts.sort(key=lambda o: (o[0], o[1]))
    return [opts[0][2], opts[0][0]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 15, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 11, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['BOW0', 1090, 'B', 3, 'OW'], ['TRT1', 1190, 'T', 7, 'RT'], ['TRT2', 570, 'T', 0, 'RT'], ['MOW3', 1370, 'M', 3, 'OW']], 'trip': 'RT', 'ap_days': 0, 'rbd_open': ['B', 'H', 'K', 'L', 'M', 'N', 'T', 'Y']}, [['TRT2'], 570]], ['sampled case 2', {'fares': [['TRT0', 970, 'T', 0, 'RT'], ['TOW1', 780, 'T', 3, 'OW'], ['LRT2', 800, 'L', 7, 'RT'], ['VRT3', 1290, 'V', 14, 'RT'], ['BOW4', 1450, 'B', 21, 'OW']], 'trip': 'OW', 'ap_days': 30, 'rbd_open': ['Y']}, 'NO_FARE'], ['sampled case 3', {'fares': [['KRT0', 550, 'K', 3, 'RT'], ['HRT1', 1290, 'H', 3, 'RT'], ['TOW2', 1300, 'T', 7, 'OW'], ['MOW3', 480, 'M', 21, 'OW']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['B', 'H', 'M', 'T', 'Y']}, [['TOW2'], 1300]]], [['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 16, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 12, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['NOW0', 1290, 'N', 0, 'OW'], ['YRT1', 1250, 'Y', 0, 'RT'], ['LOW2', 190, 'L', 7, 'OW']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['K', 'T']}, 'NO_FARE'], ['sampled case 2', {'fares': [['TRT0', 1050, 'T', 3, 'RT'], ['KOW1', 890, 'K', 21, 'OW'], ['TOW2', 1070, 'T', 3, 'OW'], ['HOW3', 880, 'H', 14, 'OW'], ['VOW4', 480, 'V', 0, 'OW']], 'trip': 'RT', 'ap_days': 3, 'rbd_open': ['B', 'H', 'K', 'L', 'N', 'Q', 'V', 'Y']}, [['VOW4', 'VOW4'], 960]], ['sampled case 3', {'fares': [['QOW0', 1370, 'Q', 14, 'OW'], ['HRT1', 320, 'H', 3, 'RT'], ['BOW2', 860, 'B', 21, 'OW'], ['LRT3', 1490, 'L', 3, 'RT'], ['LOW4', 1320, 'L', 0, 'OW']], 'trip': 'RT', 'ap_days': 3, 'rbd_open': ['H', 'K', 'L', 'M', 'N', 'Q', 'T', 'V', 'Y']}, [['HRT1'], 320]]], [['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 17, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 13, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['KOW0', 1090, 'K', 21, 'OW'], ['YRT1', 1120, 'Y', 14, 'RT'], ['YOW2', 200, 'Y', 14, 'OW'], ['TOW3', 770, 'T', 3, 'OW'], ['QRT4', 600, 'Q', 3, 'RT'], ['MOW5', 360, 'M', 0, 'OW']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['K', 'L', 'M', 'Q', 'T']}, [['QRT4'], 600]], ['sampled case 2', {'fares': [['QOW0', 280, 'Q', 21, 'OW'], ['TRT1', 1200, 'T', 3, 'RT'], ['MOW2', 110, 'M', 14, 'OW']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['H']}, 'NO_FARE'], ['sampled case 3', {'fares': [['YRT0', 1040, 'Y', 0, 'RT'], ['HRT1', 1310, 'H', 14, 'RT'], ['QRT2', 450, 'Q', 3, 'RT'], ['BOW3', 1430, 'B', 0, 'OW'], ['BRT4', 760, 'B', 3, 'RT']], 'trip': 'OW', 'ap_days': 14, 'rbd_open': ['B', 'H', 'M', 'V', 'Y']}, [['BOW3'], 1430]]], [['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 18, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 14, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['NRT0', 450, 'N', 21, 'RT'], ['KOW1', 1370, 'K', 21, 'OW'], ['KOW2', 1250, 'K', 21, 'OW'], ['LOW3', 610, 'L', 0, 'OW'], ['NOW4', 1400, 'N', 7, 'OW']], 'trip': 'RT', 'ap_days': 10, 'rbd_open': ['B', 'M', 'N', 'Q', 'V', 'Y']}, [['NOW4', 'NOW4'], 2800]], ['sampled case 2', {'fares': [['BRT0', 1180, 'B', 0, 'RT'], ['LOW1', 850, 'L', 7, 'OW'], ['MRT2', 120, 'M', 3, 'RT']], 'trip': 'RT', 'ap_days': 3, 'rbd_open': ['H', 'M', 'N', 'V', 'Y']}, [['MRT2'], 120]], ['sampled case 3', {'fares': [['NOW0', 1490, 'N', 7, 'OW'], ['QRT1', 590, 'Q', 7, 'RT'], ['KOW2', 580, 'K', 14, 'OW']], 'trip': 'OW', 'ap_days': 3, 'rbd_open': ['H', 'L', 'M', 'N', 'Q', 'T', 'V', 'Y']}, 'NO_FARE']], [['RT beats doubled OW', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 19, 'rbd_open': ['Y', 'B', 'M', 'H', 'Q', 'V', 'L', 'K', 'T']}, [['VOW7', 'VOW7'], 640]], ['doubled OW beats RT', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'M', 'V', 'H']}, [['VOW7', 'VOW7'], 640]], ['exactly AP days', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 7, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['VOW7'], 320]], ['one day short of AP', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 6, 'rbd_open': ['Y', 'B', 'V', 'H']}, [['HOW3'], 390]], ['closed cheap class', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 15, 'rbd_open': ['Y', 'B', 'H']}, [['HOW3'], 390]], ['price tie between classes', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'RT', 'ap_days': 30, 'rbd_open': ['Y', 'B', 'M', 'K', 'L']}, [['LRT21'], 640]], ['nothing sellable', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 1, 'rbd_open': ['Q', 'L', 'K']}, 'NO_FARE'], ['OW trip ignores RT fares', {'fares': [['YOW', 900, 'Y', 0, 'OW'], ['BOW', 610, 'B', 0, 'OW'], ['QRT14', 780, 'Q', 14, 'RT'], ['MRT', 1150, 'M', 0, 'RT'], ['VOW7', 320, 'V', 7, 'OW'], ['LRT21', 640, 'L', 21, 'RT'], ['HOW3', 390, 'H', 3, 'OW'], ['KRT7', 640, 'K', 7, 'RT']], 'trip': 'OW', 'ap_days': 21, 'rbd_open': ['Y', 'Q', 'L', 'K']}, [['YOW'], 900]], ['sampled case 1', {'fares': [['KOW0', 390, 'K', 3, 'OW'], ['QOW1', 520, 'Q', 3, 'OW'], ['HRT2', 930, 'H', 0, 'RT'], ['YOW3', 280, 'Y', 14, 'OW']], 'trip': 'RT', 'ap_days': 7, 'rbd_open': ['Q', 'T']}, [['QOW1', 'QOW1'], 1040]], ['sampled case 2', {'fares': [['HOW0', 550, 'H', 14, 'OW'], ['TOW1', 1070, 'T', 3, 'OW'], ['MRT2', 770, 'M', 0, 'RT'], ['BRT3', 290, 'B', 14, 'RT']], 'trip': 'OW', 'ap_days': 10, 'rbd_open': ['B']}, 'NO_FARE'], ['sampled case 3', {'fares': [['KOW0', 800, 'K', 21, 'OW'], ['NOW1', 1390, 'N', 21, 'OW'], ['VOW2', 780, 'V', 21, 'OW'], ['YOW3', 200, 'Y', 0, 'OW']], 'trip': 'RT', 'ap_days': 3, 'rbd_open': ['H', 'L', 'Q', 'V', 'Y']}, [['YOW3', 'YOW3'], 400]]]]
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:
One-way quotes undercut every published one-way fare.

Input {'fares':[[basis, amount, rbd, min AP days, 'OW'|'RT']],'trip','ap_days','rbd_open'}. A fare applies if its AP requirement <= ap_days and its booking class is open. OW trips use OW fares only; RT trips use an RT fare or two of the same OW fare. Pick the lowest total; ties prefer the booking class earlier in 'YBMHQVLKTN'. Return [[bases], total] or 'NO_FARE'.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import decimal
import math
N = 1
observations = []
def solve(x):
    units = {'USD': '1', 'EUR': '1', 'JPY': '100', 'KWD': '0.1', 'GBP': '1'}
    cur = x['currency']
    if cur not in units: return 'ERR_CURRENCY'
    nuc = sum(decimal.Decimal(str(c)) for c in x['nuc'])
    nuc = nuc.quantize(decimal.Decimal('0.01'), rounding=decimal.ROUND_HALF_UP)
    local = nuc * decimal.Decimal(str(x['roe']))
    u = decimal.Decimal(units[cur])
    local = (local / u).to_integral_value(rounding=decimal.ROUND_CEILING) * u
    return [str(nuc), str(local)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['USD two components', {'nuc': [412.357, 388.25], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.336, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [100.0], 'roe': 1.1, 'currency': 'USD'}, ['100.00', '110']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [803.18, 217.556], 'roe': 82.0232, 'currency': 'EUR'}, ['1020.73', '83724']], ['sampled case 2', {'nuc': [103.64], 'roe': 139.908192, 'currency': 'JPY'}, ['103.64', '14600']], ['sampled case 3', {'nuc': [310.5398, 792.913, 638.67], 'roe': 101.8, 'currency': 'EUR'}, ['1742.12', '177348']]], [['USD two components', {'nuc': [412.357, 388.25100000000003], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.33700000000002, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [200.0], 'roe': 1.1, 'currency': 'USD'}, ['200.00', '220']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [563.46, 751.68, 255.98, 518.496], 'roe': 85.8739, 'currency': 'KWD'}, ['2089.61', '179443.0']], ['sampled case 2', {'nuc': [209.16, 92.65, 665.5938], 'roe': 70.378988, 'currency': 'KWD'}, ['967.40', '68084.7']], ['sampled case 3', {'nuc': [239.23, 415.82, 554.5256, 886.394], 'roe': 150.32, 'currency': 'GBP'}, ['2095.96', '315065']]], [['USD two components', {'nuc': [412.357, 388.252], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.338, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [400.0], 'roe': 1.1, 'currency': 'USD'}, ['400.00', '440']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [522.92, 637.956, 224.95, 711.2788], 'roe': 128.068436, 'currency': 'KWD'}, ['2097.10', '268572.4']], ['sampled case 2', {'nuc': [144.652, 317.07, 333.8817, 156.6471], 'roe': 11.54, 'currency': 'EUR'}, ['952.25', '10989']], ['sampled case 3', {'nuc': [727.197], 'roe': 115.954461, 'currency': 'EUR'}, ['727.19', '84321']]], [['USD two components', {'nuc': [412.357, 388.25300000000004], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.339, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [700.0], 'roe': 1.1, 'currency': 'USD'}, ['700.00', '770']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [367.07, 59.422, 404.75, 654.184], 'roe': 8.8773, 'currency': 'KWD'}, ['1485.42', '13186.6']], ['sampled case 2', {'nuc': [244.923, 449.2429, 688.15, 857.76], 'roe': 23.061535, 'currency': 'JPY'}, ['2240.07', '51700']], ['sampled case 3', {'nuc': [354.514, 161.36], 'roe': 58.707806, 'currency': 'KWD'}, ['515.87', '30285.6']]], [['USD two components', {'nuc': [412.357, 388.254], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.34, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [800.0], 'roe': 1.1, 'currency': 'USD'}, ['800.00', '880']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [58.672], 'roe': 29.040403, 'currency': 'USD'}, ['58.67', '1704']], ['sampled case 2', {'nuc': [303.792, 254.01, 298.5418], 'roe': 12.68, 'currency': 'GBP'}, ['856.34', '10859']], ['sampled case 3', {'nuc': [709.048], 'roe': 90.68, 'currency': 'EUR'}, ['709.04', '64296']]]]
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 decimal
import math
N = 1
observations = []
def solve(x):
    units = {'USD': '1', 'EUR': '1', 'JPY': '100', 'KWD': '0.1', 'GBP': '1'}
    cur = x['currency']
    if cur not in units: return 'ERR_CURRENCY'
    nuc = sum(decimal.Decimal(str(c)) for c in x['nuc'])
    nuc = nuc.quantize(decimal.Decimal('0.1'), rounding=decimal.ROUND_DOWN)
    local = nuc * decimal.Decimal(str(x['roe']))
    u = decimal.Decimal(units[cur])
    local = (local / u).to_integral_value(rounding=decimal.ROUND_CEILING) * u
    return [str(nuc), str(local)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['USD two components', {'nuc': [412.357, 388.25], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.336, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [100.0], 'roe': 1.1, 'currency': 'USD'}, ['100.00', '110']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [803.18, 217.556], 'roe': 82.0232, 'currency': 'EUR'}, ['1020.73', '83724']], ['sampled case 2', {'nuc': [103.64], 'roe': 139.908192, 'currency': 'JPY'}, ['103.64', '14600']], ['sampled case 3', {'nuc': [310.5398, 792.913, 638.67], 'roe': 101.8, 'currency': 'EUR'}, ['1742.12', '177348']]], [['USD two components', {'nuc': [412.357, 388.25100000000003], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.33700000000002, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [200.0], 'roe': 1.1, 'currency': 'USD'}, ['200.00', '220']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [563.46, 751.68, 255.98, 518.496], 'roe': 85.8739, 'currency': 'KWD'}, ['2089.61', '179443.0']], ['sampled case 2', {'nuc': [209.16, 92.65, 665.5938], 'roe': 70.378988, 'currency': 'KWD'}, ['967.40', '68084.7']], ['sampled case 3', {'nuc': [239.23, 415.82, 554.5256, 886.394], 'roe': 150.32, 'currency': 'GBP'}, ['2095.96', '315065']]], [['USD two components', {'nuc': [412.357, 388.252], 'roe': 1.0, 'currency': 'USD'}, ['800.60', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.338, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [400.0], 'roe': 1.1, 'currency': 'USD'}, ['400.00', '440']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [522.92, 637.956, 224.95, 711.2788], 'roe': 128.068436, 'currency': 'KWD'}, ['2097.10', '268572.4']], ['sampled case 2', {'nuc': [144.652, 317.07, 333.8817, 156.6471], 'roe': 11.54, 'currency': 'EUR'}, ['952.25', '10989']], ['sampled case 3', {'nuc': [727.197], 'roe': 115.954461, 'currency': 'EUR'}, ['727.19', '84321']]], [['USD two components', {'nuc': [412.357, 388.25300000000004], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.339, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [700.0], 'roe': 1.1, 'currency': 'USD'}, ['700.00', '770']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [367.07, 59.422, 404.75, 654.184], 'roe': 8.8773, 'currency': 'KWD'}, ['1485.42', '13186.6']], ['sampled case 2', {'nuc': [244.923, 449.2429, 688.15, 857.76], 'roe': 23.061535, 'currency': 'JPY'}, ['2240.07', '51700']], ['sampled case 3', {'nuc': [354.514, 161.36], 'roe': 58.707806, 'currency': 'KWD'}, ['515.87', '30285.6']]], [['USD two components', {'nuc': [412.357, 388.254], 'roe': 1.0, 'currency': 'USD'}, ['800.61', '801']], ['JPY hundreds', {'nuc': [512.12, 97.555], 'roe': 148.34, 'currency': 'JPY'}, ['609.67', '90500']], ['KWD tenths', {'nuc': [700.009, 100.0], 'roe': 0.30712, 'currency': 'KWD'}, ['800.00', '245.7']], ['exact local amount', {'nuc': [250.0, 250.0], 'roe': 0.92, 'currency': 'EUR'}, ['500.00', '460']], ['float product trap', {'nuc': [800.0], 'roe': 1.1, 'currency': 'USD'}, ['800.00', '880']], ['unsupported currency', {'nuc': [100.0], 'roe': 3.67, 'currency': 'AED'}, 'ERR_CURRENCY'], ['sum crosses a cent', {'nuc': [100.005, 200.006], 'roe': 0.788341, 'currency': 'GBP'}, ['300.01', '237']], ['sampled case 1', {'nuc': [58.672], 'roe': 29.040403, 'currency': 'USD'}, ['58.67', '1704']], ['sampled case 2', {'nuc': [303.792, 254.01, 298.5418], 'roe': 12.68, 'currency': 'GBP'}, ['856.34', '10859']], ['sampled case 3', {'nuc': [709.048], 'roe': 90.68, 'currency': 'EUR'}, ['709.04', '64296']]]]
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:
The NUC total on the fare calculation line is a cent higher than the component sum allows.

Input {'nuc':[component amounts],'roe','currency'}. Sum components exactly, truncate the NUC total to 2 decimals, multiply by ROE, and round UP to the currency unit (USD/EUR/GBP 1, JPY 100, KWD 0.1) in exact decimal arithmetic; other currencies -> 'ERR_CURRENCY'. Return [NUC string, local string].

split: open-access