broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(start, days_allowed, pauses):
    st = dt.date.fromisoformat(start)
    paused = set()
    open_ended = None
    for a, b in pauses:
        a = dt.date.fromisoformat(a)
        if b is None:
            open_ended = a if open_ended is None else a
            continue
        b = dt.date.fromisoformat(b)
        for i in range((b - a).days):
            paused.add(a + dt.timedelta(days=i))
    d = st
    counted = 0
    while counted < days_allowed:
        d += dt.timedelta(days=1)
        if open_ended is not None and d >= open_ended:
            return None
        if d in paused:
            continue
        counted += 1
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11')],
 [('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15')],
 [('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('earlier open-ended listed first',
   ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]],
   None)],
 [('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('earlier open-ended listed first',
   ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]],
   None)],
 [('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('earlier open-ended listed first',
   ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]],
   None)]]
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(start, days_allowed, pauses):
    st = dt.date.fromisoformat(start)
    paused = set()
    open_ended = None
    for a, b in pauses:
        a = dt.date.fromisoformat(a)
        if b is None:
            open_ended = a if open_ended is None else max(open_ended, a)
            continue
        b = dt.date.fromisoformat(b)
        for i in range((b - a).days):
            paused.add(a + dt.timedelta(days=i))
    d = st
    counted = 0
    while counted < days_allowed:
        d += dt.timedelta(days=1)
        if open_ended is not None and d >= open_ended:
            return None
        if d in paused:
            continue
        counted += 1
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11')],
 [('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15')],
 [('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('earlier open-ended listed first',
   ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]],
   None)],
 [('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('earlier open-ended listed first',
   ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]],
   None)],
 [('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('earlier open-ended listed first',
   ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]],
   None)]]
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:
With two open-ended stops, the review is reported as expiring although an earlier stop froze it.

Stipulated: a review has days_allowed clock days, counted from the day after start. A pause [stop, resume] stops the clock on the stop day and every day before the resume day; the resume day counts. A pause with resume None is open-ended and starts on its stop day; if the clock would reach a day on or after the earliest open-ended stop before expiring, the result is None. Return the date of the last clock 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(start, days_allowed, pauses):
    st = dt.date.fromisoformat(start)
    paused = set()
    open_ended = None
    for a, b in pauses:
        a = dt.date.fromisoformat(a)
        if b is None:
            open_ended = a if open_ended is None else min(open_ended, a)
            continue
        b = dt.date.fromisoformat(b)
        for i in range((b - a).days + 1):
            paused.add(a + dt.timedelta(days=i))
    d = st
    counted = 0
    while counted < days_allowed:
        d += dt.timedelta(days=1)
        if open_ended is not None and d >= open_ended:
            return None
        if d in paused:
            continue
        counted += 1
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11')],
 [('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15')],
 [('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14')],
 [('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None)],
 [('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31')]]
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(start, days_allowed, pauses):
    st = dt.date.fromisoformat(start)
    paused = set()
    open_ended = None
    for a, b in pauses:
        a = dt.date.fromisoformat(a)
        if b is None:
            open_ended = a if open_ended is None else min(open_ended, a)
            continue
        b = dt.date.fromisoformat(b)
        for i in range((b - a).days - 1):
            paused.add(a + dt.timedelta(days=i))
    d = st
    counted = 0
    while counted < days_allowed:
        d += dt.timedelta(days=1)
        if open_ended is not None and d >= open_ended:
            return None
        if d in paused:
            continue
        counted += 1
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11')],
 [('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15')],
 [('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14')],
 [('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None)],
 [('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31')]]
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 clock loses a day for every pause because the resume day is not counted.

Stipulated: a review has days_allowed clock days, counted from the day after start. A pause [stop, resume] stops the clock on the stop day and every day before the resume day; the resume day counts. A pause with resume None is open-ended and starts on its stop day; if the clock would reach a day on or after the earliest open-ended stop before expiring, the result is None. Return the date of the last clock 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(start, days_allowed, pauses):
    st = dt.date.fromisoformat(start)
    paused = set()
    open_ended = None
    for a, b in pauses:
        a = dt.date.fromisoformat(a)
        if b is None:
            open_ended = a if open_ended is None else min(open_ended, a)
            continue
        b = dt.date.fromisoformat(b)
        for i in range((b - a).days):
            paused.add(a + dt.timedelta(days=i))
    d = st - dt.timedelta(days=1)
    counted = 0
    while counted < days_allowed:
        d += dt.timedelta(days=1)
        if open_ended is not None and d >= open_ended:
            return None
        if d in paused:
            continue
        counted += 1
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11')],
 [('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15')],
 [('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14')],
 [('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None)],
 [('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31')]]
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(start, days_allowed, pauses):
    st = dt.date.fromisoformat(start)
    paused = set()
    open_ended = None
    for a, b in pauses:
        a = dt.date.fromisoformat(a)
        if b is None:
            open_ended = a if open_ended is None else min(open_ended, a)
            continue
        b = dt.date.fromisoformat(b)
        for i in range((b - a).days):
            paused.add(a + dt.timedelta(days=i))
    d = st - dt.timedelta(days=1) if st.weekday() < 5 else st
    counted = 0
    while counted < days_allowed:
        d += dt.timedelta(days=1)
        if open_ended is not None and d >= open_ended:
            return None
        if d in paused:
            continue
        counted += 1
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11')],
 [('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15')],
 [('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14')],
 [('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None)],
 [('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31')]]
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 review expires a day early because the submission day is counted.

Stipulated: a review has days_allowed clock days, counted from the day after start. A pause [stop, resume] stops the clock on the stop day and every day before the resume day; the resume day counts. A pause with resume None is open-ended and starts on its stop day; if the clock would reach a day on or after the earliest open-ended stop before expiring, the result is None. Return the date of the last clock 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(start, days_allowed, pauses):
    st = dt.date.fromisoformat(start)
    paused = set()
    open_ended = None
    for a, b in pauses:
        a = dt.date.fromisoformat(a)
        if b is None:
            open_ended = a if open_ended is None else min(open_ended, a)
            continue
        b = dt.date.fromisoformat(b)
        for i in range((b - a).days):
            paused.add(a + dt.timedelta(days=i))
    d = st
    counted = 0
    while counted < days_allowed:
        d += dt.timedelta(days=1)
        if open_ended is not None and d > open_ended:
            return None
        if d in paused:
            continue
        counted += 1
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11')],
 [('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15')],
 [('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14')],
 [('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None)],
 [('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31')]]
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(start, days_allowed, pauses):
    st = dt.date.fromisoformat(start)
    paused = set()
    open_ended = None
    for a, b in pauses:
        a = dt.date.fromisoformat(a)
        if b is None:
            open_ended = a if open_ended is None else min(open_ended, a)
            continue
        b = dt.date.fromisoformat(b)
        for i in range((b - a).days):
            paused.add(a + dt.timedelta(days=i))
    d = st
    counted = 0
    while counted < days_allowed:
        d += dt.timedelta(days=1)
        if open_ended is not None and d >= open_ended + dt.timedelta(days=1):
            return None
        if d in paused:
            continue
        counted += 1
    return d.isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31'),
  ('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11')],
 [('two open-ended stops', ['2024-01-01', 30, [['2024-01-20', None], ['2024-01-10', None]]], None),
  ('earlier open-ended listed first', ['2024-01-01', 12, [['2024-01-10', None], ['2024-01-20', None]]], None),
  ('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15')],
 [('open-ended after expiry', ['2024-01-01', 10, [['2024-01-20', None]]], '2024-01-11'),
  ('open-ended on last day', ['2024-01-01', 10, [['2024-01-11', None]]], None),
  ('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14')],
 [('open-ended the day after', ['2024-01-01', 10, [['2024-01-12', None]]], '2024-01-11'),
  ('overlapping pauses',
   ['2024-02-01', 15, [['2024-02-05', '2024-02-10'], ['2024-02-08', '2024-02-12']]],
   '2024-02-23'),
  ('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None)],
 [('pause before start', ['2024-03-10', 5, [['2024-03-01', '2024-03-05']]], '2024-03-15'),
  ('weekday start', ['2024-04-02', 7, []], '2024-04-09'),
  ('saturday start', ['2024-04-06', 7, [['2024-04-08', '2024-04-09']]], '2024-04-14'),
  ('pause then open-ended', ['2024-05-01', 20, [['2024-05-05', '2024-05-15'], ['2024-05-25', None]]], None),
  ('open-ended pushed by pause',
   ['2024-06-01', 10, [['2024-06-03', '2024-06-06'], ['2024-06-14', None]]],
   None),
  ('regression: pause resume day counts', ['2024-01-01', 10, [['2024-01-04', '2024-01-08']]], '2024-01-15'),
  ('no pauses', ['2024-01-01', 30, []], '2024-01-31')]]
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 review whose last clock day coincides with an open-ended stop is reported as expired on that day.

Stipulated: a review has days_allowed clock days, counted from the day after start. A pause [stop, resume] stops the clock on the stop day and every day before the resume day; the resume day counts. A pause with resume None is open-ended and starts on its stop day; if the clock would reach a day on or after the earliest open-ended stop before expiring, the result is None. Return the date of the last clock day.

split: open-access


prompt:
A non-accelerated filer is told its quarterly report is due five days early.

Stipulated: a fiscal year labelled year ends on the last day of fy_end_month in that year. Quarterly reports cover the first three fiscal quarters, which end on the last day of the months 9, 6 and 3 months before the fiscal year end; they are due 40 days after quarter end (45 for non-accelerated filers). The annual report is due 60/75/90 days after year end for large/accelerated/non-accelerated filers. Each due date on a weekend or listed holiday moves to the next open day. Return [Q1, Q2, Q3, annual].

split: open-access


prompt:
An accelerated filer's annual report is computed with the large-filer period.

Stipulated: a fiscal year labelled year ends on the last day of fy_end_month in that year. Quarterly reports cover the first three fiscal quarters, which end on the last day of the months 9, 6 and 3 months before the fiscal year end; they are due 40 days after quarter end (45 for non-accelerated filers). The annual report is due 60/75/90 days after year end for large/accelerated/non-accelerated filers. Each due date on a weekend or listed holiday moves to the next open day. Return [Q1, Q2, Q3, annual].

split: open-access


prompt:
A June fiscal year gets quarterly deadlines based on calendar quarters.

Stipulated: a fiscal year labelled year ends on the last day of fy_end_month in that year. Quarterly reports cover the first three fiscal quarters, which end on the last day of the months 9, 6 and 3 months before the fiscal year end; they are due 40 days after quarter end (45 for non-accelerated filers). The annual report is due 60/75/90 days after year end for large/accelerated/non-accelerated filers. Each due date on a weekend or listed holiday moves to the next open day. Return [Q1, Q2, Q3, annual].

split: open-access


prompt:
Quarters ending in 31-day months are treated as ending on the 30th.

Stipulated: a fiscal year labelled year ends on the last day of fy_end_month in that year. Quarterly reports cover the first three fiscal quarters, which end on the last day of the months 9, 6 and 3 months before the fiscal year end; they are due 40 days after quarter end (45 for non-accelerated filers). The annual report is due 60/75/90 days after year end for large/accelerated/non-accelerated filers. Each due date on a weekend or listed holiday moves to the next open day. Return [Q1, Q2, Q3, annual].

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(birth, accrual, years, cap_years):
    b = dt.date.fromisoformat(birth)
    acc = dt.date.fromisoformat(accrual)
    def anniversary(d, n):
        y = d.year + n
        return dt.date(y, d.month, min(d.day, calendar.monthrange(y, d.month)[1]))
    y18 = b.year + 18
    maj = dt.date(y18, 2, 28) if (b.month, b.day) == (2, 29) else dt.date(y18, b.month, b.day)
    start = maj if acc < maj else acc
    deadline = anniversary(start, years)
    cap = anniversary(acc, cap_years)
    return (min(deadline, cap)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05')],
 [('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01')],
 [('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20')],
 [('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01')],
 [('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01')]]
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 claimant born on February 29 is treated as an adult on February 28.

Stipulated: a claimant reaches majority on the 18th birthday; someone born February 29 reaches it on March 1 in a common year. If the claim accrues before majority, the period starts at majority, otherwise at accrual. The deadline is the anniversary of the start after years (a missing February 29 becomes February 28). Regardless of minority, the deadline may not exceed cap_years after accrual (same anniversary rule).

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(birth, accrual, years, cap_years):
    b = dt.date.fromisoformat(birth)
    acc = dt.date.fromisoformat(accrual)
    def anniversary(d, n):
        y = d.year + n
        return dt.date(y, d.month, min(d.day, calendar.monthrange(y, d.month)[1]))
    y18 = b.year + 18
    maj = dt.date(y18, 3, 1) if (b.month, b.day) == (2, 29) and not calendar.isleap(y18) else dt.date(y18, b.month, b.day)
    start = acc if (acc - b).days >= 18 * 365 else maj
    deadline = anniversary(start, years)
    cap = anniversary(acc, cap_years)
    return (min(deadline, cap)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05')],
 [('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20')],
 [('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20')],
 [('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01')],
 [('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01')]]
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(birth, accrual, years, cap_years):
    b = dt.date.fromisoformat(birth)
    acc = dt.date.fromisoformat(accrual)
    def anniversary(d, n):
        y = d.year + n
        return dt.date(y, d.month, min(d.day, calendar.monthrange(y, d.month)[1]))
    y18 = b.year + 18
    maj = dt.date(y18, 3, 1) if (b.month, b.day) == (2, 29) and not calendar.isleap(y18) else dt.date(y18, b.month, b.day)
    start = maj if acc.year < maj.year else acc
    deadline = anniversary(start, years)
    cap = anniversary(acc, cap_years)
    return (min(deadline, cap)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05')],
 [('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20')],
 [('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20')],
 [('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01')],
 [('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01')]]
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 claim accruing days before the 18th birthday is treated as an adult claim.

Stipulated: a claimant reaches majority on the 18th birthday; someone born February 29 reaches it on March 1 in a common year. If the claim accrues before majority, the period starts at majority, otherwise at accrual. The deadline is the anniversary of the start after years (a missing February 29 becomes February 28). Regardless of minority, the deadline may not exceed cap_years after accrual (same anniversary rule).

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(birth, accrual, years, cap_years):
    b = dt.date.fromisoformat(birth)
    acc = dt.date.fromisoformat(accrual)
    def anniversary(d, n):
        y = d.year + n
        return dt.date(y, d.month, min(d.day, calendar.monthrange(y, d.month)[1]))
    y18 = b.year + 18
    maj = dt.date(y18, 3, 1) if (b.month, b.day) == (2, 29) and not calendar.isleap(y18) else dt.date(y18, b.month, b.day)
    start = maj if acc < maj else acc
    deadline = anniversary(start, years)
    cap = anniversary(maj, cap_years)
    return (min(deadline, cap)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05')],
 [('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01')],
 [('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01')],
 [('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01')],
 [('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01')]]
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(birth, accrual, years, cap_years):
    b = dt.date.fromisoformat(birth)
    acc = dt.date.fromisoformat(accrual)
    def anniversary(d, n):
        y = d.year + n
        return dt.date(y, d.month, min(d.day, calendar.monthrange(y, d.month)[1]))
    y18 = b.year + 18
    maj = dt.date(y18, 3, 1) if (b.month, b.day) == (2, 29) and not calendar.isleap(y18) else dt.date(y18, b.month, b.day)
    start = maj if acc < maj else acc
    deadline = anniversary(start, years)
    cap = anniversary(start, cap_years)
    return (min(deadline, cap)).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05')],
 [('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01')],
 [('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01')],
 [('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01')],
 [('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01')]]
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 absolute cap is measured from majority, letting tolled claims run past the cap.

Stipulated: a claimant reaches majority on the 18th birthday; someone born February 29 reaches it on March 1 in a common year. If the claim accrues before majority, the period starts at majority, otherwise at accrual. The deadline is the anniversary of the start after years (a missing February 29 becomes February 28). Regardless of minority, the deadline may not exceed cap_years after accrual (same anniversary rule).

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(birth, accrual, years, cap_years):
    b = dt.date.fromisoformat(birth)
    acc = dt.date.fromisoformat(accrual)
    def anniversary(d, n):
        y = d.year + n
        return dt.date(y, d.month, min(d.day, calendar.monthrange(y, d.month)[1]))
    y18 = b.year + 18
    maj = dt.date(y18, 3, 1) if (b.month, b.day) == (2, 29) and not calendar.isleap(y18) else dt.date(y18, b.month, b.day)
    start = maj if acc < maj else acc
    deadline = anniversary(start, years)
    cap = anniversary(acc, cap_years)
    return (deadline).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05')],
 [('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01')],
 [('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01')],
 [('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01')],
 [('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01')]]
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(birth, accrual, years, cap_years):
    b = dt.date.fromisoformat(birth)
    acc = dt.date.fromisoformat(accrual)
    def anniversary(d, n):
        y = d.year + n
        return dt.date(y, d.month, min(d.day, calendar.monthrange(y, d.month)[1]))
    y18 = b.year + 18
    maj = dt.date(y18, 3, 1) if (b.month, b.day) == (2, 29) and not calendar.isleap(y18) else dt.date(y18, b.month, b.day)
    start = maj if acc < maj else acc
    deadline = anniversary(start, years)
    cap = anniversary(acc, cap_years)
    return (min(deadline, cap) if years > cap_years else deadline).isoformat()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05')],
 [('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01')],
 [('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01'),
  ('accrual in majority year before birthday', ['2006-11-30', '2024-02-01', 2, 6], '2026-11-30'),
  ('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01')],
 [('accrual on majority date', ['2006-05-05', '2024-05-05', 2, 8], '2026-05-05'),
  ('teen within cap', ['2009-09-09', '2024-01-15', 2, 10], '2029-09-09'),
  ('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01')],
 [('leap birthday accrual early', ['2004-02-29', '2021-12-01', 3, 10], '2025-03-01'),
  ('cap equals tolled', ['2010-07-07', '2020-07-07', 2, 10], '2030-07-07'),
  ('regression: accrual days before 18th birthday', ['2006-06-20', '2024-06-17', 2, 8], '2026-06-20'),
  ('leap birthday common majority year', ['2004-02-29', '2020-05-01', 2, 8], '2024-03-01'),
  ('leap birthday leap majority year', ['2008-02-29', '2025-01-01', 1, 8], '2027-03-01'),
  ('young child capped', ['2015-03-10', '2016-04-01', 3, 8], '2024-04-01'),
  ('adult claim', ['1990-01-01', '2024-01-01', 2, 8], '2026-01-01')]]
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 minor's tolled deadline extends beyond the absolute cap.

Stipulated: a claimant reaches majority on the 18th birthday; someone born February 29 reaches it on March 1 in a common year. If the claim accrues before majority, the period starts at majority, otherwise at accrual. The deadline is the anniversary of the start after years (a missing February 29 becomes February 28). Regardless of minority, the deadline may not exceed cap_years after accrual (same anniversary rule).

split: open-access


prompt:
A notice sent at 15:30 in New York is treated as received before a 17:00 cutoff in London.

Stipulated: a notice is sent at a local time in the sender zone (sender_offset_min east of UTC) and is received at the same instant in the recipient zone (recipient_offset_min). Received at or after the cutoff time (recipient local) it is deemed received the next day; a deemed day that is not a business day (weekday, not a listed holiday) moves to the next business day. The response window ends after n business days counted from the day after deemed receipt. Return [deemed receipt, response deadline].

split: open-access


prompt:
A notice received exactly at the 17:00 cutoff is deemed received that day.

Stipulated: a notice is sent at a local time in the sender zone (sender_offset_min east of UTC) and is received at the same instant in the recipient zone (recipient_offset_min). Received at or after the cutoff time (recipient local) it is deemed received the next day; a deemed day that is not a business day (weekday, not a listed holiday) moves to the next business day. The response window ends after n business days counted from the day after deemed receipt. Return [deemed receipt, response deadline].

split: open-access


prompt:
A notice received on a public holiday is deemed received that day.

Stipulated: a notice is sent at a local time in the sender zone (sender_offset_min east of UTC) and is received at the same instant in the recipient zone (recipient_offset_min). Received at or after the cutoff time (recipient local) it is deemed received the next day; a deemed day that is not a business day (weekday, not a listed holiday) moves to the next business day. The response window ends after n business days counted from the day after deemed receipt. Return [deemed receipt, response deadline].

split: open-access


prompt:
A notice received on Friday evening gets a response window counted from Friday.

Stipulated: a notice is sent at a local time in the sender zone (sender_offset_min east of UTC) and is received at the same instant in the recipient zone (recipient_offset_min). Received at or after the cutoff time (recipient local) it is deemed received the next day; a deemed day that is not a business day (weekday, not a listed holiday) moves to the next business day. The response window ends after n business days counted from the day after deemed receipt. Return [deemed receipt, response deadline].

split: open-access