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

N = 1
observations = []
def solve(ts_utc, offset_min, cards, holidays):
    local = ts_utc + offset_min * 60
    day = local // 86400
    minute = local % 86400 // 60
    wd = (day + 4) % 7
    is_hol = day in holidays
    for c in cards:
        if c['days'] == 'holiday':
            if is_hol and c['start'] <= minute < c['end']:
                return c['card']
            continue
        if c['start'] < c['end']:
            if wd in c['days'] and c['start'] <= minute < c['end']:
                return c['card']
        else:
            if wd in c['days'] and minute >= c['start']:
                return c['card']
            if (wd - 1) % 7 in c['days'] and minute < c['end']:
                return c['card']
    return 'standard'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: epoch weekday',
   [1728770400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'late_night'),
  ('partial repair probe: epoch weekday',
   [1729029600, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'rush'),
  ('second regression',
   [1729058400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'rush'),
  ('normal control 1',
   [1729165389, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('normal control 2',
   [1728518400, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard'),
  ('normal control 3',
   [1728349200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('normal control 4',
   [1728381600, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'standard')],
 [('regression: epoch weekday',
   [1728165600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'late_night'),
  ('partial repair probe: epoch weekday',
   [1728727200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'late_night'),
  ('second regression',
   [1728604800, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('normal control 1',
   [1729123200, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 2',
   [1728432060, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 3',
   [1728802800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'holiday'),
  ('normal control 4',
   [1728111600, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard')],
 [('regression: epoch weekday',
   [1728194400, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'late_night'),
  ('partial repair probe: epoch weekday',
   [1728367200, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('second regression',
   [1728342000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'rush'),
  ('normal control 1',
   [1729126800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('normal control 2',
   [1728457200, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'standard'),
  ('normal control 3',
   [1728604860, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard'),
  ('normal control 4',
   [1728086340, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard')],
 [('regression: epoch weekday',
   [1728802800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('partial repair probe: epoch weekday',
   [1728950400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('second regression',
   [1728626400, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard'),
  ('normal control 1',
   [1728086340, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('normal control 2',
   [1728000060, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard'),
  ('normal control 3',
   [1728716400, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard'),
  ('normal control 4',
   [1729036740, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard')],
 [('regression: epoch weekday',
   [1728198000, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('partial repair probe: epoch weekday',
   [1728802800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'late_night'),
  ('second regression',
   [1728597600, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'rush'),
  ('normal control 1',
   [1728774000, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('normal control 2',
   [1728338400, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard'),
  ('normal control 3',
   [1728864000, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 4',
   [1728608400, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard')]]
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(ts_utc, offset_min, cards, holidays):
    local = ts_utc + offset_min * 60
    day = local // 86400
    minute = local % 86400 // 60
    wd = day % 7
    is_hol = day in holidays
    for c in cards:
        if c['days'] == 'holiday':
            if is_hol and c['start'] <= minute < c['end']:
                return c['card']
            continue
        if c['start'] < c['end']:
            if wd in c['days'] and c['start'] <= minute < c['end']:
                return c['card']
        else:
            if wd in c['days'] and minute >= c['start']:
                return c['card']
            if (wd - 1) % 7 in c['days'] and minute < c['end']:
                return c['card']
    return 'standard'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: epoch weekday',
   [1728770400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'late_night'),
  ('partial repair probe: epoch weekday',
   [1729029600, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'rush'),
  ('second regression',
   [1729058400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'rush'),
  ('normal control 1',
   [1729165389, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('normal control 2',
   [1728518400, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard'),
  ('normal control 3',
   [1728349200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('normal control 4',
   [1728381600, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'standard')],
 [('regression: epoch weekday',
   [1728165600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'late_night'),
  ('partial repair probe: epoch weekday',
   [1728727200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'late_night'),
  ('second regression',
   [1728604800, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('normal control 1',
   [1729123200, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 2',
   [1728432060, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 3',
   [1728802800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'holiday'),
  ('normal control 4',
   [1728111600, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard')],
 [('regression: epoch weekday',
   [1728194400, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'late_night'),
  ('partial repair probe: epoch weekday',
   [1728367200, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('second regression',
   [1728342000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'rush'),
  ('normal control 1',
   [1729126800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('normal control 2',
   [1728457200, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'standard'),
  ('normal control 3',
   [1728604860, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard'),
  ('normal control 4',
   [1728086340, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard')],
 [('regression: epoch weekday',
   [1728802800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('partial repair probe: epoch weekday',
   [1728950400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('second regression',
   [1728626400, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard'),
  ('normal control 1',
   [1728086340, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('normal control 2',
   [1728000060, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard'),
  ('normal control 3',
   [1728716400, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard'),
  ('normal control 4',
   [1729036740, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard')],
 [('regression: epoch weekday',
   [1728198000, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('partial repair probe: epoch weekday',
   [1728802800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'late_night'),
  ('second regression',
   [1728597600, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'rush'),
  ('normal control 1',
   [1728774000, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('normal control 2',
   [1728338400, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard'),
  ('normal control 3',
   [1728864000, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 4',
   [1728608400, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard')]]
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:
Friday late-night pricing shows up on Saturdays.

Pick the rate card for a pickup at ts_utc seconds (Unix epoch; day 0 was a Thursday) in a city at offset_min minutes from UTC. Local day index and minute-of-day come from the local time; weekday is Monday=0. Cards are checked in order, windows are half-open [start, end) minutes; a window with start > end wraps midnight and its after-midnight part belongs to the previous weekday. Holiday cards match local day indexes in holidays. Default "standard".

split: open-access


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

N = 1
observations = []
def solve(ts_utc, offset_min, cards, holidays):
    local = ts_utc + offset_min * 60
    day = local // 86400
    minute = local % 86400 // 60
    wd = (day + 3) % 7
    is_hol = day in holidays
    for c in cards:
        if c['days'] == 'holiday':
            if is_hol and c['start'] <= minute < c['end']:
                return c['card']
            continue
        if c['start'] < c['end']:
            if wd in c['days'] and c['start'] <= minute < c['end']:
                return c['card']
        else:
            if wd in c['days'] and minute >= c['start']:
                return c['card']
            if wd in c['days'] and minute < c['end']:
                return c['card']
    return 'standard'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: wrapped window weekday',
   [1728604740, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('partial repair probe: wrapped window weekday',
   [1729123200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('second regression',
   [1728700972, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'late_night'),
  ('normal control 1',
   [1728431940, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('normal control 2',
   [1728950340, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'standard'),
  ('normal control 3',
   [1728021600, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('normal control 4',
   [1729033200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'standard')],
 [('regression: wrapped window weekday',
   [1728604800, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard'),
  ('partial repair probe: wrapped window weekday',
   [1728727200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'late_night'),
  ('second regression',
   [1728687600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'late_night'),
  ('normal control 1',
   [1728367200, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('normal control 2',
   [1728194400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('normal control 3',
   [1728518460, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 4',
   [1728554400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard')],
 [('regression: wrapped window weekday',
   [1728165600, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'late_night'),
  ('partial repair probe: wrapped window weekday',
   [1729116000, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard'),
  ('second regression',
   [1728774000, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'late_night'),
  ('normal control 1',
   [1728889200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'rush'),
  ('normal control 2',
   [1728856800, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('normal control 3',
   [1729159200, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard'),
  ('normal control 4',
   [1728716400, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard')],
 [('regression: wrapped window weekday',
   [1728608400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('partial repair probe: wrapped window weekday',
   [1728663396, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'late_night'),
  ('second regression',
   [1728777660, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'late_night'),
  ('normal control 1',
   [1728799200, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard'),
  ('normal control 2',
   [1729119600, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 3',
   [1728338400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard'),
  ('normal control 4',
   [1728597600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard')],
 [('regression: wrapped window weekday',
   [1729209540, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('partial repair probe: wrapped window weekday',
   [1728082800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'late_night'),
  ('second regression',
   [1728169200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'late_night'),
  ('normal control 1',
   [1728021600, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard'),
  ('normal control 2',
   [1728025200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'rush'),
  ('normal control 3',
   [1728036000, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('normal control 4',
   [1728172740, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(ts_utc, offset_min, cards, holidays):
    local = ts_utc + offset_min * 60
    day = local // 86400
    minute = local % 86400 // 60
    wd = (day + 3) % 7
    is_hol = day in holidays
    for c in cards:
        if c['days'] == 'holiday':
            if is_hol and c['start'] <= minute < c['end']:
                return c['card']
            continue
        if c['start'] < c['end']:
            if wd in c['days'] and c['start'] <= minute < c['end']:
                return c['card']
        else:
            if wd in c['days'] and minute >= c['start']:
                return c['card']
            if (wd + 1) % 7 in c['days'] and minute < c['end']:
                return c['card']
    return 'standard'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: wrapped window weekday',
   [1728604740, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('partial repair probe: wrapped window weekday',
   [1729123200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('second regression',
   [1728700972, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'late_night'),
  ('normal control 1',
   [1728431940, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('normal control 2',
   [1728950340, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'standard'),
  ('normal control 3',
   [1728021600, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('normal control 4',
   [1729033200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'standard')],
 [('regression: wrapped window weekday',
   [1728604800, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard'),
  ('partial repair probe: wrapped window weekday',
   [1728727200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'late_night'),
  ('second regression',
   [1728687600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'late_night'),
  ('normal control 1',
   [1728367200, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('normal control 2',
   [1728194400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('normal control 3',
   [1728518460, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 4',
   [1728554400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard')],
 [('regression: wrapped window weekday',
   [1728165600, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'late_night'),
  ('partial repair probe: wrapped window weekday',
   [1729116000, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard'),
  ('second regression',
   [1728774000, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'late_night'),
  ('normal control 1',
   [1728889200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'rush'),
  ('normal control 2',
   [1728856800, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('normal control 3',
   [1729159200, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard'),
  ('normal control 4',
   [1728716400, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard')],
 [('regression: wrapped window weekday',
   [1728608400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('partial repair probe: wrapped window weekday',
   [1728663396, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'late_night'),
  ('second regression',
   [1728777660, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'late_night'),
  ('normal control 1',
   [1728799200, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard'),
  ('normal control 2',
   [1729119600, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 3',
   [1728338400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard'),
  ('normal control 4',
   [1728597600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard')],
 [('regression: wrapped window weekday',
   [1729209540, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('partial repair probe: wrapped window weekday',
   [1728082800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'late_night'),
  ('second regression',
   [1728169200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'late_night'),
  ('normal control 1',
   [1728021600, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'standard'),
  ('normal control 2',
   [1728025200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'rush'),
  ('normal control 3',
   [1728036000, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('normal control 4',
   [1728172740, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard')]]
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:
Friday 1 a.m. gets Thursday-night pricing and Sunday 1 a.m. gets none.

Pick the rate card for a pickup at ts_utc seconds (Unix epoch; day 0 was a Thursday) in a city at offset_min minutes from UTC. Local day index and minute-of-day come from the local time; weekday is Monday=0. Cards are checked in order, windows are half-open [start, end) minutes; a window with start > end wraps midnight and its after-midnight part belongs to the previous weekday. Holiday cards match local day indexes in holidays. Default "standard".

split: open-access


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

N = 1
observations = []
def solve(ts_utc, offset_min, cards, holidays):
    local = ts_utc + offset_min * 60
    day = local // 86400
    minute = local % 86400 // 60
    wd = (day + 3) % 7
    is_hol = day in holidays
    for c in cards:
        if c['days'] == 'holiday':
            if is_hol and c['start'] <= minute < c['end']:
                return c['card']
            continue
        if c['start'] < c['end']:
            if wd in c['days'] and c['start'] <= minute <= c['end']:
                return c['card']
        else:
            if wd in c['days'] and minute >= c['start']:
                return c['card']
            if (wd - 1) % 7 in c['days'] and minute < c['end']:
                return c['card']
    return 'standard'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: window end exclusive',
   [1728950400, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1728885600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'rush'),
  ('second regression',
   [1729148400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'rush'),
  ('normal control 1',
   [1729123200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'holiday'),
  ('normal control 2',
   [1728381600, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('normal control 3',
   [1728208800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'late_night'),
  ('normal control 4',
   [1728169200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'late_night')],
 [('regression: window end exclusive',
   [1728432000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1728889200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'rush'),
  ('second regression',
   [1728864000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('normal control 1',
   [1728082800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('normal control 2',
   [1728608400, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 3',
   [1728727200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'late_night'),
  ('normal control 4',
   [1728864060, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard')],
 [('regression: window end exclusive',
   [1728432000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1729062000, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'rush'),
  ('second regression',
   [1729062000, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'rush'),
  ('normal control 1',
   [1728511200, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('normal control 2',
   [1729058400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('normal control 3',
   [1728259140, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('normal control 4',
   [1729116000, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard')],
 [('regression: window end exclusive',
   [1728950400, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1728284400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'rush'),
  ('second regression',
   [1729159200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 1',
   [1728345660, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard'),
  ('normal control 2',
   [1728338400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('normal control 3',
   [1728691200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'late_night'),
  ('normal control 4',
   [1728198000, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'late_night')],
 [('regression: window end exclusive',
   [1728432000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1728457200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'rush'),
  ('second regression',
   [1728885600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'rush'),
  ('normal control 1',
   [1729159200, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('normal control 2',
   [1728198000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'holiday'),
  ('normal control 3',
   [1728863940, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('normal control 4',
   [1729072800, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard')]]
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(ts_utc, offset_min, cards, holidays):
    local = ts_utc + offset_min * 60
    day = local // 86400
    minute = local % 86400 // 60
    wd = (day + 3) % 7
    is_hol = day in holidays
    for c in cards:
        if c['days'] == 'holiday':
            if is_hol and c['start'] <= minute < c['end']:
                return c['card']
            continue
        if c['start'] < c['end']:
            if wd in c['days'] and c['start'] < minute < c['end']:
                return c['card']
        else:
            if wd in c['days'] and minute >= c['start']:
                return c['card']
            if (wd - 1) % 7 in c['days'] and minute < c['end']:
                return c['card']
    return 'standard'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: window end exclusive',
   [1728950400, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1728885600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'rush'),
  ('second regression',
   [1729148400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'rush'),
  ('normal control 1',
   [1729123200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'holiday'),
  ('normal control 2',
   [1728381600, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('normal control 3',
   [1728208800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'late_night'),
  ('normal control 4',
   [1728169200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'late_night')],
 [('regression: window end exclusive',
   [1728432000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1728889200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'rush'),
  ('second regression',
   [1728864000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('normal control 1',
   [1728082800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('normal control 2',
   [1728608400, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 3',
   [1728727200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'late_night'),
  ('normal control 4',
   [1728864060, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard')],
 [('regression: window end exclusive',
   [1728432000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1729062000, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'rush'),
  ('second regression',
   [1729062000, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'rush'),
  ('normal control 1',
   [1728511200, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('normal control 2',
   [1729058400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('normal control 3',
   [1728259140, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('normal control 4',
   [1729116000, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard')],
 [('regression: window end exclusive',
   [1728950400, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1728284400, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'rush'),
  ('second regression',
   [1729159200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 1',
   [1728345660, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard'),
  ('normal control 2',
   [1728338400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('normal control 3',
   [1728691200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'late_night'),
  ('normal control 4',
   [1728198000, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'late_night')],
 [('regression: window end exclusive',
   [1728432000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'standard'),
  ('partial repair probe: window end exclusive',
   [1728457200, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'rush'),
  ('second regression',
   [1728885600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'rush'),
  ('normal control 1',
   [1729159200, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('normal control 2',
   [1728198000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'holiday'),
  ('normal control 3',
   [1728863940, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('normal control 4',
   [1729072800, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard')]]
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:
Pickups at exactly 10:00 still pay rush pricing.

Pick the rate card for a pickup at ts_utc seconds (Unix epoch; day 0 was a Thursday) in a city at offset_min minutes from UTC. Local day index and minute-of-day come from the local time; weekday is Monday=0. Cards are checked in order, windows are half-open [start, end) minutes; a window with start > end wraps midnight and its after-midnight part belongs to the previous weekday. Holiday cards match local day indexes in holidays. Default "standard".

split: open-access


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

N = 1
observations = []
def solve(ts_utc, offset_min, cards, holidays):
    local = ts_utc + offset_min * 60
    day = local // 86400
    minute = local % 86400 // 60
    wd = (day + 3) % 7
    is_hol = ts_utc // 86400 in holidays
    for c in cards:
        if c['days'] == 'holiday':
            if is_hol and c['start'] <= minute < c['end']:
                return c['card']
            continue
        if c['start'] < c['end']:
            if wd in c['days'] and c['start'] <= minute < c['end']:
                return c['card']
        else:
            if wd in c['days'] and minute >= c['start']:
                return c['card']
            if (wd - 1) % 7 in c['days'] and minute < c['end']:
                return c['card']
    return 'standard'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: holiday calendar day',
   [1729182230, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('partial repair probe: holiday calendar day',
   [1728864000, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('second regression',
   [1728345540, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'rush'),
  ('normal control 1',
   [1728604860, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 2',
   [1728424800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('normal control 3',
   [1728543600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'rush'),
  ('normal control 4',
   [1728295200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard')],
 [('regression: holiday calendar day',
   [1728252000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'rush'),
  ('partial repair probe: holiday calendar day',
   [1728432000, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('second regression',
   [1728172800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'holiday'),
  ('normal control 1',
   [1728727200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'late_night'),
  ('normal control 2',
   [1728687600, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 3',
   [1728090000, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'late_night'),
  ('normal control 4',
   [1728802800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard')],
 [('regression: holiday calendar day',
   [1728950340, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('partial repair probe: holiday calendar day',
   [1728777600, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('second regression',
   [1728086400, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('normal control 1',
   [1728856800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard'),
  ('normal control 2',
   [1728537326, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('normal control 3',
   [1728172800, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 4',
   [1728194400, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard')],
 [('regression: holiday calendar day',
   [1728604740, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'holiday'),
  ('partial repair probe: holiday calendar day',
   [1728079200, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('second regression',
   [1728777660, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'holiday'),
  ('normal control 1',
   [1728604860, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('normal control 2',
   [1728604740, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'rush'),
  ('normal control 3',
   [1728208800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 4',
   [1728252000, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard')],
 [('regression: holiday calendar day',
   [1728860400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'holiday'),
  ('partial repair probe: holiday calendar day',
   [1728777660, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('second regression',
   [1728855612, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'holiday'),
  ('normal control 1',
   [1729036740, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 2',
   [1729058400, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard'),
  ('normal control 3',
   [1728946800, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 4',
   [1728950460, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard')]]
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(ts_utc, offset_min, cards, holidays):
    local = ts_utc + offset_min * 60
    day = local // 86400
    minute = local % 86400 // 60
    wd = (day + 3) % 7
    is_hol = day in holidays or ts_utc // 86400 in holidays
    for c in cards:
        if c['days'] == 'holiday':
            if is_hol and c['start'] <= minute < c['end']:
                return c['card']
            continue
        if c['start'] < c['end']:
            if wd in c['days'] and c['start'] <= minute < c['end']:
                return c['card']
        else:
            if wd in c['days'] and minute >= c['start']:
                return c['card']
            if (wd - 1) % 7 in c['days'] and minute < c['end']:
                return c['card']
    return 'standard'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: holiday calendar day',
   [1729182230, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'standard'),
  ('partial repair probe: holiday calendar day',
   [1728864000, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('second regression',
   [1728345540, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'rush'),
  ('normal control 1',
   [1728604860, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 2',
   [1728424800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('normal control 3',
   [1728543600, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20013]],
   'rush'),
  ('normal control 4',
   [1728295200, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard')],
 [('regression: holiday calendar day',
   [1728252000, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20002]],
   'rush'),
  ('partial repair probe: holiday calendar day',
   [1728432000, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20005]],
   'standard'),
  ('second regression',
   [1728172800, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'holiday'),
  ('normal control 1',
   [1728727200, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'late_night'),
  ('normal control 2',
   [1728687600, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 3',
   [1728090000, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'late_night'),
  ('normal control 4',
   [1728802800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard')],
 [('regression: holiday calendar day',
   [1728950340, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'standard'),
  ('partial repair probe: holiday calendar day',
   [1728777600, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('second regression',
   [1728086400, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard'),
  ('normal control 1',
   [1728856800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20006]],
   'standard'),
  ('normal control 2',
   [1728537326, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'standard'),
  ('normal control 3',
   [1728172800, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 4',
   [1728194400, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20012]],
   'standard')],
 [('regression: holiday calendar day',
   [1728604740, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20007]],
   'holiday'),
  ('partial repair probe: holiday calendar day',
   [1728079200, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('second regression',
   [1728777660, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20008]],
   'holiday'),
  ('normal control 1',
   [1728604860, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard'),
  ('normal control 2',
   [1728604740, 600,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20011]],
   'rush'),
  ('normal control 3',
   [1728208800, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 4',
   [1728252000, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20001]],
   'standard')],
 [('regression: holiday calendar day',
   [1728860400, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'holiday'),
  ('partial repair probe: holiday calendar day',
   [1728777660, -480,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('second regression',
   [1728855612, 330,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20010]],
   'holiday'),
  ('normal control 1',
   [1729036740, 60,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20003]],
   'standard'),
  ('normal control 2',
   [1729058400, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20004]],
   'standard'),
  ('normal control 3',
   [1728946800, 0,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20009]],
   'standard'),
  ('normal control 4',
   [1728950460, -300,
    [{'card': 'holiday', 'days': 'holiday', 'end': 1440, 'start': 0},
     {'card': 'late_night', 'days': [4, 5], 'end': 240, 'start': 1320},
     {'card': 'rush', 'days': [0, 1, 2, 3, 4], 'end': 600, 'start': 420}],
    [20000]],
   'standard')]]
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:
In a city ahead of UTC the first hours of the holiday are priced normally.

Pick the rate card for a pickup at ts_utc seconds (Unix epoch; day 0 was a Thursday) in a city at offset_min minutes from UTC. Local day index and minute-of-day come from the local time; weekday is Monday=0. Cards are checked in order, windows are half-open [start, end) minutes; a window with start > end wraps midnight and its after-midnight part belongs to the previous weekday. Holiday cards match local day indexes in holidays. Default "standard".

split: open-access