broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else None
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d <= p:
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = max(d, p + dt.timedelta(days=60))
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, stay + dt.timedelta(days=30))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']])]]
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(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else None
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d < p - dt.timedelta(days=1):
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = max(d, p + dt.timedelta(days=60))
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, stay + dt.timedelta(days=30))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']])]]
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 deadline falling on the petition date is treated as already expired.

Stipulated: for each deadline [kind, date] and petition date p: a deadline before p had already expired and is returned as [date, "expired"]. An "act" deadline becomes the later of its date and p + 60 days. A "collection" deadline becomes the later of its date and stay_end + 30 days; if stay_end is None it is "stayed". Return [date or None, status] per deadline, status "extended" when the date moved and "unchanged" otherwise.

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(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else None
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d < p:
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = p + dt.timedelta(days=60)
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, stay + dt.timedelta(days=30))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']])]]
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(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else None
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d < p:
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = d + dt.timedelta(days=60)
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, stay + dt.timedelta(days=30))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']])]]
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 deadline already more than 60 days after the petition is shortened.

Stipulated: for each deadline [kind, date] and petition date p: a deadline before p had already expired and is returned as [date, "expired"]. An "act" deadline becomes the later of its date and p + 60 days. A "collection" deadline becomes the later of its date and stay_end + 30 days; if stay_end is None it is "stayed". Return [date or None, status] per deadline, status "extended" when the date moved and "unchanged" otherwise.

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(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else p
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d < p:
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = max(d, p + dt.timedelta(days=60))
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, stay + dt.timedelta(days=30))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']])]]
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(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else p + dt.timedelta(days=60)
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d < p:
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = max(d, p + dt.timedelta(days=60))
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, stay + dt.timedelta(days=30))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']])]]
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 collection deadline with the stay still in force is given a computed date.

Stipulated: for each deadline [kind, date] and petition date p: a deadline before p had already expired and is returned as [date, "expired"]. An "act" deadline becomes the later of its date and p + 60 days. A "collection" deadline becomes the later of its date and stay_end + 30 days; if stay_end is None it is "stayed". Return [date or None, status] per deadline, status "extended" when the date moved and "unchanged" otherwise.

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(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else None
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d < p:
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = max(d, p + dt.timedelta(days=60))
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, p + dt.timedelta(days=30))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']])]]
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(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else None
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d < p:
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = max(d, p + dt.timedelta(days=60))
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, max(p, d) + dt.timedelta(days=30))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']])]]
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:
Collection deadlines are extended from the petition date rather than the end of the stay.

Stipulated: for each deadline [kind, date] and petition date p: a deadline before p had already expired and is returned as [date, "expired"]. An "act" deadline becomes the later of its date and p + 60 days. A "collection" deadline becomes the later of its date and stay_end + 30 days; if stay_end is None it is "stayed". Return [date or None, status] per deadline, status "extended" when the date moved and "unchanged" otherwise.

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(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else None
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d < p:
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = max(d, p + dt.timedelta(days=60))
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, stay + dt.timedelta(days=60))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']])]]
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(petition, stay_end, deadlines):
    p = dt.date.fromisoformat(petition)
    out = []
    stay = dt.date.fromisoformat(stay_end) if stay_end else None
    for kind, due in deadlines:
        d = dt.date.fromisoformat(due)
        if d < p:
            out.append([due, 'expired'])
            continue
        if kind == 'act':
            new = max(d, p + dt.timedelta(days=60))
        elif stay is None:
            out.append([None, 'stayed'])
            continue
        else:
            new = max(d, stay + dt.timedelta(days=29))
        out.append([new.isoformat(), 'extended' if new != d else 'unchanged'])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']])],
 [('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']])],
 [('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']]),
  ('collection stay pending',
   ['2024-03-01', None, [['collection', '2024-03-15'], ['act', '2024-03-20']]],
   [[None, 'stayed'], ['2024-04-30', 'extended']]),
  ('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']])],
 [('collection late anyway',
   ['2024-03-01', '2024-04-01', [['collection', '2024-06-30']]],
   [['2024-06-30', 'unchanged']]),
  ('mixed list',
   ['2024-05-10', '2024-05-20', [['act', '2024-05-01'], ['collection', '2024-05-12'], ['act', '2024-08-01']]],
   [['2024-05-01', 'expired'], ['2024-06-19', 'extended'], ['2024-08-01', 'unchanged']]),
  ('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']])],
 [('collection due after petition before stay end',
   ['2024-01-10', '2024-02-05', [['collection', '2024-02-01']]],
   [['2024-03-06', 'extended']]),
  ('stay pending act only', ['2024-02-01', None, [['act', '2024-02-02']]], [['2024-04-01', 'extended']]),
  ('regression: late act deadline',
   ['2024-03-01', '2024-06-01', [['act', '2024-07-15']]],
   [['2024-07-15', 'unchanged']]),
  ('act soon after petition',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-10']]],
   [['2024-04-30', 'extended']]),
  ('deadline on petition date',
   ['2024-03-01', '2024-06-01', [['act', '2024-03-01']]],
   [['2024-04-30', 'extended']]),
  ('expired day before', ['2024-03-01', '2024-06-01', [['act', '2024-02-29']]], [['2024-02-29', 'expired']]),
  ('collection after stay',
   ['2024-03-01', '2024-06-01', [['collection', '2024-03-15']]],
   [['2024-07-01', 'extended']])]]
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:
Collection deadlines receive the 60-day act extension.

Stipulated: for each deadline [kind, date] and petition date p: a deadline before p had already expired and is returned as [date, "expired"]. An "act" deadline becomes the later of its date and p + 60 days. A "collection" deadline becomes the later of its date and stay_end + 30 days; if stay_end is None it is "stayed". Return [date or None, status] per deadline, status "extended" when the date moved and "unchanged" otherwise.

split: open-access


prompt:
A partnership return is scheduled a month late.

Stipulated: a return for a fiscal year ending fy_end (month end) is due on the 15th day of the 3rd month after year end for a partnership and the 4th month for other entities. A statutory date on a weekend or listed holiday moves to the next open day. An extension request filed on or before that (moved) due date extends the due date to 6 months after the statutory (unmoved) date, again moved forward if closed.

split: open-access


prompt:
An extension requested on the Monday after a weekend statutory date is rejected.

Stipulated: a return for a fiscal year ending fy_end (month end) is due on the 15th day of the 3rd month after year end for a partnership and the 4th month for other entities. A statutory date on a weekend or listed holiday moves to the next open day. An extension request filed on or before that (moved) due date extends the due date to 6 months after the statutory (unmoved) date, again moved forward if closed.

split: open-access


source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(fy_end, entity, requested, holidays):
    e = dt.date.fromisoformat(fy_end)
    hol = {dt.date.fromisoformat(x) for x in holidays}
    def roll(d):
        while d.weekday() >= 5 or d in hol:
            d += dt.timedelta(days=1)
        return d
    def plus_months(d, k):
        mi = d.month - 1 + k
        return dt.date(d.year + mi // 12, mi % 12 + 1, d.day)
    statutory = plus_months(dt.date(e.year, e.month, 15), 3 if entity == 'partnership' else 4)
    due = roll(statutory)
    if requested is not None and dt.date.fromisoformat(requested) <= due:
        due = roll(plus_months(due - dt.timedelta(days=due.weekday() - 4) if due.weekday() == 0 else due, 6))
    return due.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: statutory saturday, extension',
   ['2022-12-31',
    'corporation',
    '2023-04-17',
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25']],
   '2023-10-16'),
  ('partnership calendar year',
   ['2023-12-31',
    'partnership',
    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-15'),
  ('partnership extension',
   ['2023-12-31',
    'partnership',
    '2024-03-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-09-16'),
  ('corporation june year',
   ['2024-06-30',
    'corporation',
    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-10-15'),
  ('request on due date',
   ['2023-12-31',
    'corporation',
    '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-10-15'),
  ('late request',
   ['2023-12-31',
    'corporation',
    '2024-04-16',
    ['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-15'),
  ('statutory on holiday',
   ['2023-12-31',
    'individual',
    '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-04-15']],
   '2024-10-15')],
 [('partnership extension',
   ['2023-12-31',
    'partnership',
    '2024-03-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-09-16'),
  ('corporation june year',
   ['2024-06-30',
    'corporation',
    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-10-15'),
  ('request on due date',
   ['2023-12-31',
    'corporation',
    '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-10-15'),
  ('late request',
   ['2023-12-31',
    'corporation',
    '2024-04-16',
    ['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-15'),
  ('statutory on holiday',
   ['2023-12-31',
    'individual',
    '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-04-15']],
   '2024-10-15'),
  ('march fiscal year corporation',
   ['2024-03-31',
    'corporation',
    '2024-07-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']],
   '2025-01-15'),
  ('september fiscal partnership',
   ['2023-09-30',
    'partnership',
    '2023-12-15',
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '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-06-17')],
 [('request on due date',
   ['2023-12-31',
    'corporation',
    '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-10-15'),
  ('late request',
   ['2023-12-31',
    'corporation',
    '2024-04-16',
    ['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-15'),
  ('statutory on holiday',
   ['2023-12-31',
    'individual',
    '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-04-15']],
   '2024-10-15'),
  ('march fiscal year corporation',
   ['2024-03-31',
    'corporation',
    '2024-07-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']],
   '2025-01-15'),
  ('september fiscal partnership',
   ['2023-09-30',
    'partnership',
    '2023-12-15',
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '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-06-17'),
  ('regression: statutory saturday, extension',
   ['2022-12-31',
    'corporation',
    '2023-04-17',
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25']],
   '2023-10-16'),
  ('partnership calendar year',
   ['2023-12-31',
    'partnership',
    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-15')],
 [('statutory on holiday',
   ['2023-12-31',
    'individual',
    '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-04-15']],
   '2024-10-15'),
  ('march fiscal year corporation',
   ['2024-03-31',
    'corporation',
    '2024-07-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']],
   '2025-01-15'),
  ('september fiscal partnership',
   ['2023-09-30',
    'partnership',
    '2023-12-15',
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '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-06-17'),
  ('regression: statutory saturday, extension',
   ['2022-12-31',
    'corporation',
    '2023-04-17',
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25']],
   '2023-10-16'),
  ('partnership calendar year',
   ['2023-12-31',
    'partnership',
    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-15'),
  ('partnership extension',
   ['2023-12-31',
    'partnership',
    '2024-03-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-09-16'),
  ('corporation june year',
   ['2024-06-30',
    'corporation',
    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-10-15')],
 [('september fiscal partnership',
   ['2023-09-30',
    'partnership',
    '2023-12-15',
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25',
     '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-06-17'),
  ('regression: statutory saturday, extension',
   ['2022-12-31',
    'corporation',
    '2023-04-17',
    ['2023-01-02',
     '2023-01-16',
     '2023-02-20',
     '2023-05-29',
     '2023-06-19',
     '2023-07-04',
     '2023-09-04',
     '2023-10-09',
     '2023-11-10',
     '2023-11-23',
     '2023-12-25']],
   '2023-10-16'),
  ('partnership calendar year',
   ['2023-12-31',
    'partnership',
    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-15'),
  ('partnership extension',
   ['2023-12-31',
    'partnership',
    '2024-03-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-09-16'),
  ('corporation june year',
   ['2024-06-30',
    'corporation',
    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-10-15'),
  ('request on due date',
   ['2023-12-31',
    'corporation',
    '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-10-15'),
  ('late request',
   ['2023-12-31',
    'corporation',
    '2024-04-16',
    ['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-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:
When the original due date was moved off a weekend, the extended due date is moved as well.

Stipulated: a return for a fiscal year ending fy_end (month end) is due on the 15th day of the 3rd month after year end for a partnership and the 4th month for other entities. A statutory date on a weekend or listed holiday moves to the next open day. An extension request filed on or before that (moved) due date extends the due date to 6 months after the statutory (unmoved) date, again moved forward if closed.

split: open-access