broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = diff % period == 0 and diff // period < count
    if diff < 0:
        idx = 0
    else:
        idx = diff // period + 1
    if idx >= count:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0])]]
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(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = abs(diff) % period == 0 and diff // period < count
    if diff < 0:
        idx = 0
    else:
        idx = diff // period + 1
    if idx >= count:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0])]]
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 date two weeks before the first payday is reported as a payday.

A series occurs every interval_weeks weeks starting at anchor, for count occurrences. For a query date return [is_occurrence, next occurrence strictly after the query or None, 0-based index of that next occurrence or None]. Dates before the anchor are never occurrences; the next occurrence after a query before the anchor is the anchor itself.

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(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = diff >= 0 and diff % period == 0 and diff // period <= count
    if diff < 0:
        idx = 0
    else:
        idx = diff // period + 1
    if idx >= count:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, 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)

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(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = diff >= 0 and diff % period == 0 and diff < count * 7
    if diff < 0:
        idx = 0
    else:
        idx = diff // period + 1
    if idx >= count:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, 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:
The date one period after the final occurrence is still reported as an occurrence.

A series occurs every interval_weeks weeks starting at anchor, for count occurrences. For a query date return [is_occurrence, next occurrence strictly after the query or None, 0-based index of that next occurrence or None]. Dates before the anchor are never occurrences; the next occurrence after a query before the anchor is the anchor itself.

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(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = diff >= 0 and diff % period == 0 and diff // period < count
    if diff <= 0:
        idx = 0
    else:
        idx = diff // period + 1
    if idx >= count:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1])]]
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(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = diff >= 0 and diff % period == 0 and diff // period < count
    if diff < 0 and diff % period != 0:
        idx = 0
    else:
        idx = diff // period + 1
    if idx >= count:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1])]]
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 query on the anchor date returns the anchor as the next occurrence instead of the following one.

A series occurs every interval_weeks weeks starting at anchor, for count occurrences. For a query date return [is_occurrence, next occurrence strictly after the query or None, 0-based index of that next occurrence or None]. Dates before the anchor are never occurrences; the next occurrence after a query before the anchor is the anchor itself.

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(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = diff >= 0 and diff % period == 0 and diff // period < count
    if diff < 0:
        idx = 0
    else:
        idx = -(-diff // period)
    if idx >= count:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1])]]
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(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = diff >= 0 and diff % period == 0 and diff // period < count
    if diff < 0:
        idx = 0
    else:
        idx = (diff + 1) // period + 1
    if idx >= count:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1])]]
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:
Querying on an occurrence date returns that same date as the next occurrence.

A series occurs every interval_weeks weeks starting at anchor, for count occurrences. For a query date return [is_occurrence, next occurrence strictly after the query or None, 0-based index of that next occurrence or None]. Dates before the anchor are never occurrences; the next occurrence after a query before the anchor is the anchor itself.

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(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = diff >= 0 and diff % period == 0 and diff // period < count
    if diff < 0:
        idx = 0
    else:
        idx = diff // period + 1
    if idx > count:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, 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(anchor, interval_weeks, count, query):
    a = dt.date.fromisoformat(anchor)
    q = dt.date.fromisoformat(query)
    period = 7 * interval_weeks
    diff = (q - a).days
    is_occ = diff >= 0 and diff % period == 0 and diff // period < count
    if diff < 0:
        idx = 0
    else:
        idx = diff // period + 1
    if idx >= count - 1:
        return [is_occ, None, None]
    return [is_occ, (a + dt.timedelta(days=idx * period)).isoformat(), idx]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on anchor', ['2024-01-05', 2, 10, '2024-01-05'], [True, '2024-01-19', 1]),
  ('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3])],
 [('query on later occurrence', ['2024-01-05', 2, 10, '2024-02-02'], [True, '2024-02-16', 3]),
  ('day before occurrence', ['2024-01-05', 2, 10, '2024-01-18'], [False, '2024-01-19', 1]),
  ('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3])],
 [('one period after last', ['2024-01-05', 2, 3, '2024-02-16'], [False, None, None]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None]),
  ('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3])],
 [('far before anchor', ['2024-01-05', 3, 4, '2023-11-01'], [False, '2024-01-05', 0]),
  ('weekly mid week', ['2024-03-04', 1, 5, '2024-03-13'], [False, '2024-03-18', 2]),
  ('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, None, None])],
 [('four-weekly aligned', ['2024-03-04', 4, 6, '2024-04-29'], [True, '2024-05-27', 3]),
  ('aligned before anchor weekly', ['2024-03-04', 1, 5, '2024-02-26'], [False, '2024-03-04', 0]),
  ('two periods before anchor', ['2024-01-05', 2, 10, '2023-12-08'], [False, '2024-01-05', 0]),
  ('three periods before anchor weekly', ['2024-03-04', 1, 5, '2024-02-12'], [False, '2024-03-04', 0]),
  ('beyond series end', ['2024-03-04', 1, 2, '2024-04-30'], [False, None, None]),
  ('penultimate occurrence', ['2024-06-07', 2, 4, '2024-07-05'], [True, '2024-07-19', 3]),
  ('regression: aligned date before anchor', ['2024-01-05', 2, 10, '2023-12-22'], [False, '2024-01-05', 0]),
  ('query on last occurrence', ['2024-01-05', 2, 3, '2024-02-02'], [True, 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:
After the final occurrence the lookup invents one more occurrence.

A series occurs every interval_weeks weeks starting at anchor, for count occurrences. For a query date return [is_occurrence, next occurrence strictly after the query or None, 0-based index of that next occurrence or None]. Dates before the anchor are never occurrences; the next occurrence after a query before the anchor is the anchor itself.

split: open-access


prompt:
BYHOUR=17,9 emits the evening slot before the morning slot and repeats duplicated hours.

FREQ=DAILY. Each day produces the cartesian product of BYHOUR and BYMINUTE in chronological order; a missing BYHOUR defaults to the dtstart hour and a missing BYMINUTE to the dtstart minute. Duplicates in either list are ignored. Times before dtstart are dropped. Return the first count ISO date-times.

split: open-access


prompt:
A rule with only BYMINUTE fires at midnight hours instead of the dtstart hour.

FREQ=DAILY. Each day produces the cartesian product of BYHOUR and BYMINUTE in chronological order; a missing BYHOUR defaults to the dtstart hour and a missing BYMINUTE to the dtstart minute. Duplicates in either list are ignored. Times before dtstart are dropped. Return the first count ISO date-times.

split: open-access


prompt:
A 09:30 series with BYHOUR=9,17 fires on the hour.

FREQ=DAILY. Each day produces the cartesian product of BYHOUR and BYMINUTE in chronological order; a missing BYHOUR defaults to the dtstart hour and a missing BYMINUTE to the dtstart minute. Duplicates in either list are ignored. Times before dtstart are dropped. Return the first count ISO date-times.

split: open-access


prompt:
Slots are emitted minute-major, out of chronological order, so COUNT keeps the wrong slots.

FREQ=DAILY. Each day produces the cartesian product of BYHOUR and BYMINUTE in chronological order; a missing BYHOUR defaults to the dtstart hour and a missing BYMINUTE to the dtstart minute. Duplicates in either list are ignored. Times before dtstart are dropped. Return the first count ISO date-times.

split: open-access


prompt:
Slots earlier on the dtstart day than dtstart are emitted.

FREQ=DAILY. Each day produces the cartesian product of BYHOUR and BYMINUTE in chronological order; a missing BYHOUR defaults to the dtstart hour and a missing BYMINUTE to the dtstart minute. Duplicates in either list are ignored. Times before dtstart are dropped. Return the first count ISO date-times.

split: open-access


prompt:
In years starting on Friday, Saturday or Sunday every week number is one week early.

FREQ=YEARLY with BYWEEKNO (ISO weeks, Monday start, week 1 contains January 4) and BYDAY weekdays (0=Monday). Negative week numbers count from the last ISO week of the year (-1 is the last). A year has 53 weeks exactly when December 28 falls in week 53; week numbers outside 1..weeks are ignored for that year. Dates may fall in the adjacent calendar year. Expand years year_start .. year_start+years-1 and return unique ISO dates sorted.

split: open-access


prompt:
BYWEEKNO=-1 is resolved to week 0 in years whose December 31 belongs to next year's week 1.

FREQ=YEARLY with BYWEEKNO (ISO weeks, Monday start, week 1 contains January 4) and BYDAY weekdays (0=Monday). Negative week numbers count from the last ISO week of the year (-1 is the last). A year has 53 weeks exactly when December 28 falls in week 53; week numbers outside 1..weeks are ignored for that year. Dates may fall in the adjacent calendar year. Expand years year_start .. year_start+years-1 and return unique ISO dates sorted.

split: open-access


prompt:
BYWEEKNO=-1 selects the second-to-last ISO week.

FREQ=YEARLY with BYWEEKNO (ISO weeks, Monday start, week 1 contains January 4) and BYDAY weekdays (0=Monday). Negative week numbers count from the last ISO week of the year (-1 is the last). A year has 53 weeks exactly when December 28 falls in week 53; week numbers outside 1..weeks are ignored for that year. Dates may fall in the adjacent calendar year. Expand years year_start .. year_start+years-1 and return unique ISO dates sorted.

split: open-access


prompt:
BYWEEKNO=53 in a 52-week year produces dates in the next year's week 1.

FREQ=YEARLY with BYWEEKNO (ISO weeks, Monday start, week 1 contains January 4) and BYDAY weekdays (0=Monday). Negative week numbers count from the last ISO week of the year (-1 is the last). A year has 53 weeks exactly when December 28 falls in week 53; week numbers outside 1..weeks are ignored for that year. Dates may fall in the adjacent calendar year. Expand years year_start .. year_start+years-1 and return unique ISO dates sorted.

split: open-access


prompt:
BYWEEKNO=20;BYDAY=MO produces Tuesdays.

FREQ=YEARLY with BYWEEKNO (ISO weeks, Monday start, week 1 contains January 4) and BYDAY weekdays (0=Monday). Negative week numbers count from the last ISO week of the year (-1 is the last). A year has 53 weeks exactly when December 28 falls in week 53; week numbers outside 1..weeks are ignored for that year. Dates may fall in the adjacent calendar year. Expand years year_start .. year_start+years-1 and return unique ISO dates sorted.

split: open-access


prompt:
A day-29 series applies the skip policy in leap-year February instead of using February 29.

FREQ=MONTHLY on a fixed monthday from the dtstart month. When the day does not exist in a month, skip decides: OMIT (also the default when skip is None) drops the month, BACKWARD uses the last day of the month, FORWARD uses the first day of the following month. February has 29 days in leap years. Instances before dtstart are dropped. Return the first count ISO dates.

split: open-access


prompt:
A series without an explicit skip policy moves missing days forward instead of omitting them.

FREQ=MONTHLY on a fixed monthday from the dtstart month. When the day does not exist in a month, skip decides: OMIT (also the default when skip is None) drops the month, BACKWARD uses the last day of the month, FORWARD uses the first day of the following month. February has 29 days in leap years. Instances before dtstart are dropped. Return the first count ISO dates.

split: open-access


prompt:
BACKWARD from the 31st lands on the 28th of 30-day months.

FREQ=MONTHLY on a fixed monthday from the dtstart month. When the day does not exist in a month, skip decides: OMIT (also the default when skip is None) drops the month, BACKWARD uses the last day of the month, FORWARD uses the first day of the following month. February has 29 days in leap years. Instances before dtstart are dropped. Return the first count ISO dates.

split: open-access


prompt:
FORWARD from February 31 lands on March 3 instead of March 1.

FREQ=MONTHLY on a fixed monthday from the dtstart month. When the day does not exist in a month, skip decides: OMIT (also the default when skip is None) drops the month, BACKWARD uses the last day of the month, FORWARD uses the first day of the following month. February has 29 days in leap years. Instances before dtstart are dropped. Return the first count ISO dates.

split: open-access


prompt:
BYDAY=FR;BYMONTHDAY=13 returns Thursday the 13th.

FREQ=MONTHLY with BYDAY weekday codes (MO..SU) and BYMONTHDAY values (negative counts from month end). When both are present a day must satisfy both; an empty list imposes no restriction. Days are examined from dtstart forward. Return the first count ISO dates (search bounded to 50 years).

split: open-access


prompt:
A rule with only BYMONTHDAY produces no instances.

FREQ=MONTHLY with BYDAY weekday codes (MO..SU) and BYMONTHDAY values (negative counts from month end). When both are present a day must satisfy both; an empty list imposes no restriction. Days are examined from dtstart forward. Return the first count ISO dates (search bounded to 50 years).

split: open-access


prompt:
BYMONTHDAY=-1 combined with BYDAY never matches.

FREQ=MONTHLY with BYDAY weekday codes (MO..SU) and BYMONTHDAY values (negative counts from month end). When both are present a day must satisfy both; an empty list imposes no restriction. Days are examined from dtstart forward. Return the first count ISO dates (search bounded to 50 years).

split: open-access


prompt:
BYDAY=FR;BYMONTHDAY=13 returns every Friday and every 13th.

FREQ=MONTHLY with BYDAY weekday codes (MO..SU) and BYMONTHDAY values (negative counts from month end). When both are present a day must satisfy both; an empty list imposes no restriction. Days are examined from dtstart forward. Return the first count ISO dates (search bounded to 50 years).

split: open-access


prompt:
A reminder configured 15 minutes before each meeting fires 15 minutes after it starts.

Occurrences start at dtstart + k*interval_hours for k < count. Each has one alarm at start + trigger_min minutes (negative means before the start). Occurrences whose start string (YYYY-MM-DDTHH:MM) is in acknowledged have no alarm. An alarm due at or before now is delivered at now if the occurrence has not started yet (start > now), otherwise dropped. Alarms due after now + horizon_hours are not scheduled. Return [occurrence_start, fire_time] pairs in series order.

split: open-access


prompt:
An alarm that fires inside the scheduling horizon is dropped because its occurrence starts after the horizon.

Occurrences start at dtstart + k*interval_hours for k < count. Each has one alarm at start + trigger_min minutes (negative means before the start). Occurrences whose start string (YYYY-MM-DDTHH:MM) is in acknowledged have no alarm. An alarm due at or before now is delivered at now if the occurrence has not started yet (start > now), otherwise dropped. Alarms due after now + horizon_hours are not scheduled. Return [occurrence_start, fire_time] pairs in series order.

split: open-access


prompt:
Acknowledging an occurrence does not silence its alarm.

Occurrences start at dtstart + k*interval_hours for k < count. Each has one alarm at start + trigger_min minutes (negative means before the start). Occurrences whose start string (YYYY-MM-DDTHH:MM) is in acknowledged have no alarm. An alarm due at or before now is delivered at now if the occurrence has not started yet (start > now), otherwise dropped. Alarms due after now + horizon_hours are not scheduled. Return [occurrence_start, fire_time] pairs in series order.

split: open-access


prompt:
A missed alarm for a meeting that has not started yet is silently dropped.

Occurrences start at dtstart + k*interval_hours for k < count. Each has one alarm at start + trigger_min minutes (negative means before the start). Occurrences whose start string (YYYY-MM-DDTHH:MM) is in acknowledged have no alarm. An alarm due at or before now is delivered at now if the occurrence has not started yet (start > now), otherwise dropped. Alarms due after now + horizon_hours are not scheduled. Return [occurrence_start, fire_time] pairs in series order.

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(dtstart, interval, count, until, offset_min):
    first = dt.datetime.fromisoformat(dtstart)
    if until is None:
        limit = None
    elif until.endswith('Z'):
        limit = dt.datetime.fromisoformat(until[:-1]) - dt.timedelta(minutes=offset_min)
    elif len(until) == 10:
        limit = dt.datetime.combine(dt.date.fromisoformat(until), dt.time(23, 59))
    else:
        limit = dt.datetime.fromisoformat(until)
    out = []
    for k in range(40):
        t = first + dt.timedelta(days=k * interval)
        if limit is not None and t > limit:
            break
        if count is not None and len(out) >= count:
            break
        out.append(t.isoformat(timespec='minutes'))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], [])],
 [('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30'])],
 [('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, interval, count, until, offset_min):
    first = dt.datetime.fromisoformat(dtstart)
    if until is None:
        limit = None
    elif until.endswith('Z'):
        limit = dt.datetime.fromisoformat(until[:-1])
    elif len(until) == 10:
        limit = dt.datetime.combine(dt.date.fromisoformat(until), dt.time(23, 59))
    else:
        limit = dt.datetime.fromisoformat(until)
    out = []
    for k in range(40):
        t = first + dt.timedelta(days=k * interval)
        if limit is not None and t > limit:
            break
        if count is not None and len(out) >= count:
            break
        out.append(t.isoformat(timespec='minutes'))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], [])],
 [('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30'])],
 [('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A UTC UNTIL in a zone east of UTC cuts off the last local instance.

A daily-interval timed series in a fixed local offset (offset_min east of UTC). until may be None, a date (inclusive through the end of that local day, i.e. 23:59), a local date-time (inclusive), or a UTC date-time ending in Z (converted to local by adding offset_min). count may be None; count 0 means no instances. When both are given the series stops at whichever limit is reached first. Unbounded series are capped at 40 instances. Return ISO local date-times.

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(dtstart, interval, count, until, offset_min):
    first = dt.datetime.fromisoformat(dtstart)
    if until is None:
        limit = None
    elif until.endswith('Z'):
        limit = dt.datetime.fromisoformat(until[:-1]) + dt.timedelta(minutes=offset_min)
    elif len(until) == 10:
        limit = dt.datetime.fromisoformat(until)
    else:
        limit = dt.datetime.fromisoformat(until)
    out = []
    for k in range(40):
        t = first + dt.timedelta(days=k * interval)
        if limit is not None and t > limit:
            break
        if count is not None and len(out) >= count:
            break
        out.append(t.isoformat(timespec='minutes'))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], [])],
 [('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00'])],
 [('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00'])],
 [('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, interval, count, until, offset_min):
    first = dt.datetime.fromisoformat(dtstart)
    if until is None:
        limit = None
    elif until.endswith('Z'):
        limit = dt.datetime.fromisoformat(until[:-1]) + dt.timedelta(minutes=offset_min)
    elif len(until) == 10:
        limit = dt.datetime.fromisoformat(until) + dt.timedelta(hours=12)
    else:
        limit = dt.datetime.fromisoformat(until)
    out = []
    for k in range(40):
        t = first + dt.timedelta(days=k * interval)
        if limit is not None and t > limit:
            break
        if count is not None and len(out) >= count:
            break
        out.append(t.isoformat(timespec='minutes'))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], [])],
 [('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00'])],
 [('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00'])],
 [('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A date-only UNTIL drops the instance at 09:00 on the UNTIL date.

A daily-interval timed series in a fixed local offset (offset_min east of UTC). until may be None, a date (inclusive through the end of that local day, i.e. 23:59), a local date-time (inclusive), or a UTC date-time ending in Z (converted to local by adding offset_min). count may be None; count 0 means no instances. When both are given the series stops at whichever limit is reached first. Unbounded series are capped at 40 instances. Return ISO local date-times.

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(dtstart, interval, count, until, offset_min):
    first = dt.datetime.fromisoformat(dtstart)
    if until is None:
        limit = None
    elif until.endswith('Z'):
        limit = dt.datetime.fromisoformat(until[:-1]) + dt.timedelta(minutes=offset_min)
    elif len(until) == 10:
        limit = dt.datetime.combine(dt.date.fromisoformat(until), dt.time(23, 59))
    else:
        limit = dt.datetime.fromisoformat(until)
    out = []
    for k in range(40):
        t = first + dt.timedelta(days=k * interval)
        if limit is not None and t >= limit:
            break
        if count is not None and len(out) >= count:
            break
        out.append(t.isoformat(timespec='minutes'))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], [])],
 [('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30'])],
 [('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, interval, count, until, offset_min):
    first = dt.datetime.fromisoformat(dtstart)
    if until is None:
        limit = None
    elif until.endswith('Z'):
        limit = dt.datetime.fromisoformat(until[:-1]) + dt.timedelta(minutes=offset_min)
    elif len(until) == 10:
        limit = dt.datetime.combine(dt.date.fromisoformat(until), dt.time(23, 59))
    else:
        limit = dt.datetime.fromisoformat(until)
    out = []
    for k in range(40):
        t = first + dt.timedelta(days=k * interval)
        if limit is not None and t.date() > limit.date():
            break
        if count is not None and len(out) >= count:
            break
        out.append(t.isoformat(timespec='minutes'))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], [])],
 [('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30'])],
 [('utc until west offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T15:30Z', -300],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('count zero', ['2024-01-01T09:00', 1, 0, None, 0], []),
  ('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('utc until east offset',
   ['2024-01-01T09:00', 1, None, '2024-01-03T07:00Z', 120],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])],
 [('count zero with until', ['2024-01-01T09:00', 1, 0, '2024-02-01', 0], []),
  ('until before count reached',
   ['2024-01-01T09:00', 3, 10, '2024-01-08', 0],
   ['2024-01-01T09:00', '2024-01-04T09:00', '2024-01-07T09:00']),
  ('count before until reached',
   ['2024-03-01T18:30', 7, 2, '2024-12-31T00:00Z', 60],
   ['2024-03-01T18:30', '2024-03-08T18:30']),
  ('regression: count and until both set',
   ['2024-01-01T09:00', 1, 3, '2024-01-10', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00']),
  ('date until includes that day',
   ['2024-01-01T09:00', 2, None, '2024-01-07', 0],
   ['2024-01-01T09:00', '2024-01-03T09:00', '2024-01-05T09:00', '2024-01-07T09:00']),
  ('date until evening event',
   ['2024-01-01T20:00', 1, None, '2024-01-03', 60],
   ['2024-01-01T20:00', '2024-01-02T20:00', '2024-01-03T20:00']),
  ('local until exact',
   ['2024-01-01T09:00', 1, None, '2024-01-04T09:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00', '2024-01-04T09:00']),
  ('local until earlier time',
   ['2024-01-01T09:00', 1, None, '2024-01-04T08:00', 0],
   ['2024-01-01T09:00', '2024-01-02T09:00', '2024-01-03T09:00'])]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An instance exactly at a date-time UNTIL is missing.

A daily-interval timed series in a fixed local offset (offset_min east of UTC). until may be None, a date (inclusive through the end of that local day, i.e. 23:59), a local date-time (inclusive), or a UTC date-time ending in Z (converted to local by adding offset_min). count may be None; count 0 means no instances. When both are given the series stops at whichever limit is reached first. Unbounded series are capped at 40 instances. Return ISO local date-times.

split: open-access