broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(existing, req, buffer, n_conn):
    s, e, want = req
    if e < s:
        return 'invalid'
    if want is not None and not 1 <= want <= n_conn:
        return 'invalid'
    conns = [want] if want is not None else list(range(1, n_conn + 1))
    for c in conns:
        clash = False
        for c2, s2, e2 in existing:
            if c2 == c and s < e2 + buffer and s2 < e + buffer:
                clash = True
                break
        if not clash:
            return c
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window',
   [[[1, 70, 116], [2, 43, 88], [1, 109, 153]], [45, 45, None], 0, 2], 'invalid'],
  ['regression: empty request window (partial repair)', [[], [159, 164, 1], 10, 3], 1],
  ['control 1', [[[2, 157, 203], [1, 191, 236]], [179, 224, None], 5, 2], None],
  ['control 2',
   [[[3, 190, 210], [4, 11, 28], [2, 54, 68], [4, 54, 104], [3, 134, 162]], [79, 139, 4], 5, 4],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window', [[[1, 191, 246], [2, 105, 128]], [128, 128, None], 15, 2],
   'invalid'],
  ['regression: empty request window (partial repair)', [[], [171, 171, None], 0, 1], 'invalid'],
  ['control 1',
   [[[2, 130, 150], [3, 5, 36], [3, 174, 193], [2, 18, 78], [1, 61, 115], [4, 68, 95]],
    [171, 201, 2], 10, 4],
   2],
  ['control 2',
   [[[3, 116, 135], [1, 178, 208], [1, 83, 123], [1, 136, 157], [3, 111, 126], [1, 97, 137]],
    [217, 222, 2], 0, 3],
   2]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window',
   [[[1, 61, 98], [2, 89, 148], [1, 159, 190], [2, 124, 167], [1, 197, 219]], [29, 29, None], 15,
    2],
   'invalid'],
  ['regression: empty request window (partial repair)',
   [[[1, 125, 139], [4, 142, 161], [2, 3, 17]], [206, 211, None], 15, 4], 1],
  ['control 1', [[[3, 198, 211], [1, 147, 191], [4, 137, 178]], [148, 208, None], 10, 4], 2],
  ['control 2',
   [[[1, 75, 109], [1, 5, 46], [3, 128, 161], [3, 171, 198], [2, 190, 240], [1, 13, 36]],
    [58, 73, 1], 10, 3],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window',
   [[[1, 144, 201], [1, 99, 140], [1, 187, 246], [1, 92, 150], [1, 120, 150]], [55, 55, 1], 0, 2],
   'invalid'],
  ['regression: empty request window (partial repair)',
   [[[1, 1, 57], [2, 28, 64]], [70, 75, 2], 15, 2], None],
  ['control 1', [[[3, 69, 129], [1, 134, 154], [4, 142, 167]], [67, 72, 0], 15, 4], 'invalid'],
  ['control 2', [[[2, 188, 212]], [190, 180, 2], 15, 2], 'invalid']],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window',
   [[[2, 141, 198], [2, 146, 161], [3, 91, 117], [2, 43, 82]], [0, 0, 1], 5, 4], 'invalid'],
  ['regression: empty request window (partial repair)', [[], [64, 69, None], 15, 4], 1],
  ['control 1', [[[4, 7, 51], [4, 60, 108], [1, 80, 129]], [8, 68, None], 0, 4], 1],
  ['control 2',
   [[[1, 169, 199], [1, 193, 217], [1, 118, 149], [1, 4, 58], [1, 125, 169], [1, 1, 52]],
    [156, 146, None], 10, 1],
   'invalid']]]
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

N = 1
observations = []
def solve(existing, req, buffer, n_conn):
    s, e, want = req
    if e - s < buffer:
        return 'invalid'
    if want is not None and not 1 <= want <= n_conn:
        return 'invalid'
    conns = [want] if want is not None else list(range(1, n_conn + 1))
    for c in conns:
        clash = False
        for c2, s2, e2 in existing:
            if c2 == c and s < e2 + buffer and s2 < e + buffer:
                clash = True
                break
        if not clash:
            return c
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window',
   [[[1, 70, 116], [2, 43, 88], [1, 109, 153]], [45, 45, None], 0, 2], 'invalid'],
  ['regression: empty request window (partial repair)', [[], [159, 164, 1], 10, 3], 1],
  ['control 1', [[[2, 157, 203], [1, 191, 236]], [179, 224, None], 5, 2], None],
  ['control 2',
   [[[3, 190, 210], [4, 11, 28], [2, 54, 68], [4, 54, 104], [3, 134, 162]], [79, 139, 4], 5, 4],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window', [[[1, 191, 246], [2, 105, 128]], [128, 128, None], 15, 2],
   'invalid'],
  ['regression: empty request window (partial repair)', [[], [171, 171, None], 0, 1], 'invalid'],
  ['control 1',
   [[[2, 130, 150], [3, 5, 36], [3, 174, 193], [2, 18, 78], [1, 61, 115], [4, 68, 95]],
    [171, 201, 2], 10, 4],
   2],
  ['control 2',
   [[[3, 116, 135], [1, 178, 208], [1, 83, 123], [1, 136, 157], [3, 111, 126], [1, 97, 137]],
    [217, 222, 2], 0, 3],
   2]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window',
   [[[1, 61, 98], [2, 89, 148], [1, 159, 190], [2, 124, 167], [1, 197, 219]], [29, 29, None], 15,
    2],
   'invalid'],
  ['regression: empty request window (partial repair)',
   [[[1, 125, 139], [4, 142, 161], [2, 3, 17]], [206, 211, None], 15, 4], 1],
  ['control 1', [[[3, 198, 211], [1, 147, 191], [4, 137, 178]], [148, 208, None], 10, 4], 2],
  ['control 2',
   [[[1, 75, 109], [1, 5, 46], [3, 128, 161], [3, 171, 198], [2, 190, 240], [1, 13, 36]],
    [58, 73, 1], 10, 3],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window',
   [[[1, 144, 201], [1, 99, 140], [1, 187, 246], [1, 92, 150], [1, 120, 150]], [55, 55, 1], 0, 2],
   'invalid'],
  ['regression: empty request window (partial repair)',
   [[[1, 1, 57], [2, 28, 64]], [70, 75, 2], 15, 2], None],
  ['control 1', [[[3, 69, 129], [1, 134, 154], [4, 142, 167]], [67, 72, 0], 15, 4], 'invalid'],
  ['control 2', [[[2, 188, 212]], [190, 180, 2], 15, 2], 'invalid']],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: empty request window',
   [[[2, 141, 198], [2, 146, 161], [3, 91, 117], [2, 43, 82]], [0, 0, 1], 5, 4], 'invalid'],
  ['regression: empty request window (partial repair)', [[], [64, 69, None], 15, 4], 1],
  ['control 1', [[[4, 7, 51], [4, 60, 108], [1, 80, 129]], [8, 68, None], 0, 4], 1],
  ['control 2',
   [[[1, 169, 199], [1, 193, 217], [1, 118, 149], [1, 4, 58], [1, 125, 169], [1, 1, 52]],
    [156, 146, None], 10, 1],
   'invalid']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A zero-length reservation is accepted and blocks a connector.

Connectors are numbered 1..n_conn. existing holds [connector, start, end) reservations. req is [start, end, connector or None]. end <= start or an out-of-range connector returns 'invalid'. Two reservations on the same connector conflict unless separated by at least buffer minutes on both sides. Return the requested connector if free, or the lowest free connector when None was requested, else None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(existing, req, buffer, n_conn):
    s, e, want = req
    if e <= s:
        return 'invalid'
    if want is not None and not 1 <= want <= n_conn:
        return 'invalid'
    conns = [want] if want is not None else list(range(1, n_conn + 1))
    for c in conns:
        clash = False
        for c2, s2, e2 in existing:
            if s < e2 + buffer and s2 < e + buffer:
                clash = True
                break
        if not clash:
            return c
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[1, 100, 133], [2, 11, 28], [1, 134, 160]], [20, 80, None], 10, 3], 1],
  ['regression: same-connector filter (partial repair)',
   [[[3, 177, 218], [1, 136, 190], [4, 57, 79]], [155, 200, 2], 5, 4], 2],
  ['control 1', [[[2, 157, 203], [1, 191, 236]], [179, 224, None], 5, 2], None],
  ['control 2',
   [[[3, 190, 210], [4, 11, 28], [2, 54, 68], [4, 54, 104], [3, 134, 162]], [79, 139, 4], 5, 4],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[2, 18, 58], [2, 102, 153], [1, 73, 93], [4, 193, 224], [4, 85, 112]], [44, 49, None], 0, 4],
   1],
  ['regression: same-connector filter (partial repair)',
   [[[1, 162, 178], [1, 168, 179], [4, 176, 201], [3, 128, 179]], [187, 232, None], 10, 4], 2],
  ['control 1',
   [[[2, 130, 150], [3, 5, 36], [3, 174, 193], [2, 18, 78], [1, 61, 115], [4, 68, 95]],
    [171, 201, 2], 10, 4],
   2],
  ['control 2',
   [[[3, 116, 135], [1, 178, 208], [1, 83, 123], [1, 136, 157], [3, 111, 126], [1, 97, 137]],
    [217, 222, 2], 0, 3],
   2]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[2, 129, 171], [1, 169, 226], [1, 85, 130], [1, 33, 84]], [46, 51, 2], 5, 2], 2],
  ['regression: same-connector filter (partial repair)',
   [[[1, 105, 159], [2, 195, 210], [1, 9, 50], [3, 158, 180]], [73, 103, 3], 15, 3], 3],
  ['control 1', [[[3, 198, 211], [1, 147, 191], [4, 137, 178]], [148, 208, None], 10, 4], 2],
  ['control 2',
   [[[1, 75, 109], [1, 5, 46], [3, 128, 161], [3, 171, 198], [2, 190, 240], [1, 13, 36]],
    [58, 73, 1], 10, 3],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[2, 102, 160], [3, 28, 74], [3, 56, 79], [2, 172, 229]], [175, 220, None], 0, 3], 1],
  ['regression: same-connector filter (partial repair)',
   [[[1, 172, 210], [1, 61, 81]], [200, 245, None], 0, 3], 2],
  ['control 1', [[[3, 69, 129], [1, 134, 154], [4, 142, 167]], [67, 72, 0], 15, 4], 'invalid'],
  ['control 2', [[[2, 188, 212]], [190, 180, 2], 15, 2], 'invalid']],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[1, 100, 116], [1, 77, 119], [1, 115, 153], [2, 193, 239], [2, 186, 231]], [87, 117, 2], 10,
    2],
   2],
  ['regression: same-connector filter (partial repair)',
   [[[1, 8, 36], [1, 100, 132]], [-5, 55, 2], 10, 3], 2],
  ['control 1', [[[4, 7, 51], [4, 60, 108], [1, 80, 129]], [8, 68, None], 0, 4], 1],
  ['control 2',
   [[[1, 169, 199], [1, 193, 217], [1, 118, 149], [1, 4, 58], [1, 125, 169], [1, 1, 52]],
    [156, 146, None], 10, 1],
   'invalid']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(existing, req, buffer, n_conn):
    s, e, want = req
    if e <= s:
        return 'invalid'
    if want is not None and not 1 <= want <= n_conn:
        return 'invalid'
    conns = [want] if want is not None else list(range(1, n_conn + 1))
    for c in conns:
        clash = False
        for c2, s2, e2 in existing:
            if c2 <= c and s < e2 + buffer and s2 < e + buffer:
                clash = True
                break
        if not clash:
            return c
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[1, 100, 133], [2, 11, 28], [1, 134, 160]], [20, 80, None], 10, 3], 1],
  ['regression: same-connector filter (partial repair)',
   [[[3, 177, 218], [1, 136, 190], [4, 57, 79]], [155, 200, 2], 5, 4], 2],
  ['control 1', [[[2, 157, 203], [1, 191, 236]], [179, 224, None], 5, 2], None],
  ['control 2',
   [[[3, 190, 210], [4, 11, 28], [2, 54, 68], [4, 54, 104], [3, 134, 162]], [79, 139, 4], 5, 4],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[2, 18, 58], [2, 102, 153], [1, 73, 93], [4, 193, 224], [4, 85, 112]], [44, 49, None], 0, 4],
   1],
  ['regression: same-connector filter (partial repair)',
   [[[1, 162, 178], [1, 168, 179], [4, 176, 201], [3, 128, 179]], [187, 232, None], 10, 4], 2],
  ['control 1',
   [[[2, 130, 150], [3, 5, 36], [3, 174, 193], [2, 18, 78], [1, 61, 115], [4, 68, 95]],
    [171, 201, 2], 10, 4],
   2],
  ['control 2',
   [[[3, 116, 135], [1, 178, 208], [1, 83, 123], [1, 136, 157], [3, 111, 126], [1, 97, 137]],
    [217, 222, 2], 0, 3],
   2]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[2, 129, 171], [1, 169, 226], [1, 85, 130], [1, 33, 84]], [46, 51, 2], 5, 2], 2],
  ['regression: same-connector filter (partial repair)',
   [[[1, 105, 159], [2, 195, 210], [1, 9, 50], [3, 158, 180]], [73, 103, 3], 15, 3], 3],
  ['control 1', [[[3, 198, 211], [1, 147, 191], [4, 137, 178]], [148, 208, None], 10, 4], 2],
  ['control 2',
   [[[1, 75, 109], [1, 5, 46], [3, 128, 161], [3, 171, 198], [2, 190, 240], [1, 13, 36]],
    [58, 73, 1], 10, 3],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[2, 102, 160], [3, 28, 74], [3, 56, 79], [2, 172, 229]], [175, 220, None], 0, 3], 1],
  ['regression: same-connector filter (partial repair)',
   [[[1, 172, 210], [1, 61, 81]], [200, 245, None], 0, 3], 2],
  ['control 1', [[[3, 69, 129], [1, 134, 154], [4, 142, 167]], [67, 72, 0], 15, 4], 'invalid'],
  ['control 2', [[[2, 188, 212]], [190, 180, 2], 15, 2], 'invalid']],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: same-connector filter',
   [[[1, 100, 116], [1, 77, 119], [1, 115, 153], [2, 193, 239], [2, 186, 231]], [87, 117, 2], 10,
    2],
   2],
  ['regression: same-connector filter (partial repair)',
   [[[1, 8, 36], [1, 100, 132]], [-5, 55, 2], 10, 3], 2],
  ['control 1', [[[4, 7, 51], [4, 60, 108], [1, 80, 129]], [8, 68, None], 0, 4], 1],
  ['control 2',
   [[[1, 169, 199], [1, 193, 217], [1, 118, 149], [1, 4, 58], [1, 125, 169], [1, 1, 52]],
    [156, 146, None], 10, 1],
   'invalid']]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A booking on connector 2 blocks a free connector 3.

Connectors are numbered 1..n_conn. existing holds [connector, start, end) reservations. req is [start, end, connector or None]. end <= start or an out-of-range connector returns 'invalid'. Two reservations on the same connector conflict unless separated by at least buffer minutes on both sides. Return the requested connector if free, or the lowest free connector when None was requested, else None.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(existing, req, buffer, n_conn):
    s, e, want = req
    if e <= s:
        return 'invalid'
    if want is not None and not 1 <= want <= n_conn:
        return 'invalid'
    conns = [want] if want is not None else list(range(n_conn, 0, -1))
    for c in conns:
        clash = False
        for c2, s2, e2 in existing:
            if c2 == c and s < e2 + buffer and s2 < e + buffer:
                clash = True
                break
        if not clash:
            return c
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order',
   [[[1, 100, 133], [2, 11, 28], [1, 134, 160]], [20, 80, None], 10, 3], 1],
  ['regression: free connector search order (partial repair)', [[], [95, 125, None], 5, 1], 1],
  ['control 1', [[[2, 157, 203], [1, 191, 236]], [179, 224, None], 5, 2], None],
  ['control 2',
   [[[3, 190, 210], [4, 11, 28], [2, 54, 68], [4, 54, 104], [3, 134, 162]], [79, 139, 4], 5, 4],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order', [[[2, 159, 208], [1, 9, 67]], [210, 255, None], 0, 3],
   1],
  ['regression: free connector search order (partial repair)', [[], [95, 125, None], 5, 1], 1],
  ['control 1',
   [[[2, 130, 150], [3, 5, 36], [3, 174, 193], [2, 18, 78], [1, 61, 115], [4, 68, 95]],
    [171, 201, 2], 10, 4],
   2],
  ['control 2',
   [[[3, 116, 135], [1, 178, 208], [1, 83, 123], [1, 136, 157], [3, 111, 126], [1, 97, 137]],
    [217, 222, 2], 0, 3],
   2]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order', [[], [149, 154, None], 5, 4], 1],
  ['regression: free connector search order (partial repair)',
   [[[1, 130, 147], [1, 82, 133], [1, 89, 133], [1, 193, 215], [1, 86, 134]], [2, 32, None], 0, 1],
   1],
  ['control 1', [[[3, 198, 211], [1, 147, 191], [4, 137, 178]], [148, 208, None], 10, 4], 2],
  ['control 2',
   [[[1, 75, 109], [1, 5, 46], [3, 128, 161], [3, 171, 198], [2, 190, 240], [1, 13, 36]],
    [58, 73, 1], 10, 3],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order',
   [[[2, 102, 160], [3, 28, 74], [3, 56, 79], [2, 172, 229]], [175, 220, None], 0, 3], 1],
  ['regression: free connector search order (partial repair)',
   [[[1, 99, 122]], [151, 211, None], 0, 1], 1],
  ['control 1', [[[3, 69, 129], [1, 134, 154], [4, 142, 167]], [67, 72, 0], 15, 4], 'invalid'],
  ['control 2', [[[2, 188, 212]], [190, 180, 2], 15, 2], 'invalid']],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order',
   [[[2, 114, 134], [3, 125, 180], [2, 120, 174], [1, 44, 57], [2, 110, 149]], [220, 235, None], 10,
    4],
   1],
  ['regression: free connector search order (partial repair)',
   [[[1, 189, 228]], [107, 152, None], 0, 1], 1],
  ['control 1', [[[4, 7, 51], [4, 60, 108], [1, 80, 129]], [8, 68, None], 0, 4], 1],
  ['control 2',
   [[[1, 169, 199], [1, 193, 217], [1, 118, 149], [1, 4, 58], [1, 125, 169], [1, 1, 52]],
    [156, 146, None], 10, 1],
   'invalid']]]
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

N = 1
observations = []
def solve(existing, req, buffer, n_conn):
    s, e, want = req
    if e <= s:
        return 'invalid'
    if want is not None and not 1 <= want <= n_conn:
        return 'invalid'
    conns = [want] if want is not None else list(range(1, n_conn))
    for c in conns:
        clash = False
        for c2, s2, e2 in existing:
            if c2 == c and s < e2 + buffer and s2 < e + buffer:
                clash = True
                break
        if not clash:
            return c
    return None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order',
   [[[1, 100, 133], [2, 11, 28], [1, 134, 160]], [20, 80, None], 10, 3], 1],
  ['regression: free connector search order (partial repair)', [[], [95, 125, None], 5, 1], 1],
  ['control 1', [[[2, 157, 203], [1, 191, 236]], [179, 224, None], 5, 2], None],
  ['control 2',
   [[[3, 190, 210], [4, 11, 28], [2, 54, 68], [4, 54, 104], [3, 134, 162]], [79, 139, 4], 5, 4],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order', [[[2, 159, 208], [1, 9, 67]], [210, 255, None], 0, 3],
   1],
  ['regression: free connector search order (partial repair)', [[], [95, 125, None], 5, 1], 1],
  ['control 1',
   [[[2, 130, 150], [3, 5, 36], [3, 174, 193], [2, 18, 78], [1, 61, 115], [4, 68, 95]],
    [171, 201, 2], 10, 4],
   2],
  ['control 2',
   [[[3, 116, 135], [1, 178, 208], [1, 83, 123], [1, 136, 157], [3, 111, 126], [1, 97, 137]],
    [217, 222, 2], 0, 3],
   2]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order', [[], [149, 154, None], 5, 4], 1],
  ['regression: free connector search order (partial repair)',
   [[[1, 130, 147], [1, 82, 133], [1, 89, 133], [1, 193, 215], [1, 86, 134]], [2, 32, None], 0, 1],
   1],
  ['control 1', [[[3, 198, 211], [1, 147, 191], [4, 137, 178]], [148, 208, None], 10, 4], 2],
  ['control 2',
   [[[1, 75, 109], [1, 5, 46], [3, 128, 161], [3, 171, 198], [2, 190, 240], [1, 13, 36]],
    [58, 73, 1], 10, 3],
   None]],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order',
   [[[2, 102, 160], [3, 28, 74], [3, 56, 79], [2, 172, 229]], [175, 220, None], 0, 3], 1],
  ['regression: free connector search order (partial repair)',
   [[[1, 99, 122]], [151, 211, None], 0, 1], 1],
  ['control 1', [[[3, 69, 129], [1, 134, 154], [4, 142, 167]], [67, 72, 0], 15, 4], 'invalid'],
  ['control 2', [[[2, 188, 212]], [190, 180, 2], 15, 2], 'invalid']],
 [['boundary: back-to-back with buffer', [[[1, 0, 30]], [40, 60, 1], 10, 1], 1],
  ['boundary: zero-length request', [[], [10, 10, None], 0, 2], 'invalid'],
  ['boundary: last connector requested', [[[1, 0, 30]], [0, 30, 3], 0, 3], 3],
  ['regression: free connector search order',
   [[[2, 114, 134], [3, 125, 180], [2, 120, 174], [1, 44, 57], [2, 110, 149]], [220, 235, None], 10,
    4],
   1],
  ['regression: free connector search order (partial repair)',
   [[[1, 189, 228]], [107, 152, None], 0, 1], 1],
  ['control 1', [[[4, 7, 51], [4, 60, 108], [1, 80, 129]], [8, 68, None], 0, 4], 1],
  ['control 2',
   [[[1, 169, 199], [1, 193, 217], [1, 118, 149], [1, 4, 58], [1, 125, 169], [1, 1, 52]],
    [156, 146, None], 10, 1],
   'invalid']]]
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:
Open-choice reservations land on the highest connector instead of the lowest free one.

Connectors are numbered 1..n_conn. existing holds [connector, start, end) reservations. req is [start, end, connector or None]. end <= start or an out-of-range connector returns 'invalid'. Two reservations on the same connector conflict unless separated by at least buffer minutes on both sides. Return the requested connector if free, or the lowest free connector when None was requested, else None.

split: open-access


prompt:
Surplus exactly at the start threshold never starts charging.

samples are per-minute PV surplus watts. Charging starts on the sample completing start_delay consecutive samples >= start_w, and stops on the sample completing stop_delay consecutive samples < stop_w; counters reset on each transition and on any interrupting sample. While charging the power is the surplus clamped to [1380, 3680] W, else 0. Return [powers, number of starts].

split: open-access


prompt:
Charging stops shortly after starting even though the sun never dipped.

samples are per-minute PV surplus watts. Charging starts on the sample completing start_delay consecutive samples >= start_w, and stops on the sample completing stop_delay consecutive samples < stop_w; counters reset on each transition and on any interrupting sample. While charging the power is the surplus clamped to [1380, 3680] W, else 0. Return [powers, number of starts].

split: open-access


prompt:
Several short, separated cloud dips add up and stop the charger.

samples are per-minute PV surplus watts. Charging starts on the sample completing start_delay consecutive samples >= start_w, and stops on the sample completing stop_delay consecutive samples < stop_w; counters reset on each transition and on any interrupting sample. While charging the power is the surplus clamped to [1380, 3680] W, else 0. Return [powers, number of starts].

split: open-access


prompt:
Charging continues one sample longer than the configured stop delay.

samples are per-minute PV surplus watts. Charging starts on the sample completing start_delay consecutive samples >= start_w, and stops on the sample completing stop_delay consecutive samples < stop_w; counters reset on each transition and on any interrupting sample. While charging the power is the surplus clamped to [1380, 3680] W, else 0. Return [powers, number of starts].

split: open-access


prompt:
While clouds pass the charger is commanded below the minimum pilot current.

samples are per-minute PV surplus watts. Charging starts on the sample completing start_delay consecutive samples >= start_w, and stops on the sample completing stop_delay consecutive samples < stop_w; counters reset on each transition and on any interrupting sample. While charging the power is the surplus clamped to [1380, 3680] W, else 0. Return [powers, number of starts].

split: open-access


prompt:
The power profile lags the charging state by one minute.

samples are per-minute PV surplus watts. Charging starts on the sample completing start_delay consecutive samples >= start_w, and stops on the sample completing stop_delay consecutive samples < stop_w; counters reset on each transition and on any interrupting sample. While charging the power is the surplus clamped to [1380, 3680] W, else 0. Return [powers, number of starts].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 60 * eff_pct // (rate_w * 100))
    latest = depart - buffer_min - dur
    latest -= latest % 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [153, 434, 2000, 11000, 85, 30], [390, 403, 'ok']],
  ['regression: efficiency direction (partial repair)', [387, 1026, 30000, 11000, 95, 30],
   [810, 983, 'ok']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [351, 1109, 18000, 3700, 95, 15], [780, 1088, 'ok']],
  ['regression: efficiency direction (partial repair)', [153, 726, 30000, 3700, 85, 0],
   [153, 726, 'late']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [84, 334, 30000, 7400, 95, 30], [84, 341, 'late']],
  ['regression: efficiency direction (partial repair)', [12, 862, 30000, 11000, 95, 15],
   [660, 833, 'ok']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [496, 868, 11000, 3700, 95, 30], [645, 833, 'ok']],
  ['regression: efficiency direction (partial repair)', [342, 397, 18000, 11000, 95, 10],
   [342, 446, 'late']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [522, 1168, 30000, 3700, 85, 30], [555, 1128, 'ok']],
  ['regression: efficiency direction (partial repair)', [546, 1243, 11000, 7400, 85, 30],
   [1095, 1200, 'ok']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 60 // rate_w)
    latest = depart - buffer_min - dur
    latest -= latest % 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [153, 434, 2000, 11000, 85, 30], [390, 403, 'ok']],
  ['regression: efficiency direction (partial repair)', [387, 1026, 30000, 11000, 95, 30],
   [810, 983, 'ok']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [351, 1109, 18000, 3700, 95, 15], [780, 1088, 'ok']],
  ['regression: efficiency direction (partial repair)', [153, 726, 30000, 3700, 85, 0],
   [153, 726, 'late']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [84, 334, 30000, 7400, 95, 30], [84, 341, 'late']],
  ['regression: efficiency direction (partial repair)', [12, 862, 30000, 11000, 95, 15],
   [660, 833, 'ok']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [496, 868, 11000, 3700, 95, 30], [645, 833, 'ok']],
  ['regression: efficiency direction (partial repair)', [342, 397, 18000, 11000, 95, 10],
   [342, 446, 'late']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: efficiency direction', [522, 1168, 30000, 3700, 85, 30], [555, 1128, 'ok']],
  ['regression: efficiency direction (partial repair)', [546, 1243, 11000, 7400, 85, 30],
   [1095, 1200, 'ok']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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:
Cars finish short of their target because charging starts too late.

Minutes. The battery must receive need_wh; the charger draws rate_w at eff_pct percent efficiency, so duration = ceil(need_wh*6000/(rate_w*eff_pct)) minutes. Latest start = depart - buffer_min - duration, rounded down to a 15-minute boundary. If that is before now, start now with status 'late'. need_wh <= 0 returns [None, now, 'done']; rate_w or eff_pct <= 0 returns [None, None, 'no-power']. Return [start, finish, status].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = need_wh * 6000 // (rate_w * eff_pct)
    latest = depart - buffer_min - dur
    latest -= latest % 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [153, 434, 2000, 11000, 85, 30], [390, 403, 'ok']],
  ['regression: duration rounding (partial repair)', [387, 1026, 30000, 11000, 95, 30],
   [810, 983, 'ok']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [351, 1109, 18000, 3700, 95, 15], [780, 1088, 'ok']],
  ['regression: duration rounding (partial repair)', [20, 911, 30000, 7400, 100, 15],
   [645, 889, 'ok']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [159, 777, 11000, 3700, 100, 30], [555, 734, 'ok']],
  ['regression: duration rounding (partial repair)', [81, 103, 5000, 3700, 100, 10],
   [81, 163, 'late']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [496, 868, 11000, 3700, 95, 30], [645, 833, 'ok']],
  ['regression: duration rounding (partial repair)', [342, 397, 18000, 11000, 95, 10],
   [342, 446, 'late']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [522, 1168, 30000, 3700, 85, 30], [555, 1128, 'ok']],
  ['regression: duration rounding (partial repair)', [341, 315, 5000, 3700, 100, 30],
   [341, 423, 'late']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = round(need_wh * 6000 / (rate_w * eff_pct))
    latest = depart - buffer_min - dur
    latest -= latest % 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [153, 434, 2000, 11000, 85, 30], [390, 403, 'ok']],
  ['regression: duration rounding (partial repair)', [387, 1026, 30000, 11000, 95, 30],
   [810, 983, 'ok']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [351, 1109, 18000, 3700, 95, 15], [780, 1088, 'ok']],
  ['regression: duration rounding (partial repair)', [20, 911, 30000, 7400, 100, 15],
   [645, 889, 'ok']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [159, 777, 11000, 3700, 100, 30], [555, 734, 'ok']],
  ['regression: duration rounding (partial repair)', [81, 103, 5000, 3700, 100, 10],
   [81, 163, 'late']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [496, 868, 11000, 3700, 95, 30], [645, 833, 'ok']],
  ['regression: duration rounding (partial repair)', [342, 397, 18000, 11000, 95, 10],
   [342, 446, 'late']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: duration rounding', [522, 1168, 30000, 3700, 85, 30], [555, 1128, 'ok']],
  ['regression: duration rounding (partial repair)', [341, 315, 5000, 3700, 100, 30],
   [341, 423, 'late']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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 session plan ends a minute before the energy is actually delivered.

Minutes. The battery must receive need_wh; the charger draws rate_w at eff_pct percent efficiency, so duration = ceil(need_wh*6000/(rate_w*eff_pct)) minutes. Latest start = depart - buffer_min - duration, rounded down to a 15-minute boundary. If that is before now, start now with status 'late'. need_wh <= 0 returns [None, now, 'done']; rate_w or eff_pct <= 0 returns [None, None, 'no-power']. Return [start, finish, status].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 6000 // (rate_w * eff_pct))
    latest = depart + buffer_min - dur
    latest -= latest % 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [153, 434, 2000, 11000, 85, 30], [390, 403, 'ok']],
  ['regression: buffer direction (partial repair)', [387, 1026, 30000, 11000, 95, 30],
   [810, 983, 'ok']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [351, 1109, 18000, 3700, 95, 15], [780, 1088, 'ok']],
  ['regression: buffer direction (partial repair)', [20, 911, 30000, 7400, 100, 15],
   [645, 889, 'ok']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [159, 777, 11000, 3700, 100, 30], [555, 734, 'ok']],
  ['regression: buffer direction (partial repair)', [12, 862, 30000, 11000, 95, 15],
   [660, 833, 'ok']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [496, 868, 11000, 3700, 95, 30], [645, 833, 'ok']],
  ['regression: buffer direction (partial repair)', [577, 1400, 11000, 7400, 85, 15],
   [1275, 1380, 'ok']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [522, 1168, 30000, 3700, 85, 30], [555, 1128, 'ok']],
  ['regression: buffer direction (partial repair)', [546, 1243, 11000, 7400, 85, 30],
   [1095, 1200, 'ok']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 6000 // (rate_w * eff_pct))
    latest = depart - dur
    latest -= latest % 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [153, 434, 2000, 11000, 85, 30], [390, 403, 'ok']],
  ['regression: buffer direction (partial repair)', [387, 1026, 30000, 11000, 95, 30],
   [810, 983, 'ok']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [351, 1109, 18000, 3700, 95, 15], [780, 1088, 'ok']],
  ['regression: buffer direction (partial repair)', [20, 911, 30000, 7400, 100, 15],
   [645, 889, 'ok']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [159, 777, 11000, 3700, 100, 30], [555, 734, 'ok']],
  ['regression: buffer direction (partial repair)', [12, 862, 30000, 11000, 95, 15],
   [660, 833, 'ok']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [496, 868, 11000, 3700, 95, 30], [645, 833, 'ok']],
  ['regression: buffer direction (partial repair)', [577, 1400, 11000, 7400, 85, 15],
   [1275, 1380, 'ok']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: buffer direction', [522, 1168, 30000, 3700, 85, 30], [555, 1128, 'ok']],
  ['regression: buffer direction (partial repair)', [546, 1243, 11000, 7400, 85, 30],
   [1095, 1200, 'ok']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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:
Charging is planned to finish after the driver leaves.

Minutes. The battery must receive need_wh; the charger draws rate_w at eff_pct percent efficiency, so duration = ceil(need_wh*6000/(rate_w*eff_pct)) minutes. Latest start = depart - buffer_min - duration, rounded down to a 15-minute boundary. If that is before now, start now with status 'late'. need_wh <= 0 returns [None, now, 'done']; rate_w or eff_pct <= 0 returns [None, None, 'no-power']. Return [start, finish, status].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 6000 // (rate_w * eff_pct))
    latest = depart - buffer_min - dur
    latest += (-latest) % 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [153, 434, 2000, 11000, 85, 30], [390, 403, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [387, 1026, 30000, 11000, 95, 30],
   [810, 983, 'ok']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [351, 1109, 18000, 3700, 95, 15], [780, 1088, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [224, 999, 2000, 11000, 100, 15],
   [960, 971, 'ok']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [159, 777, 11000, 3700, 100, 30], [555, 734, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [12, 862, 30000, 11000, 95, 15],
   [660, 833, 'ok']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [496, 868, 11000, 3700, 95, 30], [645, 833, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [53, 403, 11000, 3700, 90, 10],
   [180, 379, 'ok']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [522, 1168, 30000, 3700, 85, 30], [555, 1128, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [546, 1243, 11000, 7400, 85, 30],
   [1095, 1200, 'ok']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 6000 // (rate_w * eff_pct))
    latest = depart - buffer_min - dur
    latest = round(latest / 15) * 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [153, 434, 2000, 11000, 85, 30], [390, 403, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [387, 1026, 30000, 11000, 95, 30],
   [810, 983, 'ok']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [351, 1109, 18000, 3700, 95, 15], [780, 1088, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [224, 999, 2000, 11000, 100, 15],
   [960, 971, 'ok']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [159, 777, 11000, 3700, 100, 30], [555, 734, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [12, 862, 30000, 11000, 95, 15],
   [660, 833, 'ok']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [496, 868, 11000, 3700, 95, 30], [645, 833, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [53, 403, 11000, 3700, 90, 10],
   [180, 379, 'ok']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: quarter-hour quantization', [522, 1168, 30000, 3700, 85, 30], [555, 1128, 'ok']],
  ['regression: quarter-hour quantization (partial repair)', [546, 1243, 11000, 7400, 85, 30],
   [1095, 1200, 'ok']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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:
Planned starts snap to the next quarter hour and finish after the target time.

Minutes. The battery must receive need_wh; the charger draws rate_w at eff_pct percent efficiency, so duration = ceil(need_wh*6000/(rate_w*eff_pct)) minutes. Latest start = depart - buffer_min - duration, rounded down to a 15-minute boundary. If that is before now, start now with status 'late'. need_wh <= 0 returns [None, now, 'done']; rate_w or eff_pct <= 0 returns [None, None, 'no-power']. Return [start, finish, status].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 6000 // (rate_w * eff_pct))
    latest = depart - buffer_min - dur
    latest -= latest % 15
    if depart < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [452, 609, 18000, 7400, 90, 0], [452, 615, 'late']],
  ['regression: late detection (partial repair)', [153, 726, 30000, 3700, 85, 0],
   [153, 726, 'late']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [66, 284, 18000, 3700, 100, 10], [66, 358, 'late']],
  ['regression: late detection (partial repair)', [153, 726, 30000, 3700, 85, 0],
   [153, 726, 'late']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [81, 103, 5000, 3700, 100, 10], [81, 163, 'late']],
  ['regression: late detection (partial repair)', [343, 518, 11000, 3700, 95, 0],
   [343, 531, 'late']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['regression: late detection (partial repair)', [343, 518, 11000, 3700, 95, 0],
   [343, 531, 'late']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [394, 458, 30000, 11000, 85, 30], [394, 587, 'late']],
  ['regression: late detection (partial repair)', [153, 726, 30000, 3700, 85, 0],
   [153, 726, 'late']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 6000 // (rate_w * eff_pct))
    latest = depart - buffer_min - dur
    latest -= latest % 15
    if latest <= now - 15:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [452, 609, 18000, 7400, 90, 0], [452, 615, 'late']],
  ['regression: late detection (partial repair)', [153, 726, 30000, 3700, 85, 0],
   [153, 726, 'late']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [66, 284, 18000, 3700, 100, 10], [66, 358, 'late']],
  ['regression: late detection (partial repair)', [153, 726, 30000, 3700, 85, 0],
   [153, 726, 'late']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [81, 103, 5000, 3700, 100, 10], [81, 163, 'late']],
  ['regression: late detection (partial repair)', [343, 518, 11000, 3700, 95, 0],
   [343, 531, 'late']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['regression: late detection (partial repair)', [343, 518, 11000, 3700, 95, 0],
   [343, 531, 'late']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: late detection', [394, 458, 30000, 11000, 85, 30], [394, 587, 'late']],
  ['regression: late detection (partial repair)', [153, 726, 30000, 3700, 85, 0],
   [153, 726, 'late']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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:
Plans report starts in the past with status ok.

Minutes. The battery must receive need_wh; the charger draws rate_w at eff_pct percent efficiency, so duration = ceil(need_wh*6000/(rate_w*eff_pct)) minutes. Latest start = depart - buffer_min - duration, rounded down to a 15-minute boundary. If that is before now, start now with status 'late'. need_wh <= 0 returns [None, now, 'done']; rate_w or eff_pct <= 0 returns [None, None, 'no-power']. Return [start, finish, status].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh < 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 6000 // (rate_w * eff_pct))
    latest = depart - buffer_min - dur
    latest -= latest % 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [37, 306, 0, 3700, 100, 15], [None, 37, 'done']],
  ['regression: zero request handling (partial repair)', [55, 571, 0, 0, 90, 10],
   [None, 55, 'done']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [204, 654, 0, 3700, 100, 15], [None, 204, 'done']],
  ['regression: zero request handling (partial repair)', [318, 1160, 0, 0, 100, 30],
   [None, 318, 'done']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [591, 1384, 0, 0, 90, 0], [None, 591, 'done']],
  ['regression: zero request handling (partial repair)', [504, 733, 0, 0, 85, 10],
   [None, 504, 'done']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [474, 638, 0, 11000, 85, 15], [None, 474, 'done']],
  ['regression: zero request handling (partial repair)', [464, 1320, 0, 0, 100, 10],
   [None, 464, 'done']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [439, 470, 0, 7400, 90, 0], [None, 439, 'done']],
  ['regression: zero request handling (partial repair)', [41, 808, 0, 0, 95, 10],
   [None, 41, 'done']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
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

N = 1
observations = []
def solve(now, depart, need_wh, rate_w, eff_pct, buffer_min):
    if need_wh <= 0 and rate_w > 0:
        return [None, now, 'done']
    if rate_w <= 0 or eff_pct <= 0:
        return [None, None, 'no-power']
    dur = -(-need_wh * 6000 // (rate_w * eff_pct))
    latest = depart - buffer_min - dur
    latest -= latest % 15
    if latest < now:
        return [now, now + dur, 'late']
    return [latest, latest + dur, 'ok']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [37, 306, 0, 3700, 100, 15], [None, 37, 'done']],
  ['regression: zero request handling (partial repair)', [55, 571, 0, 0, 90, 10],
   [None, 55, 'done']],
  ['control 1', [117, 637, 11000, 11000, 95, 10], [555, 619, 'ok']],
  ['control 2', [448, 1142, 0, 3700, 85, 0], [None, 448, 'done']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [204, 654, 0, 3700, 100, 15], [None, 204, 'done']],
  ['regression: zero request handling (partial repair)', [318, 1160, 0, 0, 100, 30],
   [None, 318, 'done']],
  ['control 1', [416, 1003, 5000, 0, 85, 15], [None, None, 'no-power']],
  ['control 2', [221, 503, 5000, 0, 85, 30], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [591, 1384, 0, 0, 90, 0], [None, 591, 'done']],
  ['regression: zero request handling (partial repair)', [504, 733, 0, 0, 85, 10],
   [None, 504, 'done']],
  ['control 1', [381, 632, 18000, 3700, 95, 30], [381, 689, 'late']],
  ['control 2', [19, 584, 30000, 11000, 90, 15], [375, 557, 'ok']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [474, 638, 0, 11000, 85, 15], [None, 474, 'done']],
  ['regression: zero request handling (partial repair)', [464, 1320, 0, 0, 100, 10],
   [None, 464, 'done']],
  ['control 1', [66, 229, 11000, 0, 90, 15], [None, None, 'no-power']],
  ['control 2', [44, 377, 2000, 0, 100, 0], [None, None, 'no-power']]],
 [['boundary: nothing to charge', [100, 400, 0, 0, 90, 10], [None, 100, 'done']],
  ['boundary: latest start exactly now', [300, 390, 7400, 7400, 100, 0], [330, 390, 'ok']],
  ['boundary: no charger power', [100, 400, 5000, 0, 90, 10], [None, None, 'no-power']],
  ['regression: zero request handling', [439, 470, 0, 7400, 90, 0], [None, 439, 'done']],
  ['regression: zero request handling (partial repair)', [41, 808, 0, 0, 95, 10],
   [None, 41, 'done']],
  ['control 1', [342, 397, 18000, 11000, 95, 10], [342, 446, 'late']],
  ['control 2', [577, 1400, 11000, 7400, 85, 15], [1275, 1380, 'ok']]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A fully charged car gets a zero-length charging plan instead of done.

Minutes. The battery must receive need_wh; the charger draws rate_w at eff_pct percent efficiency, so duration = ceil(need_wh*6000/(rate_w*eff_pct)) minutes. Latest start = depart - buffer_min - duration, rounded down to a 15-minute boundary. If that is before now, start now with status 'late'. need_wh <= 0 returns [None, now, 'done']; rate_w or eff_pct <= 0 returns [None, None, 'no-power']. Return [start, finish, status].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: None for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: already-satisfied finish marker (partial repair)',
   [[['V0', 4], ['V1', 4], ['V2', 0], ['V3', 5], ['V4', 6], ['V5', 0]], 1, 9, 1],
   [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']],
    [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: already-satisfied finish marker (partial repair)', [[['V0', 0]], 1, 9, 3],
   [[[], [], [], [], [], [], [], [], []], [['V0', 0]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker', [[['V0', 2], ['V1', 0]], 2, 9, 3],
   [[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
  ['regression: already-satisfied finish marker (partial repair)',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker',
   [[['V0', 2], ['V1', 6], ['V2', 1], ['V3', 0]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1'], ['V1']], [['V0', 2], ['V1', None], ['V2', 1], ['V3', 0]]]],
  ['regression: already-satisfied finish marker (partial repair)',
   [[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 4]], 2, 9, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V3'], ['V1', 'V3'], ['V1', 'V3'], ['V3'], [],
     []],
    [['V0', 0], ['V1', 6], ['V2', 3], ['V3', 7]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: already-satisfied finish marker (partial repair)',
   [[['V0', 6], ['V1', 5], ['V2', 1], ['V3', 0], ['V4', 5], ['V5', 3]], 1, 9, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V4'], ['V4'], ['V5'], ['V5']],
    [['V0', None], ['V1', None], ['V2', 5], ['V3', 0], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
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

N = 1
observations = []
def solve(vehicles, ports, slots, quantum):
    queue = [[vid, need] for vid, need in vehicles if need > 0]
    done = {vid: (1 if need <= 0 else None) for vid, need in vehicles}
    active = []
    timeline = []
    for t in range(slots):
        while len(active) < ports and queue:
            v = queue.pop(0)
            active.append([v[0], v[1], quantum])
        timeline.append(sorted(a[0] for a in active))
        nxt = []
        for a in active:
            a[1] -= 1
            a[2] -= 1
            if a[1] == 0:
                done[a[0]] = t + 1
            elif a[2] == 0:
                queue.append([a[0], a[1]])
            else:
                nxt.append(a)
        active = nxt
    return [timeline, [[k, done[k]] for k in sorted(done)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker', [[['V0', 2], ['V1', 0], ['V2', 3]], 3, 8, 1],
   [[['V0', 'V2'], ['V0', 'V2'], ['V2'], [], [], [], [], []], [['V0', 2], ['V1', 0], ['V2', 3]]]],
  ['regression: already-satisfied finish marker (partial repair)',
   [[['V0', 4], ['V1', 4], ['V2', 0], ['V3', 5], ['V4', 6], ['V5', 0]], 1, 9, 1],
   [[['V0'], ['V1'], ['V3'], ['V4'], ['V0'], ['V1'], ['V3'], ['V4'], ['V0']],
    [['V0', None], ['V1', None], ['V2', 0], ['V3', None], ['V4', None], ['V5', 0]]]],
  ['control 1', [[['V0', 1], ['V1', 4], ['V2', 6], ['V3', 2], ['V4', 5], ['V5', 5]], 1, 10, 2],
   [[['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V3'], ['V3'], ['V4'], ['V4'], ['V5']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', 7], ['V4', None], ['V5', None]]]],
  ['control 2', [[['V0', 5], ['V1', 3], ['V2', 2]], 1, 6, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2']], [['V0', None], ['V1', None], ['V2', 6]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker',
   [[['V0', 1], ['V1', 3], ['V2', 2], ['V3', 6], ['V4', 0], ['V5', 0]], 2, 5, 3],
   [[['V0', 'V1'], ['V1', 'V2'], ['V1', 'V2'], ['V3'], ['V3']],
    [['V0', 1], ['V1', 3], ['V2', 3], ['V3', None], ['V4', 0], ['V5', 0]]]],
  ['regression: already-satisfied finish marker (partial repair)', [[['V0', 0]], 1, 9, 3],
   [[[], [], [], [], [], [], [], [], []], [['V0', 0]]]],
  ['control 1', [[['V0', 1], ['V1', 6], ['V2', 6], ['V3', 1], ['V4', 1]], 1, 7, 3],
   [[['V0'], ['V1'], ['V1'], ['V1'], ['V2'], ['V2'], ['V2']],
    [['V0', 1], ['V1', None], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 2], ['V1', 2], ['V2', 3], ['V3', 0], ['V4', 4], ['V5', 3]], 1, 3, 3],
   [[['V0'], ['V0'], ['V1']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', 0], ['V4', None], ['V5', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker', [[['V0', 2], ['V1', 0]], 2, 9, 3],
   [[['V0'], ['V0'], [], [], [], [], [], [], []], [['V0', 2], ['V1', 0]]]],
  ['regression: already-satisfied finish marker (partial repair)',
   [[['V0', 4], ['V1', 0], ['V2', 3], ['V3', 1], ['V4', 0], ['V5', 4]], 2, 8, 2],
   [[['V0', 'V2'], ['V0', 'V2'], ['V3', 'V5'], ['V0', 'V5'], ['V0', 'V2'], ['V5'], ['V5'], []],
    [['V0', 5], ['V1', 0], ['V2', 5], ['V3', 3], ['V4', 0], ['V5', 7]]]],
  ['control 1', [[['V0', 0], ['V1', 6], ['V2', 4]], 2, 7, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1'], ['V1'], []],
    [['V0', 0], ['V1', 6], ['V2', 4]]]],
  ['control 2', [[['V0', 3], ['V1', 0]], 1, 3, 1],
   [[['V0'], ['V0'], ['V0']], [['V0', 3], ['V1', 0]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker',
   [[['V0', 2], ['V1', 6], ['V2', 1], ['V3', 0]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1'], ['V1']], [['V0', 2], ['V1', None], ['V2', 1], ['V3', 0]]]],
  ['regression: already-satisfied finish marker (partial repair)',
   [[['V0', 0], ['V1', 6], ['V2', 3], ['V3', 4]], 2, 9, 3],
   [[['V1', 'V2'], ['V1', 'V2'], ['V1', 'V2'], ['V1', 'V3'], ['V1', 'V3'], ['V1', 'V3'], ['V3'], [],
     []],
    [['V0', 0], ['V1', 6], ['V2', 3], ['V3', 7]]]],
  ['control 1', [[['V0', 2], ['V1', 3], ['V2', 6], ['V3', 6], ['V4', 1], ['V5', 3]], 3, 3, 2],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V3', 'V4', 'V5']],
    [['V0', 2], ['V1', None], ['V2', None], ['V3', None], ['V4', 3], ['V5', None]]]],
  ['control 2', [[['V0', 2], ['V1', 6], ['V2', 6]], 1, 10, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V2'], ['V1'], ['V1'], ['V2'], ['V2']],
    [['V0', 2], ['V1', None], ['V2', None]]]]],
 [['boundary: vehicle needing nothing', [[['A', 0], ['B', 2]], 1, 3, 1],
   [[['B'], ['B'], []], [['A', 0], ['B', 2]]]],
  ['boundary: finishes exactly at quantum end', [[['A', 2], ['B', 2]], 1, 5, 2],
   [[['A'], ['A'], ['B'], ['B'], []], [['A', 2], ['B', 4]]]],
  ['boundary: more ports than vehicles', [[['A', 3]], 2, 4, 1],
   [[['A'], ['A'], ['A'], []], [['A', 3]]]],
  ['regression: already-satisfied finish marker',
   [[['V0', 5], ['V1', 5], ['V2', 6], ['V3', 0], ['V4', 6]], 3, 8, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V4'],
     ['V0', 'V1', 'V4'], ['V2', 'V4'], ['V2', 'V4'], ['V2', 'V4']],
    [['V0', 5], ['V1', 5], ['V2', 8], ['V3', 0], ['V4', None]]]],
  ['regression: already-satisfied finish marker (partial repair)',
   [[['V0', 6], ['V1', 5], ['V2', 1], ['V3', 0], ['V4', 5], ['V5', 3]], 1, 9, 2],
   [[['V0'], ['V0'], ['V1'], ['V1'], ['V2'], ['V4'], ['V4'], ['V5'], ['V5']],
    [['V0', None], ['V1', None], ['V2', 5], ['V3', 0], ['V4', None], ['V5', None]]]],
  ['control 1', [[['V0', 4], ['V1', 3], ['V2', 4], ['V3', 5], ['V4', 6]], 3, 3, 3],
   [[['V0', 'V1', 'V2'], ['V0', 'V1', 'V2'], ['V0', 'V1', 'V2']],
    [['V0', None], ['V1', 3], ['V2', None], ['V3', None], ['V4', None]]]],
  ['control 2', [[['V0', 4], ['V1', 0], ['V2', 0], ['V3', 4], ['V4', 2]], 1, 12, 1],
   [[['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V4'], ['V0'], ['V3'], ['V0'], ['V3'], [], []],
    [['V0', 9], ['V1', 0], ['V2', 0], ['V3', 10], ['V4', 6]]]]]]
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:
Vehicles that needed no charge are reported as unfinished.

vehicles is [[id, need_slots]] in arrival order. Each slot, free ports are filled from the FIFO queue; a vehicle holds its port for quantum slots or until done, then goes to the back of the queue. Return [timeline of sorted charging ids per slot, [[id, finish]] sorted by id] where finish is the slot index after its last charging slot, 0 when nothing was needed, None if unfinished.

split: open-access