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 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 = a
        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 = max(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, inj)
        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:
Tolling that ended before discovery still extends the deadline.

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 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)
        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)

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(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, 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 + 2)
        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 one-day tolling interval adds nothing.

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 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 = total
    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 = max(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 = total - (len(tolls) - 1)
    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:
Overlapping tolling periods are double counted.

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 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(accrual, 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'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15')]]
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, 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(disc, 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'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The repose cap runs from discovery, allowing claims beyond the absolute bar.

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 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 (extended).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'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15')]]
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, 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(base, repose) + dt.timedelta(days=tolled)).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'),
  ('repose caps', ['2010-01-15', '2019-06-01', 3, [['2020-01-01', '2020-06-30']], 10], '2020-01-15')]]
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:
Tolling extends a claim beyond the statute of repose.

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


prompt:
A case involving a federal agency gets only 30 days.

Stipulated: the period is 30 days after entry of judgment, or 60 days if any party is the united-states, an agency or an officer. A motion filed within 28 days after entry (inclusive) tolls the period, which then runs from the latest disposition of such motions; if any tolling motion is undisposed the result is "pending". Untimely motions have no effect. A deadline on a Saturday, Sunday or listed holiday moves to the next open day.

split: open-access


prompt:
A motion filed on the 28th day is treated as untimely and does not toll.

Stipulated: the period is 30 days after entry of judgment, or 60 days if any party is the united-states, an agency or an officer. A motion filed within 28 days after entry (inclusive) tolls the period, which then runs from the latest disposition of such motions; if any tolling motion is undisposed the result is "pending". Untimely motions have no effect. A deadline on a Saturday, Sunday or listed holiday moves to the next open day.

split: open-access


prompt:
When motions are listed out of order, the period runs from an earlier disposition.

Stipulated: the period is 30 days after entry of judgment, or 60 days if any party is the united-states, an agency or an officer. A motion filed within 28 days after entry (inclusive) tolls the period, which then runs from the latest disposition of such motions; if any tolling motion is undisposed the result is "pending". Untimely motions have no effect. A deadline on a Saturday, Sunday or listed holiday moves to the next open day.

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(entry, parties, motions, holidays):
    e = dt.date.fromisoformat(entry)
    hol = {dt.date.fromisoformat(x) for x in holidays}
    period = 60 if any(p in ('united-states', 'agency', 'officer') for p in parties) else 30
    start = e
    pending = False
    for filed, disposed in motions:
        f = dt.date.fromisoformat(filed)
        if (f - e).days <= 28:
            if disposed is None:
                pending = True
            else:
                start = max(start, dt.date.fromisoformat(disposed))
    if pending and start == e:
        return 'pending'
    d = start + dt.timedelta(days=period)
    while d.weekday() >= 5 or d in hol:
        d += dt.timedelta(days=1)
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: agency party',
   ['2024-03-01',
    ['agency', 'smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('private parties',
   ['2024-03-01',
    ['smith', 'jones'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('government second',
   ['2024-03-01',
    ['smith', 'officer'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('motion on day 28',
   ['2024-03-01',
    ['smith'],
    [['2024-03-29', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-15'),
  ('motion on day 29',
   ['2024-03-01',
    ['smith'],
    [['2024-03-30', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('out of order dispositions',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-05-01'], ['2024-03-12', '2024-04-10']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-31'),
  ('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending')],
 [('government second',
   ['2024-03-01',
    ['smith', 'officer'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('motion on day 28',
   ['2024-03-01',
    ['smith'],
    [['2024-03-29', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-15'),
  ('motion on day 29',
   ['2024-03-01',
    ['smith'],
    [['2024-03-30', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('out of order dispositions',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-05-01'], ['2024-03-12', '2024-04-10']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-31'),
  ('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('single pending',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('lands on holiday',
   ['2024-06-04',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-07-05')],
 [('motion on day 29',
   ['2024-03-01',
    ['smith'],
    [['2024-03-30', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('out of order dispositions',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-05-01'], ['2024-03-12', '2024-04-10']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-31'),
  ('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('single pending',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('lands on holiday',
   ['2024-06-04',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-07-05'),
  ('lands on weekend',
   ['2024-02-05',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-06'),
  ('untimely pending ignored',
   ['2024-01-10',
    ['united-states'],
    [['2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-11')],
 [('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('single pending',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('lands on holiday',
   ['2024-06-04',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-07-05'),
  ('lands on weekend',
   ['2024-02-05',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-06'),
  ('untimely pending ignored',
   ['2024-01-10',
    ['united-states'],
    [['2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-11'),
  ('memorial day landing',
   ['2024-04-27',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-28'),
  ('regression: agency party',
   ['2024-03-01',
    ['agency', 'smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30')],
 [('lands on holiday',
   ['2024-06-04',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-07-05'),
  ('lands on weekend',
   ['2024-02-05',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-06'),
  ('untimely pending ignored',
   ['2024-01-10',
    ['united-states'],
    [['2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-11'),
  ('memorial day landing',
   ['2024-04-27',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-28'),
  ('regression: agency party',
   ['2024-03-01',
    ['agency', 'smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('private parties',
   ['2024-03-01',
    ['smith', 'jones'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('government second',
   ['2024-03-01',
    ['smith', 'officer'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending')]]
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(entry, parties, motions, holidays):
    e = dt.date.fromisoformat(entry)
    hol = {dt.date.fromisoformat(x) for x in holidays}
    period = 60 if any(p in ('united-states', 'agency', 'officer') for p in parties) else 30
    start = e
    pending = False
    for filed, disposed in motions:
        f = dt.date.fromisoformat(filed)
        if (f - e).days <= 28:
            if disposed is None:
                pending = True
            else:
                start = max(start, dt.date.fromisoformat(disposed))
    if pending and len(motions) == 1:
        return 'pending'
    d = start + dt.timedelta(days=period)
    while d.weekday() >= 5 or d in hol:
        d += dt.timedelta(days=1)
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: agency party',
   ['2024-03-01',
    ['agency', 'smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('private parties',
   ['2024-03-01',
    ['smith', 'jones'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('government second',
   ['2024-03-01',
    ['smith', 'officer'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('motion on day 28',
   ['2024-03-01',
    ['smith'],
    [['2024-03-29', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-15'),
  ('motion on day 29',
   ['2024-03-01',
    ['smith'],
    [['2024-03-30', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('out of order dispositions',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-05-01'], ['2024-03-12', '2024-04-10']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-31'),
  ('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending')],
 [('government second',
   ['2024-03-01',
    ['smith', 'officer'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('motion on day 28',
   ['2024-03-01',
    ['smith'],
    [['2024-03-29', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-15'),
  ('motion on day 29',
   ['2024-03-01',
    ['smith'],
    [['2024-03-30', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('out of order dispositions',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-05-01'], ['2024-03-12', '2024-04-10']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-31'),
  ('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('single pending',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('lands on holiday',
   ['2024-06-04',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-07-05')],
 [('motion on day 29',
   ['2024-03-01',
    ['smith'],
    [['2024-03-30', '2024-04-15']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('out of order dispositions',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-05-01'], ['2024-03-12', '2024-04-10']],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-31'),
  ('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('single pending',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('lands on holiday',
   ['2024-06-04',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-07-05'),
  ('lands on weekend',
   ['2024-02-05',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-06'),
  ('untimely pending ignored',
   ['2024-01-10',
    ['united-states'],
    [['2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-11')],
 [('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('single pending',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending'),
  ('lands on holiday',
   ['2024-06-04',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-07-05'),
  ('lands on weekend',
   ['2024-02-05',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-06'),
  ('untimely pending ignored',
   ['2024-01-10',
    ['united-states'],
    [['2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-11'),
  ('memorial day landing',
   ['2024-04-27',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-28'),
  ('regression: agency party',
   ['2024-03-01',
    ['agency', 'smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30')],
 [('lands on holiday',
   ['2024-06-04',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-07-05'),
  ('lands on weekend',
   ['2024-02-05',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-06'),
  ('untimely pending ignored',
   ['2024-01-10',
    ['united-states'],
    [['2024-02-20', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-03-11'),
  ('memorial day landing',
   ['2024-04-27',
    ['smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-05-28'),
  ('regression: agency party',
   ['2024-03-01',
    ['agency', 'smith'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('private parties',
   ['2024-03-01',
    ['smith', 'jones'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-01'),
  ('government second',
   ['2024-03-01',
    ['smith', 'officer'],
    [],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   '2024-04-30'),
  ('pending after disposed',
   ['2024-03-01',
    ['smith'],
    [['2024-03-10', '2024-04-01'], ['2024-03-12', None]],
    ['2024-01-01',
     '2024-01-15',
     '2024-02-19',
     '2024-05-27',
     '2024-06-19',
     '2024-07-04',
     '2024-09-02',
     '2024-10-14',
     '2024-11-11',
     '2024-11-28',
     '2024-12-25']],
   'pending')]]
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 undisposed tolling motion is ignored once another motion has been decided.

Stipulated: the period is 30 days after entry of judgment, or 60 days if any party is the united-states, an agency or an officer. A motion filed within 28 days after entry (inclusive) tolls the period, which then runs from the latest disposition of such motions; if any tolling motion is undisposed the result is "pending". Untimely motions have no effect. A deadline on a Saturday, Sunday or listed holiday moves to the next open day.

split: open-access


prompt:
An appeal deadline landing on a holiday is not extended.

Stipulated: the period is 30 days after entry of judgment, or 60 days if any party is the united-states, an agency or an officer. A motion filed within 28 days after entry (inclusive) tolls the period, which then runs from the latest disposition of such motions; if any tolling motion is undisposed the result is "pending". Untimely motions have no effect. A deadline on a Saturday, Sunday or listed holiday moves to the next open day.

split: open-access


prompt:
The waiver answer deadline is computed from the date the waiver was filed rather than when the request was sent.

Stipulated: with personal service the answer is due 21 days after service. When service is waived, the answer is due 60 days after the waiver request was sent, or 90 days if the request was sent to a defendant outside the country (foreign is a boolean). A government defendant served personally gets 60 days instead of 21. The trigger day is excluded and a closed last day (weekend or listed holiday) moves to the next open day.

split: open-access


prompt:
A defendant abroad who waived service gets 60 days instead of 90.

Stipulated: with personal service the answer is due 21 days after service. When service is waived, the answer is due 60 days after the waiver request was sent, or 90 days if the request was sent to a defendant outside the country (foreign is a boolean). A government defendant served personally gets 60 days instead of 21. The trigger day is excluded and a closed last day (weekend or listed holiday) moves to the next open day.

split: open-access


prompt:
A federal officer served personally is given only 21 days to answer.

Stipulated: with personal service the answer is due 21 days after service. When service is waived, the answer is due 60 days after the waiver request was sent, or 90 days if the request was sent to a defendant outside the country (foreign is a boolean). A government defendant served personally gets 60 days instead of 21. The trigger day is excluded and a closed last day (weekend or listed holiday) moves to the next open day.

split: open-access


prompt:
A waiver answer deadline falling on a Sunday is not extended.

Stipulated: with personal service the answer is due 21 days after service. When service is waived, the answer is due 60 days after the waiver request was sent, or 90 days if the request was sent to a defendant outside the country (foreign is a boolean). A government defendant served personally gets 60 days instead of 21. The trigger day is excluded and a closed last day (weekend or listed holiday) moves to the next open day.

split: open-access


prompt:
Serving on a court day lets the service day count toward the notice, allowing a hearing a day early.

Stipulated: a motion must be served at least notice_days court days before the hearing. Excluding the service day, count notice_days court days (not Saturday, Sunday or a listed holiday); then add calendar days for the service method (mail 5, mail-out-of-state 10, express 2, otherwise 0). If that day is not a court day, the earliest hearing is the next court day.

split: open-access


prompt:
A holiday inside the notice period is counted as a court day.

Stipulated: a motion must be served at least notice_days court days before the hearing. Excluding the service day, count notice_days court days (not Saturday, Sunday or a listed holiday); then add calendar days for the service method (mail 5, mail-out-of-state 10, express 2, otherwise 0). If that day is not a court day, the earliest hearing is the next court day.

split: open-access


prompt:
Out-of-state mail service gets only 5 extra days.

Stipulated: a motion must be served at least notice_days court days before the hearing. Excluding the service day, count notice_days court days (not Saturday, Sunday or a listed holiday); then add calendar days for the service method (mail 5, mail-out-of-state 10, express 2, otherwise 0). If that day is not a court day, the earliest hearing is the next court day.

split: open-access


prompt:
The earliest hearing is scheduled on a court holiday.

Stipulated: a motion must be served at least notice_days court days before the hearing. Excluding the service day, count notice_days court days (not Saturday, Sunday or a listed holiday); then add calendar days for the service method (mail 5, mail-out-of-state 10, express 2, otherwise 0). If that day is not a court day, the earliest hearing is the next court day.

split: open-access