broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import calendar
N = 1
observations = []
def solve(x):
    d = datetime.date.fromisoformat(x['depart'])
    r = datetime.date.fromisoformat(x['return'])
    rule = x['rule']
    fails = []
    if rule['sat_night']:
        sun = d + datetime.timedelta(days=(5 - d.weekday()) % 7 + 1)
        if r < sun: fails.append('SAT')
    if (r - d).days <= rule['min_days']: fails.append('MIN')
    mo = d.month - 1 + rule['max_months']
    y, mo = d.year + mo // 12, mo % 12 + 1
    last = calendar.monthrange(y, mo)[1]
    eom = d.day == calendar.monthrange(d.year, d.month)[1]
    lim = datetime.date(y, mo, last if eom else min(d.day, last))
    if r > lim: fails.append('MAX')
    return fails
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-08', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-11', 'return': '2028-01-10', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-14', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-08-19', 'return': '2029-08-28', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, []], ['sampled case 2', {'depart': '2028-06-13', 'return': '2028-12-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['sampled case 3', {'depart': '2028-04-16', 'return': '2028-08-20', 'rule': {'sat_night': False, 'min_days': 1, 'max_months': 1}}, ['MAX']], ['regression: minimum stay comparison', {'depart': '2027-01-26', 'return': '2027-02-01', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 3}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-09', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-12', 'return': '2028-01-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-15', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-07-11', 'return': '2029-07-23', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 12}}, []], ['sampled case 2', {'depart': '2029-06-25', 'return': '2029-12-12', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, ['MAX']], ['sampled case 3', {'depart': '2029-02-02', 'return': '2030-02-22', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, ['MAX']], ['regression: minimum stay comparison', {'depart': '2027-01-22', 'return': '2027-01-24', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 3}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-10', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-29', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-29', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-13', 'return': '2028-01-14', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-16', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-10-05', 'return': '2027-10-14', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 6}}, []], ['sampled case 2', {'depart': '2028-04-06', 'return': '2028-10-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-11-12', 'return': '2027-11-21', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 2}}, []], ['regression: minimum stay comparison', {'depart': '2027-10-11', 'return': '2027-10-17', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 3}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-11', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-14', 'return': '2028-01-16', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-17', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-06-01', 'return': '2027-06-09', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 1}}, []], ['sampled case 2', {'depart': '2028-03-04', 'return': '2028-06-07', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, []], ['sampled case 3', {'depart': '2029-03-17', 'return': '2029-03-25', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['regression: minimum stay comparison', {'depart': '2027-08-23', 'return': '2027-08-29', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 2}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-12', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-15', 'return': '2028-01-18', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-18', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2029-08-05', 'return': '2030-07-02', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 11}}, []], ['sampled case 2', {'depart': '2028-05-10', 'return': '2028-05-12', 'rule': {'sat_night': False, 'min_days': 2, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-09-03', 'return': '2027-09-03', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 6}}, ['SAT']], ['regression: minimum stay comparison', {'depart': '2027-09-05', 'return': '2027-09-11', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 6}}, ['SAT', 'MIN']]]]
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 calendar
N = 1
observations = []
def solve(x):
    d = datetime.date.fromisoformat(x['depart'])
    r = datetime.date.fromisoformat(x['return'])
    rule = x['rule']
    fails = []
    if rule['sat_night']:
        sun = d + datetime.timedelta(days=(5 - d.weekday()) % 7 + 1)
        if r < sun: fails.append('SAT')
    if (r - d).days + 1 < rule['min_days']: fails.append('MIN')
    mo = d.month - 1 + rule['max_months']
    y, mo = d.year + mo // 12, mo % 12 + 1
    last = calendar.monthrange(y, mo)[1]
    eom = d.day == calendar.monthrange(d.year, d.month)[1]
    lim = datetime.date(y, mo, last if eom else min(d.day, last))
    if r > lim: fails.append('MAX')
    return fails
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-08', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-11', 'return': '2028-01-10', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-14', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-08-19', 'return': '2029-08-28', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, []], ['sampled case 2', {'depart': '2028-06-13', 'return': '2028-12-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['sampled case 3', {'depart': '2028-04-16', 'return': '2028-08-20', 'rule': {'sat_night': False, 'min_days': 1, 'max_months': 1}}, ['MAX']], ['regression: minimum stay comparison', {'depart': '2027-01-26', 'return': '2027-02-01', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 3}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-09', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-12', 'return': '2028-01-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-15', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-07-11', 'return': '2029-07-23', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 12}}, []], ['sampled case 2', {'depart': '2029-06-25', 'return': '2029-12-12', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, ['MAX']], ['sampled case 3', {'depart': '2029-02-02', 'return': '2030-02-22', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, ['MAX']], ['regression: minimum stay comparison', {'depart': '2027-01-22', 'return': '2027-01-24', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 3}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-10', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-29', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-29', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-13', 'return': '2028-01-14', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-16', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-10-05', 'return': '2027-10-14', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 6}}, []], ['sampled case 2', {'depart': '2028-04-06', 'return': '2028-10-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-11-12', 'return': '2027-11-21', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 2}}, []], ['regression: minimum stay comparison', {'depart': '2027-10-11', 'return': '2027-10-17', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 3}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-11', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-14', 'return': '2028-01-16', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-17', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-06-01', 'return': '2027-06-09', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 1}}, []], ['sampled case 2', {'depart': '2028-03-04', 'return': '2028-06-07', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, []], ['sampled case 3', {'depart': '2029-03-17', 'return': '2029-03-25', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['regression: minimum stay comparison', {'depart': '2027-08-23', 'return': '2027-08-29', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 2}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-12', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-15', 'return': '2028-01-18', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-18', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2029-08-05', 'return': '2030-07-02', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 11}}, []], ['sampled case 2', {'depart': '2028-05-10', 'return': '2028-05-12', 'rule': {'sat_night': False, 'min_days': 2, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-09-03', 'return': '2027-09-03', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 6}}, ['SAT']], ['regression: minimum stay comparison', {'depart': '2027-09-05', 'return': '2027-09-11', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 6}}, ['SAT', 'MIN']]]]
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 7-day minimum stay rejects a return exactly seven days after departure.

Input {'depart','return' ISO dates,'rule':{'sat_night','min_days','max_months'}}. Saturday-night rule: return on or after the Sunday following the first Saturday on or after departure. Min stay: return - depart >= min_days. Max stay: return <= departure date plus max_months calendar months; a month-end departure maps to the target month end, otherwise day clamps to month length. Return failed rule names in order SAT, MIN, MAX.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import calendar
N = 1
observations = []
def solve(x):
    d = datetime.date.fromisoformat(x['depart'])
    r = datetime.date.fromisoformat(x['return'])
    rule = x['rule']
    fails = []
    if 'sat_night' in rule:
        sun = d + datetime.timedelta(days=(5 - d.weekday()) % 7 + 1)
        if r < sun: fails.append('SAT')
    if (r - d).days < rule['min_days']: fails.append('MIN')
    mo = d.month - 1 + rule['max_months']
    y, mo = d.year + mo // 12, mo % 12 + 1
    last = calendar.monthrange(y, mo)[1]
    eom = d.day == calendar.monthrange(d.year, d.month)[1]
    lim = datetime.date(y, mo, last if eom else min(d.day, last))
    if r > lim: fails.append('MAX')
    return fails
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-08', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-11', 'return': '2028-01-10', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-14', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-08-19', 'return': '2029-08-28', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, []], ['sampled case 2', {'depart': '2028-06-13', 'return': '2028-12-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['sampled case 3', {'depart': '2028-04-16', 'return': '2028-08-20', 'rule': {'sat_night': False, 'min_days': 1, 'max_months': 1}}, ['MAX']], ['regression: Saturday rule applicability', {'depart': '2028-08-06', 'return': '2028-08-07', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 3}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-09', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-12', 'return': '2028-01-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-15', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-07-11', 'return': '2029-07-23', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 12}}, []], ['sampled case 2', {'depart': '2029-06-25', 'return': '2029-12-12', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, ['MAX']], ['sampled case 3', {'depart': '2029-02-02', 'return': '2030-02-22', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, ['MAX']], ['regression: Saturday rule applicability', {'depart': '2028-02-01', 'return': '2028-02-04', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 2}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-10', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-29', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-29', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-13', 'return': '2028-01-14', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-16', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-10-05', 'return': '2027-10-14', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 6}}, []], ['sampled case 2', {'depart': '2028-04-06', 'return': '2028-10-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-11-12', 'return': '2027-11-21', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 2}}, []], ['regression: Saturday rule applicability', {'depart': '2028-04-03', 'return': '2028-04-08', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 3}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-11', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-14', 'return': '2028-01-16', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-17', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-06-01', 'return': '2027-06-09', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 1}}, []], ['sampled case 2', {'depart': '2028-03-04', 'return': '2028-06-07', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, []], ['sampled case 3', {'depart': '2029-03-17', 'return': '2029-03-25', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['regression: Saturday rule applicability', {'depart': '2029-04-18', 'return': '2029-04-21', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 11}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-12', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-15', 'return': '2028-01-18', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-18', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2029-08-05', 'return': '2030-07-02', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 11}}, []], ['sampled case 2', {'depart': '2028-05-10', 'return': '2028-05-12', 'rule': {'sat_night': False, 'min_days': 2, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-09-03', 'return': '2027-09-03', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 6}}, ['SAT']]]]
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 calendar
N = 1
observations = []
def solve(x):
    d = datetime.date.fromisoformat(x['depart'])
    r = datetime.date.fromisoformat(x['return'])
    rule = x['rule']
    fails = []
    if rule['sat_night'] is not None:
        sun = d + datetime.timedelta(days=(5 - d.weekday()) % 7 + 1)
        if r < sun: fails.append('SAT')
    if (r - d).days < rule['min_days']: fails.append('MIN')
    mo = d.month - 1 + rule['max_months']
    y, mo = d.year + mo // 12, mo % 12 + 1
    last = calendar.monthrange(y, mo)[1]
    eom = d.day == calendar.monthrange(d.year, d.month)[1]
    lim = datetime.date(y, mo, last if eom else min(d.day, last))
    if r > lim: fails.append('MAX')
    return fails
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-08', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-11', 'return': '2028-01-10', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-14', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-08-19', 'return': '2029-08-28', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, []], ['sampled case 2', {'depart': '2028-06-13', 'return': '2028-12-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['sampled case 3', {'depart': '2028-04-16', 'return': '2028-08-20', 'rule': {'sat_night': False, 'min_days': 1, 'max_months': 1}}, ['MAX']], ['regression: Saturday rule applicability', {'depart': '2028-08-06', 'return': '2028-08-07', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 3}}, ['MIN']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-09', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-12', 'return': '2028-01-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-15', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-07-11', 'return': '2029-07-23', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 12}}, []], ['sampled case 2', {'depart': '2029-06-25', 'return': '2029-12-12', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, ['MAX']], ['sampled case 3', {'depart': '2029-02-02', 'return': '2030-02-22', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, ['MAX']], ['regression: Saturday rule applicability', {'depart': '2028-02-01', 'return': '2028-02-04', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 2}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-10', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-29', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-29', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-13', 'return': '2028-01-14', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-16', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-10-05', 'return': '2027-10-14', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 6}}, []], ['sampled case 2', {'depart': '2028-04-06', 'return': '2028-10-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-11-12', 'return': '2027-11-21', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 2}}, []], ['regression: Saturday rule applicability', {'depart': '2028-04-03', 'return': '2028-04-08', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 3}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-11', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-14', 'return': '2028-01-16', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-17', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-06-01', 'return': '2027-06-09', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 1}}, []], ['sampled case 2', {'depart': '2028-03-04', 'return': '2028-06-07', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, []], ['sampled case 3', {'depart': '2029-03-17', 'return': '2029-03-25', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['regression: Saturday rule applicability', {'depart': '2029-04-18', 'return': '2029-04-21', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 11}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-12', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-15', 'return': '2028-01-18', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-18', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2029-08-05', 'return': '2030-07-02', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 11}}, []], ['sampled case 2', {'depart': '2028-05-10', 'return': '2028-05-12', 'rule': {'sat_night': False, 'min_days': 2, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-09-03', 'return': '2027-09-03', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 6}}, ['SAT']]]]
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 whose rule explicitly sets sat_night to false still report SAT failures.

Input {'depart','return' ISO dates,'rule':{'sat_night','min_days','max_months'}}. Saturday-night rule: return on or after the Sunday following the first Saturday on or after departure. Min stay: return - depart >= min_days. Max stay: return <= departure date plus max_months calendar months; a month-end departure maps to the target month end, otherwise day clamps to month length. Return failed rule names in order SAT, MIN, MAX.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import calendar
N = 1
observations = []
def solve(x):
    d = datetime.date.fromisoformat(x['depart'])
    r = datetime.date.fromisoformat(x['return'])
    rule = x['rule']
    fails = []
    if rule['sat_night']:
        sun = d + datetime.timedelta(days=(5 - d.weekday()) % 7 + 1)
        if r < sun: fails.append('SAT')
    if (r - d).days < rule['min_days']: fails.append('MIN')
    mo = d.month - 1 + rule['max_months']
    y, mo = d.year + mo // 12, mo % 12 + 1
    last = calendar.monthrange(y, mo)[1]
    eom = d.day == calendar.monthrange(d.year, d.month)[1]
    lim = datetime.date(y, mo, min(d.day, last))
    if r > lim: fails.append('MAX')
    return fails
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-08', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-11', 'return': '2028-01-10', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-14', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-08-19', 'return': '2029-08-28', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, []], ['sampled case 2', {'depart': '2028-06-13', 'return': '2028-12-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['sampled case 3', {'depart': '2028-04-16', 'return': '2028-08-20', 'rule': {'sat_night': False, 'min_days': 1, 'max_months': 1}}, ['MAX']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-09', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-12', 'return': '2028-01-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-15', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-07-11', 'return': '2029-07-23', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 12}}, []], ['sampled case 2', {'depart': '2029-06-25', 'return': '2029-12-12', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, ['MAX']], ['sampled case 3', {'depart': '2029-02-02', 'return': '2030-02-22', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, ['MAX']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-10', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-29', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-29', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-13', 'return': '2028-01-14', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-16', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-10-05', 'return': '2027-10-14', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 6}}, []], ['sampled case 2', {'depart': '2028-04-06', 'return': '2028-10-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-11-12', 'return': '2027-11-21', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 2}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-11', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-14', 'return': '2028-01-16', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-17', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-06-01', 'return': '2027-06-09', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 1}}, []], ['sampled case 2', {'depart': '2028-03-04', 'return': '2028-06-07', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, []], ['sampled case 3', {'depart': '2029-03-17', 'return': '2029-03-25', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-12', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-15', 'return': '2028-01-18', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-18', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2029-08-05', 'return': '2030-07-02', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 11}}, []], ['sampled case 2', {'depart': '2028-05-10', 'return': '2028-05-12', 'rule': {'sat_night': False, 'min_days': 2, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-09-03', 'return': '2027-09-03', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 6}}, ['SAT']]]]
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 calendar
N = 1
observations = []
def solve(x):
    d = datetime.date.fromisoformat(x['depart'])
    r = datetime.date.fromisoformat(x['return'])
    rule = x['rule']
    fails = []
    if rule['sat_night']:
        sun = d + datetime.timedelta(days=(5 - d.weekday()) % 7 + 1)
        if r < sun: fails.append('SAT')
    if (r - d).days < rule['min_days']: fails.append('MIN')
    mo = d.month - 1 + rule['max_months']
    y, mo = d.year + mo // 12, mo % 12 + 1
    last = calendar.monthrange(y, mo)[1]
    eom = d.day == calendar.monthrange(d.year, d.month)[1]
    lim = datetime.date(y, mo, last if d.day >= 28 else min(d.day, last))
    if r > lim: fails.append('MAX')
    return fails
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-08', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-11', 'return': '2028-01-10', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-14', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-08-19', 'return': '2029-08-28', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, []], ['sampled case 2', {'depart': '2028-06-13', 'return': '2028-12-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['sampled case 3', {'depart': '2028-04-16', 'return': '2028-08-20', 'rule': {'sat_night': False, 'min_days': 1, 'max_months': 1}}, ['MAX']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-09', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-12', 'return': '2028-01-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-15', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-07-11', 'return': '2029-07-23', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 12}}, []], ['sampled case 2', {'depart': '2029-06-25', 'return': '2029-12-12', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, ['MAX']], ['sampled case 3', {'depart': '2029-02-02', 'return': '2030-02-22', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, ['MAX']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-10', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-29', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-29', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-13', 'return': '2028-01-14', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-16', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-10-05', 'return': '2027-10-14', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 6}}, []], ['sampled case 2', {'depart': '2028-04-06', 'return': '2028-10-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-11-12', 'return': '2027-11-21', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 2}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-11', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-14', 'return': '2028-01-16', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-17', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-06-01', 'return': '2027-06-09', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 1}}, []], ['sampled case 2', {'depart': '2028-03-04', 'return': '2028-06-07', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, []], ['sampled case 3', {'depart': '2029-03-17', 'return': '2029-03-25', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-12', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-15', 'return': '2028-01-18', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-18', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2029-08-05', 'return': '2030-07-02', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 11}}, []], ['sampled case 2', {'depart': '2028-05-10', 'return': '2028-05-12', 'rule': {'sat_night': False, 'min_days': 2, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-09-03', 'return': '2027-09-03', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 6}}, ['SAT']]]]
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:
Departing 28 February with a one-month maximum expires 28 March instead of 31 March.

Input {'depart','return' ISO dates,'rule':{'sat_night','min_days','max_months'}}. Saturday-night rule: return on or after the Sunday following the first Saturday on or after departure. Min stay: return - depart >= min_days. Max stay: return <= departure date plus max_months calendar months; a month-end departure maps to the target month end, otherwise day clamps to month length. Return failed rule names in order SAT, MIN, MAX.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import calendar
N = 1
observations = []
def solve(x):
    d = datetime.date.fromisoformat(x['depart'])
    r = datetime.date.fromisoformat(x['return'])
    rule = x['rule']
    fails = []
    if rule['sat_night']:
        sun = d + datetime.timedelta(days=(5 - d.weekday()) % 7 + 1)
        if r < sun: fails.append('SAT')
    if (r - d).days < rule['min_days']: fails.append('MIN')
    mo = d.month - 1 + rule['max_months']
    y, mo = d.year + (d.month + rule['max_months']) // 12, mo % 12 + 1
    last = calendar.monthrange(y, mo)[1]
    eom = d.day == calendar.monthrange(d.year, d.month)[1]
    lim = datetime.date(y, mo, last if eom else min(d.day, last))
    if r > lim: fails.append('MAX')
    return fails
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-08', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-11', 'return': '2028-01-10', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-14', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-08-19', 'return': '2029-08-28', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, []], ['sampled case 2', {'depart': '2028-06-13', 'return': '2028-12-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['sampled case 3', {'depart': '2028-04-16', 'return': '2028-08-20', 'rule': {'sat_night': False, 'min_days': 1, 'max_months': 1}}, ['MAX']], ['regression: maximum stay year rollover', {'depart': '2029-10-01', 'return': '2030-01-17', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 2}}, ['MAX']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-09', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-12', 'return': '2028-01-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-15', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-07-11', 'return': '2029-07-23', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 12}}, []], ['sampled case 2', {'depart': '2029-06-25', 'return': '2029-12-12', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, ['MAX']], ['sampled case 3', {'depart': '2029-02-02', 'return': '2030-02-22', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, ['MAX']], ['regression: maximum stay year rollover', {'depart': '2027-11-21', 'return': '2028-01-18', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 1}}, ['MAX']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-10', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-29', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-29', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-13', 'return': '2028-01-14', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-16', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-10-05', 'return': '2027-10-14', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 6}}, []], ['sampled case 2', {'depart': '2028-04-06', 'return': '2028-10-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-11-12', 'return': '2027-11-21', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 2}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-11', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-14', 'return': '2028-01-16', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-17', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-06-01', 'return': '2027-06-09', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 1}}, []], ['sampled case 2', {'depart': '2028-03-04', 'return': '2028-06-07', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, []], ['sampled case 3', {'depart': '2029-03-17', 'return': '2029-03-25', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['regression: maximum stay year rollover', {'depart': '2028-12-22', 'return': '2029-08-30', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-12', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-15', 'return': '2028-01-18', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-18', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2029-08-05', 'return': '2030-07-02', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 11}}, []], ['sampled case 2', {'depart': '2028-05-10', 'return': '2028-05-12', 'rule': {'sat_night': False, 'min_days': 2, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-09-03', 'return': '2027-09-03', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 6}}, ['SAT']]]]
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 calendar
N = 1
observations = []
def solve(x):
    d = datetime.date.fromisoformat(x['depart'])
    r = datetime.date.fromisoformat(x['return'])
    rule = x['rule']
    fails = []
    if rule['sat_night']:
        sun = d + datetime.timedelta(days=(5 - d.weekday()) % 7 + 1)
        if r < sun: fails.append('SAT')
    if (r - d).days < rule['min_days']: fails.append('MIN')
    mo = d.month - 1 + rule['max_months']
    y, mo = d.year + rule['max_months'] // 12, mo % 12 + 1
    last = calendar.monthrange(y, mo)[1]
    eom = d.day == calendar.monthrange(d.year, d.month)[1]
    lim = datetime.date(y, mo, last if eom else min(d.day, last))
    if r > lim: fails.append('MAX')
    return fails
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-08', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-11', 'return': '2028-01-10', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-14', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-08-19', 'return': '2029-08-28', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, []], ['sampled case 2', {'depart': '2028-06-13', 'return': '2028-12-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['sampled case 3', {'depart': '2028-04-16', 'return': '2028-08-20', 'rule': {'sat_night': False, 'min_days': 1, 'max_months': 1}}, ['MAX']], ['regression: maximum stay year rollover', {'depart': '2029-10-01', 'return': '2030-01-17', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 2}}, ['MAX']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-09', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-12', 'return': '2028-01-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, []], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-15', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, []], ['sampled case 1', {'depart': '2029-07-11', 'return': '2029-07-23', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 12}}, []], ['sampled case 2', {'depart': '2029-06-25', 'return': '2029-12-12', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 2}}, ['MAX']], ['sampled case 3', {'depart': '2029-02-02', 'return': '2030-02-22', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, ['MAX']], ['regression: maximum stay year rollover', {'depart': '2027-11-21', 'return': '2028-01-18', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 1}}, ['MAX']]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-10', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-29', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-29', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-13', 'return': '2028-01-14', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-16', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-10-05', 'return': '2027-10-14', 'rule': {'sat_night': True, 'min_days': 3, 'max_months': 6}}, []], ['sampled case 2', {'depart': '2028-04-06', 'return': '2028-10-12', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-11-12', 'return': '2027-11-21', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 2}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-11', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-30', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-30', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-14', 'return': '2028-01-16', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-17', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2027-06-01', 'return': '2027-06-09', 'rule': {'sat_night': True, 'min_days': 7, 'max_months': 1}}, []], ['sampled case 2', {'depart': '2028-03-04', 'return': '2028-06-07', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 6}}, []], ['sampled case 3', {'depart': '2029-03-17', 'return': '2029-03-25', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 12}}, []], ['regression: maximum stay year rollover', {'depart': '2028-12-22', 'return': '2029-08-30', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 11}}, []]], [['Sunday departure next-day return', {'depart': '2027-03-07', 'return': '2027-03-12', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 1}}, ['SAT']], ['Saturday departure Sunday return', {'depart': '2027-03-13', 'return': '2027-03-14', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 1}}, []], ['Friday out Saturday back', {'depart': '2027-03-12', 'return': '2027-03-13', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 3}}, ['SAT']], ['month-end max stay', {'depart': '2027-02-28', 'return': '2027-03-31', 'rule': {'sat_night': False, 'min_days': 3, 'max_months': 1}}, []], ['the 28th is not month end', {'depart': '2027-04-28', 'return': '2027-05-31', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, ['MAX']], ['Jan 31 plus one month', {'depart': '2027-01-31', 'return': '2027-02-28', 'rule': {'sat_night': False, 'min_days': 0, 'max_months': 1}}, []], ['year rollover max stay', {'depart': '2027-11-15', 'return': '2028-01-18', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 2}}, ['MAX']], ['exact minimum stay', {'depart': '2027-06-01', 'return': '2027-06-08', 'rule': {'sat_night': False, 'min_days': 7, 'max_months': 12}}, []], ['December twelve months', {'depart': '2027-12-15', 'return': '2028-12-18', 'rule': {'sat_night': True, 'min_days': 2, 'max_months': 12}}, ['MAX']], ['sampled case 1', {'depart': '2029-08-05', 'return': '2030-07-02', 'rule': {'sat_night': True, 'min_days': 1, 'max_months': 11}}, []], ['sampled case 2', {'depart': '2028-05-10', 'return': '2028-05-12', 'rule': {'sat_night': False, 'min_days': 2, 'max_months': 11}}, []], ['sampled case 3', {'depart': '2027-09-03', 'return': '2027-09-03', 'rule': {'sat_night': True, 'min_days': 0, 'max_months': 6}}, ['SAT']]]]
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 November departure with a one-month maximum stay gets a December limit in the following year.

Input {'depart','return' ISO dates,'rule':{'sat_night','min_days','max_months'}}. Saturday-night rule: return on or after the Sunday following the first Saturday on or after departure. Min stay: return - depart >= min_days. Max stay: return <= departure date plus max_months calendar months; a month-end departure maps to the target month end, otherwise day clamps to month length. Return failed rule names in order SAT, MIN, MAX.

split: open-access


prompt:
Travel on 3 January is priced as LOW instead of the December-January PEAK season.

Input {'date','seasons':[[start 'M-D', end 'M-D' (unpadded allowed), weekdays string of ISO digits 1=Mon..7=Sun, code]]}. A season with start after end wraps the year end. Both ends inclusive. Return the code of the first season (list order) containing the date on an allowed weekday, else 'NONE'.

split: open-access


prompt:
Travel on 31 August falls out of the summer season.

Input {'date','seasons':[[start 'M-D', end 'M-D' (unpadded allowed), weekdays string of ISO digits 1=Mon..7=Sun, code]]}. A season with start after end wraps the year end. Both ends inclusive. Return the code of the first season (list order) containing the date on an allowed weekday, else 'NONE'.

split: open-access


prompt:
A date covered by both a December promotion and the peak season gets the later-listed code.

Input {'date','seasons':[[start 'M-D', end 'M-D' (unpadded allowed), weekdays string of ISO digits 1=Mon..7=Sun, code]]}. A season with start after end wraps the year end. Both ends inclusive. Return the code of the first season (list order) containing the date on an allowed weekday, else 'NONE'.

split: open-access


prompt:
Weekend-only summer fares match Friday and Saturday instead of Saturday and Sunday.

Input {'date','seasons':[[start 'M-D', end 'M-D' (unpadded allowed), weekdays string of ISO digits 1=Mon..7=Sun, code]]}. A season with start after end wraps the year end. Both ends inclusive. Return the code of the first season (list order) containing the date on an allowed weekday, else 'NONE'.

split: open-access


prompt:
An October date is judged outside a September-to-November season.

Input {'date','seasons':[[start 'M-D', end 'M-D' (unpadded allowed), weekdays string of ISO digits 1=Mon..7=Sun, code]]}. A season with start after end wraps the year end. Both ends inclusive. Return the code of the first season (list order) containing the date on an allowed weekday, else 'NONE'.

split: open-access


prompt:
A trip out on 11 December and back on 5 January is refused because the Christmas blackout falls in between.

Input {'outbound','inbound' (ISO date or None),'blackouts':[[start, end] or [single date]]}. Blackouts apply only to each direction's departure date (inclusive ranges), not to days in between. Return the list of blocked directions in order 'OUT','IN', each at most once.

split: open-access


prompt:
Departures on the last day of a blackout period are sold.

Input {'outbound','inbound' (ISO date or None),'blackouts':[[start, end] or [single date]]}. Blackouts apply only to each direction's departure date (inclusive ranges), not to days in between. Return the list of blocked directions in order 'OUT','IN', each at most once.

split: open-access


prompt:
Travel on a single blacked-out holiday is sold.

Input {'outbound','inbound' (ISO date or None),'blackouts':[[start, end] or [single date]]}. Blackouts apply only to each direction's departure date (inclusive ranges), not to days in between. Return the list of blocked directions in order 'OUT','IN', each at most once.

split: open-access


prompt:
Travel during a later blackout period is accepted.

Input {'outbound','inbound' (ISO date or None),'blackouts':[[start, end] or [single date]]}. Blackouts apply only to each direction's departure date (inclusive ranges), not to days in between. Return the list of blocked directions in order 'OUT','IN', each at most once.

split: open-access


prompt:
Christmas Eve travel shows OUT twice because two blackout ranges overlap.

Input {'outbound','inbound' (ISO date or None),'blackouts':[[start, end] or [single date]]}. Blackouts apply only to each direction's departure date (inclusive ranges), not to days in between. Return the list of blocked directions in order 'OUT','IN', each at most once.

split: open-access