broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(filed, deadline, offset_min, method, office_close):
    u = dt.datetime.fromisoformat(filed.replace('Z', '+00:00')).astimezone(dt.timezone.utc).replace(tzinfo=None)
    local = u + dt.timedelta(minutes=offset_min)
    dl = dt.date.fromisoformat(deadline)
    if method == 'electronic':
        timely = local.date() <= dl
    else:
        close = dt.time.fromisoformat(office_close)
        timely = local.date() <= dl
    return [timely, local.isoformat(timespec='seconds')]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: west zone late evening',
   ['2024-03-06T04:30:00Z', '2024-03-05', -300, 'electronic', '17:00'],
   [True, '2024-03-05T23:30:00']),
  ('east zone after midnight',
   ['2024-03-05T22:30:00Z', '2024-03-05', 120, 'electronic', '17:00'],
   [False, '2024-03-06T00:30:00']),
  ('explicit offset stamp',
   ['2024-03-05T23:30:00-05:00', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T04:30:00']),
  ('last second electronic',
   ['2024-03-05T23:59:30Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T23:59:30']),
  ('deadline day morning',
   ['2024-03-05T09:00:00Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T09:00:00']),
  ('paper after close',
   ['2024-03-05T17:30:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [False, '2024-03-05T17:30:00']),
  ('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00'])],
 [('explicit offset stamp',
   ['2024-03-05T23:30:00-05:00', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T04:30:00']),
  ('last second electronic',
   ['2024-03-05T23:59:30Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T23:59:30']),
  ('deadline day morning',
   ['2024-03-05T09:00:00Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T09:00:00']),
  ('paper after close',
   ['2024-03-05T17:30:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [False, '2024-03-05T17:30:00']),
  ('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00']),
  ('paper before close offset',
   ['2024-03-05T14:00:00+02:00', '2024-03-05', 60, 'paper', '16:30'],
   [True, '2024-03-05T13:00:00']),
  ('paper previous day evening',
   ['2024-03-04T21:00:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [True, '2024-03-04T21:00:00'])],
 [('deadline day morning',
   ['2024-03-05T09:00:00Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T09:00:00']),
  ('paper after close',
   ['2024-03-05T17:30:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [False, '2024-03-05T17:30:00']),
  ('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00']),
  ('paper before close offset',
   ['2024-03-05T14:00:00+02:00', '2024-03-05', 60, 'paper', '16:30'],
   [True, '2024-03-05T13:00:00']),
  ('paper previous day evening',
   ['2024-03-04T21:00:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [True, '2024-03-04T21:00:00']),
  ('electronic next day',
   ['2024-03-06T00:00:01Z', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T00:00:01']),
  ('offset stamp plus zone',
   ['2024-03-06T01:15:00+01:00', '2024-03-05', -60, 'electronic', '17:00'],
   [True, '2024-03-05T23:15:00'])],
 [('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00']),
  ('paper before close offset',
   ['2024-03-05T14:00:00+02:00', '2024-03-05', 60, 'paper', '16:30'],
   [True, '2024-03-05T13:00:00']),
  ('paper previous day evening',
   ['2024-03-04T21:00:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [True, '2024-03-04T21:00:00']),
  ('electronic next day',
   ['2024-03-06T00:00:01Z', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T00:00:01']),
  ('offset stamp plus zone',
   ['2024-03-06T01:15:00+01:00', '2024-03-05', -60, 'electronic', '17:00'],
   [True, '2024-03-05T23:15:00']),
  ('regression: west zone late evening',
   ['2024-03-06T04:30:00Z', '2024-03-05', -300, 'electronic', '17:00'],
   [True, '2024-03-05T23:30:00']),
  ('east zone after midnight',
   ['2024-03-05T22:30:00Z', '2024-03-05', 120, 'electronic', '17:00'],
   [False, '2024-03-06T00:30:00'])],
 [('paper previous day evening',
   ['2024-03-04T21:00:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [True, '2024-03-04T21:00:00']),
  ('electronic next day',
   ['2024-03-06T00:00:01Z', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T00:00:01']),
  ('offset stamp plus zone',
   ['2024-03-06T01:15:00+01:00', '2024-03-05', -60, 'electronic', '17:00'],
   [True, '2024-03-05T23:15:00']),
  ('regression: west zone late evening',
   ['2024-03-06T04:30:00Z', '2024-03-05', -300, 'electronic', '17:00'],
   [True, '2024-03-05T23:30:00']),
  ('east zone after midnight',
   ['2024-03-05T22:30:00Z', '2024-03-05', 120, 'electronic', '17:00'],
   [False, '2024-03-06T00:30:00']),
  ('explicit offset stamp',
   ['2024-03-05T23:30:00-05:00', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T04:30:00']),
  ('last second electronic',
   ['2024-03-05T23:59:30Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T23:59:30']),
  ('paper after close',
   ['2024-03-05T17:30:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [False, '2024-03-05T17:30:00']),
  ('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(filed, deadline, offset_min, method, office_close):
    u = dt.datetime.fromisoformat(filed.replace('Z', '+00:00')).astimezone(dt.timezone.utc).replace(tzinfo=None)
    local = u + dt.timedelta(minutes=offset_min)
    dl = dt.date.fromisoformat(deadline)
    if method == 'electronic':
        timely = local.date() <= dl
    else:
        close = dt.time.fromisoformat(office_close)
        timely = local.date() < dl or (local.date() == dl and local.time() <= close)
    return [timely, local.isoformat(timespec='seconds')]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: west zone late evening',
   ['2024-03-06T04:30:00Z', '2024-03-05', -300, 'electronic', '17:00'],
   [True, '2024-03-05T23:30:00']),
  ('east zone after midnight',
   ['2024-03-05T22:30:00Z', '2024-03-05', 120, 'electronic', '17:00'],
   [False, '2024-03-06T00:30:00']),
  ('explicit offset stamp',
   ['2024-03-05T23:30:00-05:00', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T04:30:00']),
  ('last second electronic',
   ['2024-03-05T23:59:30Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T23:59:30']),
  ('deadline day morning',
   ['2024-03-05T09:00:00Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T09:00:00']),
  ('paper after close',
   ['2024-03-05T17:30:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [False, '2024-03-05T17:30:00']),
  ('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00'])],
 [('explicit offset stamp',
   ['2024-03-05T23:30:00-05:00', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T04:30:00']),
  ('last second electronic',
   ['2024-03-05T23:59:30Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T23:59:30']),
  ('deadline day morning',
   ['2024-03-05T09:00:00Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T09:00:00']),
  ('paper after close',
   ['2024-03-05T17:30:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [False, '2024-03-05T17:30:00']),
  ('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00']),
  ('paper before close offset',
   ['2024-03-05T14:00:00+02:00', '2024-03-05', 60, 'paper', '16:30'],
   [True, '2024-03-05T13:00:00']),
  ('paper previous day evening',
   ['2024-03-04T21:00:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [True, '2024-03-04T21:00:00'])],
 [('deadline day morning',
   ['2024-03-05T09:00:00Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T09:00:00']),
  ('paper after close',
   ['2024-03-05T17:30:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [False, '2024-03-05T17:30:00']),
  ('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00']),
  ('paper before close offset',
   ['2024-03-05T14:00:00+02:00', '2024-03-05', 60, 'paper', '16:30'],
   [True, '2024-03-05T13:00:00']),
  ('paper previous day evening',
   ['2024-03-04T21:00:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [True, '2024-03-04T21:00:00']),
  ('electronic next day',
   ['2024-03-06T00:00:01Z', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T00:00:01']),
  ('offset stamp plus zone',
   ['2024-03-06T01:15:00+01:00', '2024-03-05', -60, 'electronic', '17:00'],
   [True, '2024-03-05T23:15:00'])],
 [('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00']),
  ('paper before close offset',
   ['2024-03-05T14:00:00+02:00', '2024-03-05', 60, 'paper', '16:30'],
   [True, '2024-03-05T13:00:00']),
  ('paper previous day evening',
   ['2024-03-04T21:00:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [True, '2024-03-04T21:00:00']),
  ('electronic next day',
   ['2024-03-06T00:00:01Z', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T00:00:01']),
  ('offset stamp plus zone',
   ['2024-03-06T01:15:00+01:00', '2024-03-05', -60, 'electronic', '17:00'],
   [True, '2024-03-05T23:15:00']),
  ('regression: west zone late evening',
   ['2024-03-06T04:30:00Z', '2024-03-05', -300, 'electronic', '17:00'],
   [True, '2024-03-05T23:30:00']),
  ('east zone after midnight',
   ['2024-03-05T22:30:00Z', '2024-03-05', 120, 'electronic', '17:00'],
   [False, '2024-03-06T00:30:00'])],
 [('paper previous day evening',
   ['2024-03-04T21:00:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [True, '2024-03-04T21:00:00']),
  ('electronic next day',
   ['2024-03-06T00:00:01Z', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T00:00:01']),
  ('offset stamp plus zone',
   ['2024-03-06T01:15:00+01:00', '2024-03-05', -60, 'electronic', '17:00'],
   [True, '2024-03-05T23:15:00']),
  ('regression: west zone late evening',
   ['2024-03-06T04:30:00Z', '2024-03-05', -300, 'electronic', '17:00'],
   [True, '2024-03-05T23:30:00']),
  ('east zone after midnight',
   ['2024-03-05T22:30:00Z', '2024-03-05', 120, 'electronic', '17:00'],
   [False, '2024-03-06T00:30:00']),
  ('explicit offset stamp',
   ['2024-03-05T23:30:00-05:00', '2024-03-05', 0, 'electronic', '17:00'],
   [False, '2024-03-06T04:30:00']),
  ('last second electronic',
   ['2024-03-05T23:59:30Z', '2024-03-05', 0, 'electronic', '17:00'],
   [True, '2024-03-05T23:59:30']),
  ('paper after close',
   ['2024-03-05T17:30:00Z', '2024-03-05', 0, 'paper', '17:00'],
   [False, '2024-03-05T17:30:00']),
  ('paper exactly at close',
   ['2024-03-05T22:00:00Z', '2024-03-05', -300, 'paper', '17:00'],
   [False, '2024-03-05T17:00:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A paper filing handed in after the clerk office closed on the deadline day is marked timely.

The filing timestamp is ISO 8601 with Z or an explicit UTC offset. The court is at offset_min minutes east of UTC (local = UTC + offset). Electronic filing is timely through local midnight ending the deadline day (any time on the deadline date). Paper filing on the deadline day is timely only strictly before the clerk office closing time. Earlier dates are timely. Return [timely, local time ISO to the second].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(deadline, filings):
    dl = dt.date.fromisoformat(deadline)
    out = []
    for method, received, mailed, prisoner in filings:
        if prisoner and method == 'certified' and mailed is not None:
            deemed = mailed
        elif method == 'certified' and mailed is not None:
            deemed = mailed
        else:
            deemed = received
        dd = dt.date.fromisoformat(deemed)
        late = max(0, (dd - dl).days)
        out.append([deemed, dd <= dl, late])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])],
 [('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]])],
 [('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]])],
 [('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]])],
 [('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(deadline, filings):
    dl = dt.date.fromisoformat(deadline)
    out = []
    for method, received, mailed, prisoner in filings:
        if prisoner and mailed is not None and mailed <= deadline:
            deemed = mailed
        elif method == 'certified' and mailed is not None:
            deemed = mailed
        else:
            deemed = received
        dd = dt.date.fromisoformat(deemed)
        late = max(0, (dd - dl).days)
        out.append([deemed, dd <= dl, late])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])],
 [('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]])],
 [('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]])],
 [('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]])],
 [('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A prisoner filing sent by ordinary mail is dated by receipt and judged late.

Each filing is [method, received, mailed, prisoner]. Stipulated: a prisoner filing with a mailed date is deemed filed when delivered to the prison mail system (mailed), regardless of method; otherwise a certified-mail filing with a mailed date is deemed filed on its postmark (mailed); every other filing (ordinary mail, courier, electronic) is filed when received. Return [deemed date, timely (deemed on or before the deadline), days late (0 if timely)] per filing.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(deadline, filings):
    dl = dt.date.fromisoformat(deadline)
    out = []
    for method, received, mailed, prisoner in filings:
        if prisoner and mailed is not None:
            deemed = mailed
        elif method in ('certified', 'mail') and mailed is not None:
            deemed = mailed
        else:
            deemed = received
        dd = dt.date.fromisoformat(deemed)
        late = max(0, (dd - dl).days)
        out.append([deemed, dd <= dl, late])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])],
 [('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]])],
 [('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])],
 [('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])],
 [('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(deadline, filings):
    dl = dt.date.fromisoformat(deadline)
    out = []
    for method, received, mailed, prisoner in filings:
        if prisoner and mailed is not None:
            deemed = mailed
        elif method not in ('electronic', 'mail') and mailed is not None:
            deemed = mailed
        else:
            deemed = received
        dd = dt.date.fromisoformat(deemed)
        late = max(0, (dd - dl).days)
        out.append([deemed, dd <= dl, late])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])],
 [('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]])],
 [('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])],
 [('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])],
 [('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An ordinary-mail filing received late is treated as timely by its postmark.

Each filing is [method, received, mailed, prisoner]. Stipulated: a prisoner filing with a mailed date is deemed filed when delivered to the prison mail system (mailed), regardless of method; otherwise a certified-mail filing with a mailed date is deemed filed on its postmark (mailed); every other filing (ordinary mail, courier, electronic) is filed when received. Return [deemed date, timely (deemed on or before the deadline), days late (0 if timely)] per filing.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(deadline, filings):
    dl = dt.date.fromisoformat(deadline)
    out = []
    for method, received, mailed, prisoner in filings:
        if prisoner and mailed is not None:
            deemed = mailed
        elif method == 'certified' and mailed is not None:
            deemed = mailed
        else:
            deemed = received
        dd = dt.date.fromisoformat(deemed)
        late = (dd - dl).days
        out.append([deemed, dd <= dl, late])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])],
 [('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]])],
 [('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]])],
 [('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]])],
 [('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(deadline, filings):
    dl = dt.date.fromisoformat(deadline)
    out = []
    for method, received, mailed, prisoner in filings:
        if prisoner and mailed is not None:
            deemed = mailed
        elif method == 'certified' and mailed is not None:
            deemed = mailed
        else:
            deemed = received
        dd = dt.date.fromisoformat(deemed)
        late = abs((dd - dl).days)
        out.append([deemed, dd <= dl, late])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])],
 [('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]])],
 [('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]])],
 [('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]])],
 [('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Early filings report negative days late.

Each filing is [method, received, mailed, prisoner]. Stipulated: a prisoner filing with a mailed date is deemed filed when delivered to the prison mail system (mailed), regardless of method; otherwise a certified-mail filing with a mailed date is deemed filed on its postmark (mailed); every other filing (ordinary mail, courier, electronic) is filed when received. Return [deemed date, timely (deemed on or before the deadline), days late (0 if timely)] per filing.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(deadline, filings):
    dl = dt.date.fromisoformat(deadline)
    out = []
    for method, received, mailed, prisoner in filings:
        if prisoner and mailed is not None:
            deemed = mailed
        elif method == 'certified' and mailed is not None:
            deemed = mailed
        else:
            deemed = received
        dd = dt.date.fromisoformat(deemed)
        late = max(0, (dd - dl).days)
        out.append([deemed, dd < dl, late])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])],
 [('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]])],
 [('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]])],
 [('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]])],
 [('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(deadline, filings):
    dl = dt.date.fromisoformat(deadline)
    out = []
    for method, received, mailed, prisoner in filings:
        if prisoner and mailed is not None:
            deemed = mailed
        elif method == 'certified' and mailed is not None:
            deemed = mailed
        else:
            deemed = received
        dd = dt.date.fromisoformat(deemed)
        late = max(0, (dd - dl).days)
        out.append([deemed, late <= 1, late])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]])],
 [('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]]),
  ('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]])],
 [('electronic on deadline',
   ['2024-04-15', [['electronic', '2024-04-15', None, False]]],
   [['2024-04-15', True, 0]]),
  ('early and late mix',
   ['2024-04-15', [['electronic', '2024-04-10', None, False], ['electronic', '2024-04-16', None, False]]],
   [['2024-04-10', True, 0], ['2024-04-16', False, 1]]),
  ('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]])],
 [('prisoner mailed late',
   ['2024-04-15', [['mail', '2024-04-22', '2024-04-18', True]]],
   [['2024-04-18', False, 3]]),
  ('prisoner without mailed date',
   ['2024-04-15', [['mail', '2024-04-16', None, True]]],
   [['2024-04-16', False, 1]]),
  ('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]])],
 [('certified late postmark',
   ['2024-04-15', [['certified', '2024-04-20', '2024-04-17', False]]],
   [['2024-04-17', False, 2]]),
  ('one day late electronic',
   ['2024-04-15', [['electronic', '2024-04-16', None, False]]],
   [['2024-04-16', False, 1]]),
  ('prisoner certified',
   ['2024-06-01',
    [['certified', '2024-06-05', '2024-06-01', True], ['mail', '2024-05-20', '2024-05-18', False]]],
   [['2024-06-01', True, 0], ['2024-05-20', True, 0]]),
  ('regression: prisoner ordinary mail',
   ['2024-04-15', [['mail', '2024-04-19', '2024-04-12', True]]],
   [['2024-04-12', True, 0]]),
  ('ordinary mail postmarked early',
   ['2024-04-15', [['mail', '2024-04-17', '2024-04-14', False]]],
   [['2024-04-17', False, 2]]),
  ('certified mail postmark',
   ['2024-04-15', [['certified', '2024-04-18', '2024-04-15', False]]],
   [['2024-04-15', True, 0]]),
  ('courier ship date',
   ['2024-04-15', [['courier', '2024-04-17', '2024-04-15', False]]],
   [['2024-04-17', False, 2]])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A filing deemed filed on the deadline day is marked untimely.

Each filing is [method, received, mailed, prisoner]. Stipulated: a prisoner filing with a mailed date is deemed filed when delivered to the prison mail system (mailed), regardless of method; otherwise a certified-mail filing with a mailed date is deemed filed on its postmark (mailed); every other filing (ordinary mail, courier, electronic) is filed when received. Return [deemed date, timely (deemed on or before the deadline), days late (0 if timely)] per filing.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(injury, discovery, years, tolls, repose_years):
    inj = dt.date.fromisoformat(injury)
    disc = dt.date.fromisoformat(discovery)
    accrual = inj
    def add_years(d, n):
        y = d.year + n
        return dt.date(y, d.month, min(d.day, calendar.monthrange(y, d.month)[1]))
    base = add_years(accrual, years)
    covered = set()
    total = 0
    for a, b in tolls:
        a = dt.date.fromisoformat(a)
        b = dt.date.fromisoformat(b)
        a = max(a, accrual)
        span = max(0, (b - a).days + 1)
        total += span
        for i in range(span):
            covered.add(a + dt.timedelta(days=i))
    tolled = len(covered)
    extended = base + dt.timedelta(days=tolled)
    repose = add_years(inj, repose_years)
    return (min(extended, repose)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28'),
  ('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06'),
  ('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01')],
 [('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06'),
  ('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19')],
 [('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10')],
 [('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28')],
 [('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28'),
  ('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(injury, discovery, years, tolls, repose_years):
    inj = dt.date.fromisoformat(injury)
    disc = dt.date.fromisoformat(discovery)
    accrual = min(inj, disc)
    def add_years(d, n):
        y = d.year + n
        return dt.date(y, d.month, min(d.day, calendar.monthrange(y, d.month)[1]))
    base = add_years(accrual, years)
    covered = set()
    total = 0
    for a, b in tolls:
        a = dt.date.fromisoformat(a)
        b = dt.date.fromisoformat(b)
        a = max(a, accrual)
        span = max(0, (b - a).days + 1)
        total += span
        for i in range(span):
            covered.add(a + dt.timedelta(days=i))
    tolled = len(covered)
    extended = base + dt.timedelta(days=tolled)
    repose = add_years(inj, repose_years)
    return (min(extended, repose)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28'),
  ('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06'),
  ('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01')],
 [('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06'),
  ('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19')],
 [('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10')],
 [('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28')],
 [('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28'),
  ('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A latent injury discovered years later is time-barred from the injury date.

Stipulated: the claim accrues on the later of injury and discovery. The base deadline is the anniversary of accrual after years (a February 29 anniversary in a common year becomes February 28). Tolling intervals [start, end] are inclusive of both days, days before accrual do not count, and overlapping intervals count each day once; the tolled day count is added to the base deadline. A repose deadline of repose_years from the injury (same anniversary rule, never tolled) caps the result.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(injury, discovery, years, tolls, repose_years):
    inj = dt.date.fromisoformat(injury)
    disc = dt.date.fromisoformat(discovery)
    accrual = max(inj, disc)
    def add_years(d, n):
        y = d.year + n
        return d + dt.timedelta(days=365 * n)
    base = add_years(accrual, years)
    covered = set()
    total = 0
    for a, b in tolls:
        a = dt.date.fromisoformat(a)
        b = dt.date.fromisoformat(b)
        a = max(a, accrual)
        span = max(0, (b - a).days + 1)
        total += span
        for i in range(span):
            covered.add(a + dt.timedelta(days=i))
    tolled = len(covered)
    extended = base + dt.timedelta(days=tolled)
    repose = add_years(inj, repose_years)
    return (min(extended, repose)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28'),
  ('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06'),
  ('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01')],
 [('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06'),
  ('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28')],
 [('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28')],
 [('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28')],
 [('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28'),
  ('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(injury, discovery, years, tolls, repose_years):
    inj = dt.date.fromisoformat(injury)
    disc = dt.date.fromisoformat(discovery)
    accrual = max(inj, disc)
    def add_years(d, n):
        y = d.year + n
        return dt.date(y, 3, 1) if (d.month, d.day) == (2, 29) and not calendar.isleap(y) else dt.date(y, d.month, d.day)
    base = add_years(accrual, years)
    covered = set()
    total = 0
    for a, b in tolls:
        a = dt.date.fromisoformat(a)
        b = dt.date.fromisoformat(b)
        a = max(a, accrual)
        span = max(0, (b - a).days + 1)
        total += span
        for i in range(span):
            covered.add(a + dt.timedelta(days=i))
    tolled = len(covered)
    extended = base + dt.timedelta(days=tolled)
    repose = add_years(inj, repose_years)
    return (min(extended, repose)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28'),
  ('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06'),
  ('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01')],
 [('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06'),
  ('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28')],
 [('one day toll', ['2021-04-04', '2021-04-04', 1, [['2021-05-05', '2021-05-05']], 5], '2022-04-05'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15'),
  ('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28')],
 [('repose with tolling beyond',
   ['2014-07-01', '2015-07-01', 7, [['2016-01-01', '2016-03-31']], 8],
   '2022-07-01'),
  ('toll straddles accrual',
   ['2019-01-01', '2019-02-01', 1, [['2019-01-20', '2019-02-10']], 4],
   '2020-02-11'),
  ('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28')],
 [('three overlapping tolls',
   ['2022-05-05',
    '2022-05-05',
    2,
    [['2022-06-01', '2022-06-30'], ['2022-06-15', '2022-07-15'], ['2022-07-10', '2022-07-12']],
    6],
   '2024-06-19'),
  ('discovery earlier than injury input', ['2021-09-09', '2021-08-01', 2, [], 4], '2023-09-09'),
  ('toll wholly before injury',
   ['2020-10-10', '2020-10-10', 1, [['2019-01-01', '2019-02-01']], 3],
   '2021-10-10'),
  ('regression: discovery then overlapping tolls',
   ['2018-03-10', '2019-06-01', 2, [['2019-07-01', '2019-07-10'], ['2019-07-05', '2019-07-20']], 10],
   '2021-06-21'),
  ('leap day accrual', ['2020-02-29', '2020-02-29', 3, [], 10], '2023-02-28'),
  ('leap crossing two years', ['2023-03-01', '2023-03-01', 2, [], 10], '2025-03-01'),
  ('toll before discovery',
   ['2015-01-10', '2016-05-05', 3, [['2015-06-01', '2015-12-31'], ['2017-01-01', '2017-01-01']], 10],
   '2019-05-06')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A two-year period ending across a leap day expires one day early.

Stipulated: the claim accrues on the later of injury and discovery. The base deadline is the anniversary of accrual after years (a February 29 anniversary in a common year becomes February 28). Tolling intervals [start, end] are inclusive of both days, days before accrual do not count, and overlapping intervals count each day once; the tolled day count is added to the base deadline. A repose deadline of repose_years from the injury (same anniversary rule, never tolled) caps the result.

split: open-access