source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, weekdays, setpos, count):
    start = dt.date.fromisoformat(dtstart)
    out = []
    for k in range(240):
        mi = start.month - 1 + k
        y, m = start.year + mi // 12, mi % 12 + 1
        dim = calendar.monthrange(y, m)[1]
        cand = [x for x in [dt.date(y, m, d) for d in range(1, dim + 1)] if x.weekday() in weekdays and x >= dt.date(y, m, 1)]
        picked = []
        for p in setpos:
            idx = p - 1 if p > 0 else len(cand) + p
            if 0 <= idx < len(cand) and cand[idx] != (picked[-1] if picked else None):
                picked.append(cand[idx])
        for d in sorted(picked):
            if d < start:
                continue
            out.append(d.isoformat())
            if len(out) >= count:
                return out
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('first weekday, dtstart mid-month',
   ['2024-01-10', [0, 1, 2, 3, 4], [1], 3],
   ['2024-02-01', '2024-03-01', '2024-04-01']),
  ('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30'])],
 [('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27'])],
 [('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31'])],
 [('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31']),
  ('dtstart equals picked day', ['2024-05-31', [0, 1, 2, 3, 4], [-1], 2], ['2024-05-31', '2024-06-28']),
  ('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05'])],
 [('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31']),
  ('dtstart equals picked day', ['2024-05-31', [0, 1, 2, 3, 4], [-1], 2], ['2024-05-31', '2024-06-28']),
  ('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('first weekday, dtstart mid-month',
   ['2024-01-10', [0, 1, 2, 3, 4], [1], 3],
   ['2024-02-01', '2024-03-01', '2024-04-01']),
  ('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05'])]]
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:
BYSETPOS=1,-5 in a month with five candidates emits the same day twice.

FREQ=MONTHLY;BYDAY=<weekdays>;BYSETPOS=<positions>. For each month from the dtstart month, the candidate set is every day of the whole month whose weekday is listed, in date order. Positions are 1-based, negative from the end; out-of-range positions are ignored and positions naming the same day yield it once. Selected days are emitted chronologically; days before dtstart are dropped after selection. Return the first count ISO dates.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
BYSETPOS=-1,1 emits the last day before the first, and COUNT keeps the wrong instance.

FREQ=MONTHLY;BYDAY=<weekdays>;BYSETPOS=<positions>. For each month from the dtstart month, the candidate set is every day of the whole month whose weekday is listed, in date order. Positions are 1-based, negative from the end; out-of-range positions are ignored and positions naming the same day yield it once. Selected days are emitted chronologically; days before dtstart are dropped after selection. Return the first count ISO dates.

split: open-access


prompt:
A February 29 series reports an instance in 2100.

FREQ=YEARLY on a fixed month and day. Years are dtstart.year + k*interval. A year in which the date does not exist (for example February 29 in a common year) is skipped, never clamped. Gregorian leap years: divisible by 4, except centuries not divisible by 400. Instances before dtstart are dropped and the series ends at until (inclusive). Return ISO dates.

split: open-access


prompt:
An every-other-year series whose first-year date precedes dtstart runs in the wrong year parity.

FREQ=YEARLY on a fixed month and day. Years are dtstart.year + k*interval. A year in which the date does not exist (for example February 29 in a common year) is skipped, never clamped. Gregorian leap years: divisible by 4, except centuries not divisible by 400. Instances before dtstart are dropped and the series ends at until (inclusive). Return ISO dates.

split: open-access


prompt:
A leap-day series reports February 28 in common years.

FREQ=YEARLY on a fixed month and day. Years are dtstart.year + k*interval. A year in which the date does not exist (for example February 29 in a common year) is skipped, never clamped. Gregorian leap years: divisible by 4, except centuries not divisible by 400. Instances before dtstart are dropped and the series ends at until (inclusive). Return ISO dates.

split: open-access


prompt:
A series starting after the anniversary returns no instances at all.

FREQ=YEARLY on a fixed month and day. Years are dtstart.year + k*interval. A year in which the date does not exist (for example February 29 in a common year) is skipped, never clamped. Gregorian leap years: divisible by 4, except centuries not divisible by 400. Instances before dtstart are dropped and the series ends at until (inclusive). Return ISO dates.

split: open-access


prompt:
An instance falling exactly on UNTIL is missing.

FREQ=YEARLY on a fixed month and day. Years are dtstart.year + k*interval. A year in which the date does not exist (for example February 29 in a common year) is skipped, never clamped. Gregorian leap years: divisible by 4, except centuries not divisible by 400. Instances before dtstart are dropped and the series ends at until (inclusive). Return ISO dates.

split: open-access


prompt:
An EXDATE written with a time component does not remove the all-day instance.

All-day series: the rule yields exactly count instances dtstart + k*interval days (COUNT counts rule instances before exclusions; RDATEs never consume COUNT). The instance set is rule plus RDATE minus EXDATE; EXDATE also removes RDATEs. EXDATE values may carry a time part (YYYY-MM-DDTHH:MM:SS) and then exclude their calendar date. Return the unique dates sorted ascending.

split: open-access


prompt:
Excluding one instance of a COUNT=5 series pushes a sixth instance onto the calendar.

All-day series: the rule yields exactly count instances dtstart + k*interval days (COUNT counts rule instances before exclusions; RDATEs never consume COUNT). The instance set is rule plus RDATE minus EXDATE; EXDATE also removes RDATEs. EXDATE values may carry a time part (YYYY-MM-DDTHH:MM:SS) and then exclude their calendar date. Return the unique dates sorted ascending.

split: open-access


prompt:
Adding an RDATE removes the last rule instance.

All-day series: the rule yields exactly count instances dtstart + k*interval days (COUNT counts rule instances before exclusions; RDATEs never consume COUNT). The instance set is rule plus RDATE minus EXDATE; EXDATE also removes RDATEs. EXDATE values may carry a time part (YYYY-MM-DDTHH:MM:SS) and then exclude their calendar date. Return the unique dates sorted ascending.

split: open-access


prompt:
An EXDATE matching an RDATE leaves the RDATE on the calendar.

All-day series: the rule yields exactly count instances dtstart + k*interval days (COUNT counts rule instances before exclusions; RDATEs never consume COUNT). The instance set is rule plus RDATE minus EXDATE; EXDATE also removes RDATEs. EXDATE values may carry a time part (YYYY-MM-DDTHH:MM:SS) and then exclude their calendar date. Return the unique dates sorted ascending.

split: open-access


prompt:
An RDATE equal to a rule instance appears twice.

All-day series: the rule yields exactly count instances dtstart + k*interval days (COUNT counts rule instances before exclusions; RDATEs never consume COUNT). The instance set is rule plus RDATE minus EXDATE; EXDATE also removes RDATEs. EXDATE values may carry a time part (YYYY-MM-DDTHH:MM:SS) and then exclude their calendar date. Return the unique dates sorted ascending.

split: open-access


prompt:
Of two overrides for the same instance, the earlier edit wins.

A daily-interval series of count instances. overrides is an ordered list of [original_date, new_date] where new_date None cancels; for repeated originals the last override wins; overrides whose original is not a series instance are ignored. Return [original, actual] pairs for instances whose actual date lies in [window_start, window_end], sorted by actual then original date.

split: open-access


prompt:
An override for a date that is not an instance adds a phantom occurrence.

A daily-interval series of count instances. overrides is an ordered list of [original_date, new_date] where new_date None cancels; for repeated originals the last override wins; overrides whose original is not a series instance are ignored. Return [original, actual] pairs for instances whose actual date lies in [window_start, window_end], sorted by actual then original date.

split: open-access


prompt:
A cancelled instance still appears on the calendar.

A daily-interval series of count instances. overrides is an ordered list of [original_date, new_date] where new_date None cancels; for repeated originals the last override wins; overrides whose original is not a series instance are ignored. Return [original, actual] pairs for instances whose actual date lies in [window_start, window_end], sorted by actual then original date.

split: open-access


prompt:
An instance moved out of the window is still returned, and one moved into it is missing.

A daily-interval series of count instances. overrides is an ordered list of [original_date, new_date] where new_date None cancels; for repeated originals the last override wins; overrides whose original is not a series instance are ignored. Return [original, actual] pairs for instances whose actual date lies in [window_start, window_end], sorted by actual then original date.

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, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * new_interval)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, interval, count, until, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The new tail series begins on a date that was never an occurrence.

A daily-interval series (dtstart, interval, and either count or until). Editing from 0-based occurrence k splits it: the head keeps occurrences 0..k-1 (count k, or until = its last retained occurrence date) and the tail starts at the original date of occurrence k with new_interval and the remaining count (or the original until). k <= 0 makes the head None; a split at or past the end makes the tail None. Return {"head": [dtstart, count, until] or None, "tail": [start, interval, count, until] or None}.

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, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if count is not None and k >= count:
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': 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(dtstart, interval, count, until, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if (count is not None and k > count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': 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:
Splitting after the last occurrence of an UNTIL series creates an empty tail series past UNTIL.

A daily-interval series (dtstart, interval, and either count or until). Editing from 0-based occurrence k splits it: the head keeps occurrences 0..k-1 (count k, or until = its last retained occurrence date) and the tail starts at the original date of occurrence k with new_interval and the remaining count (or the original until). k <= 0 makes the head None; a split at or past the end makes the tail None. Return {"head": [dtstart, count, until] or None, "tail": [start, interval, count, until] or None}.

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, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, interval, count, until, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k - 1 if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The tail series repeats the full original COUNT and extends the series.

A daily-interval series (dtstart, interval, and either count or until). Editing from 0-based occurrence k splits it: the head keeps occurrences 0..k-1 (count k, or until = its last retained occurrence date) and the tail starts at the original date of occurrence k with new_interval and the remaining count (or the original until). k <= 0 makes the head None; a split at or past the end makes the tail None. Return {"head": [dtstart, count, until] or None, "tail": [start, interval, count, until] or None}.

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, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k < 0:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, interval, count, until, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k == 0 and count is not None:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Editing from the first occurrence leaves an empty head series behind.

A daily-interval series (dtstart, interval, and either count or until). Editing from 0-based occurrence k splits it: the head keeps occurrences 0..k-1 (count k, or until = its last retained occurrence date) and the tail starts at the original date of occurrence k with new_interval and the remaining count (or the original until). k <= 0 makes the head None; a split at or past the end makes the tail None. Return {"head": [dtstart, count, until] or None, "tail": [start, interval, count, until] or None}.

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, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k + 1, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, interval, count, until, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k - 1, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The split occurrence appears in both the head and the tail.

A daily-interval series (dtstart, interval, and either count or until). Editing from 0-based occurrence k splits it: the head keeps occurrences 0..k-1 (count k, or until = its last retained occurrence date) and the tail starts at the original date of occurrence k with new_interval and the remaining count (or the original until). k <= 0 makes the head None; a split at or past the end makes the tail None. Return {"head": [dtstart, count, until] or None, "tail": [start, interval, count, until] or None}.

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, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (tail_start).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, interval, count, until, k, new_interval):
    start = dt.date.fromisoformat(dtstart)
    until_d = dt.date.fromisoformat(until) if until else None
    tail_start = start + dt.timedelta(days=k * interval)
    if (count is not None and k >= count) or (until_d is not None and tail_start > until_d):
        tail = None
    else:
        tail = [tail_start.isoformat(), new_interval, count - k if count is not None else None, until]
    if k <= 0:
        head = None
    elif count is not None:
        head = [dtstart, k, None]
    else:
        head = [dtstart, None, (start + dt.timedelta(days=(k - 1) * new_interval)).isoformat()]
    return {'head': head, 'tail': tail}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']})],
 [('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']}),
  ('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']})],
 [('split exactly at count',
   ['2024-01-01', 1, 4, None, 4, 2],
   {'head': ['2024-01-01', 4, None], 'tail': None}),
  ('split past until',
   ['2024-01-01', 5, None, '2024-01-20', 5, 2],
   {'head': ['2024-01-01', None, '2024-01-21'], 'tail': None}),
  ('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None})],
 [('split at last until occurrence',
   ['2024-01-01', 5, None, '2024-01-21', 4, 1],
   {'head': ['2024-01-01', None, '2024-01-16'], 'tail': ['2024-01-21', 1, None, '2024-01-21']}),
  ('count split near end',
   ['2024-05-10', 1, 6, None, 5, 3],
   {'head': ['2024-05-10', 5, None], 'tail': ['2024-05-15', 3, 1, None]}),
  ('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']})],
 [('until split mid',
   ['2024-05-10', 4, None, '2024-07-01', 6, 2],
   {'head': ['2024-05-10', None, '2024-05-30'], 'tail': ['2024-06-03', 2, None, '2024-07-01']}),
  ('interval 1 count split',
   ['2024-12-30', 1, 8, None, 2, 1],
   {'head': ['2024-12-30', 2, None], 'tail': ['2025-01-01', 1, 6, None]}),
  ('split beyond count', ['2024-01-01', 1, 3, None, 7, 2], {'head': ['2024-01-01', 7, None], 'tail': None}),
  ('regression: count series split at 3',
   ['2024-01-01', 2, 10, None, 3, 7],
   {'head': ['2024-01-01', 3, None], 'tail': ['2024-01-07', 7, 7, None]}),
  ('until series split at 2',
   ['2024-01-01', 3, None, '2024-02-01', 2, 1],
   {'head': ['2024-01-01', None, '2024-01-04'], 'tail': ['2024-01-07', 1, None, '2024-02-01']}),
  ('split at first occurrence',
   ['2024-01-01', 1, 5, None, 0, 2],
   {'head': None, 'tail': ['2024-01-01', 2, 5, None]}),
  ('until split at first',
   ['2024-03-01', 7, None, '2024-06-01', 0, 14],
   {'head': None, 'tail': ['2024-03-01', 14, None, '2024-06-01']})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An UNTIL head series still includes the split occurrence.

A daily-interval series (dtstart, interval, and either count or until). Editing from 0-based occurrence k splits it: the head keeps occurrences 0..k-1 (count k, or until = its last retained occurrence date) and the tail starts at the original date of occurrence k with new_interval and the remaining count (or the original until). k <= 0 makes the head None; a split at or past the end makes the tail None. Return {"head": [dtstart, count, until] or None, "tail": [start, interval, count, until] or None}.

split: open-access


prompt:
A long instance already in progress when the window opens is missing from the result.

Instances start at dtstart + k*interval_hours for k < count and last duration_min minutes. A window [window_start, window_end) returns every instance whose half-open span [s, s+duration) overlaps it; a zero-duration instance is returned when window_start <= s < window_end. The query may skip ahead but COUNT is always counted from dtstart. Return ISO start times (minutes).

split: open-access


prompt:
A window late in a COUNT-limited series returns instances beyond the last occurrence.

Instances start at dtstart + k*interval_hours for k < count and last duration_min minutes. A window [window_start, window_end) returns every instance whose half-open span [s, s+duration) overlaps it; a zero-duration instance is returned when window_start <= s < window_end. The query may skip ahead but COUNT is always counted from dtstart. Return ISO start times (minutes).

split: open-access


prompt:
An instance starting exactly at the exclusive window end is returned.

Instances start at dtstart + k*interval_hours for k < count and last duration_min minutes. A window [window_start, window_end) returns every instance whose half-open span [s, s+duration) overlaps it; a zero-duration instance is returned when window_start <= s < window_end. The query may skip ahead but COUNT is always counted from dtstart. Return ISO start times (minutes).

split: open-access


prompt:
An instance that began before the window but is still running is omitted.

Instances start at dtstart + k*interval_hours for k < count and last duration_min minutes. A window [window_start, window_end) returns every instance whose half-open span [s, s+duration) overlaps it; a zero-duration instance is returned when window_start <= s < window_end. The query may skip ahead but COUNT is always counted from dtstart. Return ISO start times (minutes).

split: open-access