broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = free_at
        finish = start + math.ceil(need * 60 / pw)
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] <= depart]
    if ok:
        pw, finish, cid = min(ok)
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start',
   [[[1, 11, 0], [2, 150, 120], [3, 22, 10], [4, 3.7, 0]], [5, 101, 7.4, False], 31],
   [1, 72, 'ok']],
  ['regression: charger availability start (partial repair)',
   [[[1, 150, 10], [2, 22, 120], [3, 150, 30], [4, 3.7, 120]], [20, 111, 3.7, False], 6],
   [2, 445, 'late']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start',
   [[[1, 150, 0], [2, 7.4, 120], [3, 50, 0]], [20, 67, 11, True], 8], [3, 32, 'ok']],
  ['regression: charger availability start (partial repair)',
   [[[1, 22, 120]], [20, 345, 3.7, True], 47], [1, 445, 'late']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start',
   [[[1, 11, 60], [2, 150, 30], [3, 7.4, 0], [4, 3.7, 0], [5, 7.4, 60]], [10, 35, 3.7, False], 25],
   [3, 188, 'late']],
  ['regression: charger availability start (partial repair)',
   [[[1, 22, 120], [2, 7.4, 30]], [45, 240, 3.7, False], 22], [2, 760, 'late']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start',
   [[[1, 22, 120], [2, 7.4, 10], [3, 50, 60], [4, 7.4, 0]], [20, 375, 7.4, True], 37],
   [2, 200, 'ok']],
  ['regression: charger availability start (partial repair)',
   [[[1, 7.4, 120]], [20, 342, 11, True], 40], [1, 283, 'ok']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start', [[[1, 3.7, 0]], [45, 358, 3.7, False], 15],
   [1, 745, 'late']],
  ['regression: charger availability start (partial repair)',
   [[[1, 22, 120], [2, 7.4, 0]], [20, 121, 11, True], 24], [2, 187, 'late']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, '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
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = now
        finish = start + math.ceil(need * 60 / pw)
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] <= depart]
    if ok:
        pw, finish, cid = min(ok)
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start',
   [[[1, 11, 0], [2, 150, 120], [3, 22, 10], [4, 3.7, 0]], [5, 101, 7.4, False], 31],
   [1, 72, 'ok']],
  ['regression: charger availability start (partial repair)',
   [[[1, 150, 10], [2, 22, 120], [3, 150, 30], [4, 3.7, 120]], [20, 111, 3.7, False], 6],
   [2, 445, 'late']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start',
   [[[1, 150, 0], [2, 7.4, 120], [3, 50, 0]], [20, 67, 11, True], 8], [3, 32, 'ok']],
  ['regression: charger availability start (partial repair)',
   [[[1, 22, 120]], [20, 345, 3.7, True], 47], [1, 445, 'late']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start',
   [[[1, 11, 60], [2, 150, 30], [3, 7.4, 0], [4, 3.7, 0], [5, 7.4, 60]], [10, 35, 3.7, False], 25],
   [3, 188, 'late']],
  ['regression: charger availability start (partial repair)',
   [[[1, 22, 120], [2, 7.4, 30]], [45, 240, 3.7, False], 22], [2, 760, 'late']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start',
   [[[1, 22, 120], [2, 7.4, 10], [3, 50, 60], [4, 7.4, 0]], [20, 375, 7.4, True], 37],
   [2, 200, 'ok']],
  ['regression: charger availability start (partial repair)',
   [[[1, 7.4, 120]], [20, 342, 11, True], 40], [1, 283, 'ok']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: charger availability start', [[[1, 3.7, 0]], [45, 358, 3.7, False], 15],
   [1, 745, 'late']],
  ['regression: charger availability start (partial repair)',
   [[[1, 22, 120], [2, 7.4, 0]], [20, 121, 11, True], 24], [2, 187, 'late']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, '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:
Finish times are computed as if a busy charger were free now, or as if an idle one started in the past.

chargers are [id, kw, free_at]; kw > 22 is DC (usable only if dc_ok, full kw), otherwise AC limited to the vehicle onboard max_ac. vehicle is [need_kwh, depart, max_ac, dc_ok]. Finish = max(now, free_at) + ceil(need*60/power) minutes. Among chargers finishing by depart pick the lowest power, then earliest finish, then id; otherwise the earliest finish (then id) with status 'late'. Return [id, finish, status] or None when no charger is usable.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = max(now, free_at)
        finish = start + int(need * 60 / pw)
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] <= depart]
    if ok:
        pw, finish, cid = min(ok)
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding',
   [[[1, 150, 10], [2, 22, 120], [3, 150, 30], [4, 3.7, 120]], [20, 111, 3.7, False], 6],
   [2, 445, 'late']],
  ['regression: duration rounding (partial repair)',
   [[[1, 11, 0], [2, 150, 120], [3, 22, 10], [4, 3.7, 0]], [5, 101, 7.4, False], 31],
   [1, 72, 'ok']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding',
   [[[1, 11, 0], [2, 3.7, 0], [3, 22, 0], [4, 7.4, 60], [5, 150, 10]], [5, 326, 11, True], 13],
   [2, 95, 'ok']],
  ['regression: duration rounding (partial repair)',
   [[[1, 150, 0], [2, 7.4, 120], [3, 50, 0]], [20, 67, 11, True], 8], [3, 32, 'ok']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding',
   [[[1, 11, 60], [2, 150, 30], [3, 7.4, 0], [4, 3.7, 0], [5, 7.4, 60]], [10, 35, 3.7, False], 25],
   [3, 188, 'late']],
  ['regression: duration rounding (partial repair)',
   [[[1, 22, 120], [2, 7.4, 30]], [45, 240, 3.7, False], 22], [2, 760, 'late']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding',
   [[[1, 22, 120], [2, 7.4, 10], [3, 50, 60], [4, 7.4, 0]], [20, 375, 7.4, True], 37],
   [2, 200, 'ok']],
  ['regression: duration rounding (partial repair)',
   [[[1, 7.4, 0], [2, 150, 0]], [5, 263, 11, True], 56], [1, 97, 'ok']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding', [[[1, 3.7, 0]], [45, 358, 3.7, False], 15], [1, 745, 'late']],
  ['regression: duration rounding (partial repair)',
   [[[1, 50, 0], [2, 50, 30]], [10, 89, 7.4, True], 45], [1, 57, 'ok']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, '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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = max(now, free_at)
        finish = start + math.ceil(need / pw) * 60
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] <= depart]
    if ok:
        pw, finish, cid = min(ok)
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding',
   [[[1, 150, 10], [2, 22, 120], [3, 150, 30], [4, 3.7, 120]], [20, 111, 3.7, False], 6],
   [2, 445, 'late']],
  ['regression: duration rounding (partial repair)',
   [[[1, 11, 0], [2, 150, 120], [3, 22, 10], [4, 3.7, 0]], [5, 101, 7.4, False], 31],
   [1, 72, 'ok']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding',
   [[[1, 11, 0], [2, 3.7, 0], [3, 22, 0], [4, 7.4, 60], [5, 150, 10]], [5, 326, 11, True], 13],
   [2, 95, 'ok']],
  ['regression: duration rounding (partial repair)',
   [[[1, 150, 0], [2, 7.4, 120], [3, 50, 0]], [20, 67, 11, True], 8], [3, 32, 'ok']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding',
   [[[1, 11, 60], [2, 150, 30], [3, 7.4, 0], [4, 3.7, 0], [5, 7.4, 60]], [10, 35, 3.7, False], 25],
   [3, 188, 'late']],
  ['regression: duration rounding (partial repair)',
   [[[1, 22, 120], [2, 7.4, 30]], [45, 240, 3.7, False], 22], [2, 760, 'late']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding',
   [[[1, 22, 120], [2, 7.4, 10], [3, 50, 60], [4, 7.4, 0]], [20, 375, 7.4, True], 37],
   [2, 200, 'ok']],
  ['regression: duration rounding (partial repair)',
   [[[1, 7.4, 0], [2, 150, 0]], [5, 263, 11, True], 56], [1, 97, 'ok']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: duration rounding', [[[1, 3.7, 0]], [45, 358, 3.7, False], 15], [1, 745, 'late']],
  ['regression: duration rounding (partial repair)',
   [[[1, 50, 0], [2, 50, 30]], [10, 89, 7.4, True], 45], [1, 57, 'ok']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, '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:
Some sessions are reported as finishing a minute early.

chargers are [id, kw, free_at]; kw > 22 is DC (usable only if dc_ok, full kw), otherwise AC limited to the vehicle onboard max_ac. vehicle is [need_kwh, depart, max_ac, dc_ok]. Finish = max(now, free_at) + ceil(need*60/power) minutes. Among chargers finishing by depart pick the lowest power, then earliest finish, then id; otherwise the earliest finish (then id) with status 'late'. Return [id, finish, status] or None when no charger is usable.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = max(now, free_at)
        finish = start + math.ceil(need * 60 / pw)
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] < depart]
    if ok:
        pw, finish, cid = min(ok)
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 7.4, 60], [2, 150, 60], [3, 3.7, 0]], [30, 74, 11, True], 46], [2, 72, 'ok']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None],
  ['control 3', [[[1, 7.4, 120], [2, 50, 0], [3, 50, 0], [4, 50, 120]], [45, 375, 11, True], 13],
   [2, 67, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 50, 120], [2, 7.4, 0], [3, 3.7, 0], [4, 7.4, 60], [5, 50, 10]], [20, 64, 3.7, True], 31],
   [5, 55, 'ok']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']],
  ['control 3', [[[1, 150, 120], [2, 7.4, 60]], [20, 386, 11, True], 0], [2, 223, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 50, 0], [2, 50, 120], [3, 7.4, 10], [4, 3.7, 0]], [5, 54, 7.4, True], 37], [1, 43, 'ok']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']],
  ['control 3',
   [[[1, 22, 120], [2, 50, 30], [3, 150, 0], [4, 7.4, 60], [5, 7.4, 120]], [5, 316, 7.4, True], 35],
   [4, 101, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 7.4, 0], [2, 50, 10], [3, 50, 0], [4, 150, 30], [5, 22, 0]], [10, 143, 7.4, True], 58],
   [1, 140, 'ok']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']],
  ['control 3', [[[1, 3.7, 10], [2, 50, 60], [3, 22, 10], [4, 7.4, 10]], [30, 289, 7.4, True], 35],
   [3, 279, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 7.4, 0], [2, 50, 10], [3, 50, 0], [4, 150, 30], [5, 22, 0]], [10, 143, 7.4, True], 58],
   [1, 140, 'ok']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, 'ok']],
  ['control 3', [[[1, 50, 0]], [5, 182, 7.4, False], 45], None]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = max(now, free_at)
        finish = start + math.ceil(need * 60 / pw)
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] + 15 <= depart]
    if ok:
        pw, finish, cid = min(ok)
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 7.4, 60], [2, 150, 60], [3, 3.7, 0]], [30, 74, 11, True], 46], [2, 72, 'ok']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None],
  ['control 3', [[[1, 7.4, 120], [2, 50, 0], [3, 50, 0], [4, 50, 120]], [45, 375, 11, True], 13],
   [2, 67, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 50, 120], [2, 7.4, 0], [3, 3.7, 0], [4, 7.4, 60], [5, 50, 10]], [20, 64, 3.7, True], 31],
   [5, 55, 'ok']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']],
  ['control 3', [[[1, 150, 120], [2, 7.4, 60]], [20, 386, 11, True], 0], [2, 223, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 50, 0], [2, 50, 120], [3, 7.4, 10], [4, 3.7, 0]], [5, 54, 7.4, True], 37], [1, 43, 'ok']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']],
  ['control 3',
   [[[1, 22, 120], [2, 50, 30], [3, 150, 0], [4, 7.4, 60], [5, 7.4, 120]], [5, 316, 7.4, True], 35],
   [4, 101, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 7.4, 0], [2, 50, 10], [3, 50, 0], [4, 150, 30], [5, 22, 0]], [10, 143, 7.4, True], 58],
   [1, 140, 'ok']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']],
  ['control 3', [[[1, 3.7, 10], [2, 50, 60], [3, 22, 10], [4, 7.4, 10]], [30, 289, 7.4, True], 35],
   [3, 279, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: deadline inclusivity (partial repair)',
   [[[1, 7.4, 0], [2, 50, 10], [3, 50, 0], [4, 150, 30], [5, 22, 0]], [10, 143, 7.4, True], 58],
   [1, 140, 'ok']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, 'ok']],
  ['control 3', [[[1, 50, 0]], [5, 182, 7.4, False], 45], None]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A charger finishing exactly at departure is reported as late.

chargers are [id, kw, free_at]; kw > 22 is DC (usable only if dc_ok, full kw), otherwise AC limited to the vehicle onboard max_ac. vehicle is [need_kwh, depart, max_ac, dc_ok]. Finish = max(now, free_at) + ceil(need*60/power) minutes. Among chargers finishing by depart pick the lowest power, then earliest finish, then id; otherwise the earliest finish (then id) with status 'late'. Return [id, finish, status] or None when no charger is usable.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = max(now, free_at)
        finish = start + math.ceil(need * 60 / pw)
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] <= depart]
    if ok:
        pw, finish, cid = min(ok, key=lambda o: (o[1], o[2]))
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 3.7, 30], [2, 3.7, 60], [3, 11, 30], [4, 22, 120]], [10, 332, 11, True], 57],
   [1, 220, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 50, 30], [2, 22, 30], [3, 50, 120], [4, 22, 0]], [5, 150, 7.4, True], 10], [4, 51, 'ok']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 150, 0], [2, 7.4, 120], [3, 50, 0]], [20, 67, 11, True], 8], [3, 32, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 3.7, 10], [2, 7.4, 0], [3, 50, 60], [4, 50, 30], [5, 7.4, 10]], [20, 252, 3.7, True], 34],
   [4, 58, 'ok']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 150, 0], [2, 7.4, 30], [3, 7.4, 0], [4, 3.7, 60], [5, 7.4, 60]], [5, 300, 3.7, True], 48],
   [2, 130, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 150, 120], [2, 50, 0], [3, 50, 10], [4, 22, 60], [5, 22, 0]], [20, 374, 7.4, True], 19],
   [5, 182, 'ok']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 22, 120], [2, 7.4, 10], [3, 50, 60], [4, 7.4, 0]], [20, 375, 7.4, True], 37],
   [2, 200, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 150, 0], [2, 150, 10], [3, 22, 30], [4, 7.4, 10]], [10, 278, 7.4, False], 17],
   [4, 99, 'ok']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 50, 60], [2, 11, 0], [3, 7.4, 0]], [45, 352, 11, True], 50], [2, 296, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 50, 30], [2, 50, 60], [3, 50, 0]], [10, 216, 3.7, True], 29], [3, 41, 'ok']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, '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
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = max(now, free_at)
        finish = start + math.ceil(need * 60 / pw)
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] <= depart]
    if ok:
        pw, finish, cid = min(ok, key=lambda o: o[0])
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts, key=lambda o: (o[1], o[2]))
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 3.7, 30], [2, 3.7, 60], [3, 11, 30], [4, 22, 120]], [10, 332, 11, True], 57],
   [1, 220, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 50, 30], [2, 22, 30], [3, 50, 120], [4, 22, 0]], [5, 150, 7.4, True], 10], [4, 51, 'ok']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 150, 0], [2, 7.4, 120], [3, 50, 0]], [20, 67, 11, True], 8], [3, 32, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 3.7, 10], [2, 7.4, 0], [3, 50, 60], [4, 50, 30], [5, 7.4, 10]], [20, 252, 3.7, True], 34],
   [4, 58, 'ok']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 150, 0], [2, 7.4, 30], [3, 7.4, 0], [4, 3.7, 60], [5, 7.4, 60]], [5, 300, 3.7, True], 48],
   [2, 130, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 150, 120], [2, 50, 0], [3, 50, 10], [4, 22, 60], [5, 22, 0]], [20, 374, 7.4, True], 19],
   [5, 182, 'ok']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 22, 120], [2, 7.4, 10], [3, 50, 60], [4, 7.4, 0]], [20, 375, 7.4, True], 37],
   [2, 200, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 150, 0], [2, 150, 10], [3, 22, 30], [4, 7.4, 10]], [10, 278, 7.4, False], 17],
   [4, 99, 'ok']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: feasible charger preference',
   [[[1, 50, 60], [2, 11, 0], [3, 7.4, 0]], [45, 352, 11, True], 50], [2, 296, 'ok']],
  ['regression: feasible charger preference (partial repair)',
   [[[1, 50, 30], [2, 50, 60], [3, 50, 0]], [10, 216, 3.7, True], 29], [3, 41, 'ok']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, '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:
Short-stay vehicles take fast DC chargers that slower AC points could serve in time.

chargers are [id, kw, free_at]; kw > 22 is DC (usable only if dc_ok, full kw), otherwise AC limited to the vehicle onboard max_ac. vehicle is [need_kwh, depart, max_ac, dc_ok]. Finish = max(now, free_at) + ceil(need*60/power) minutes. Among chargers finishing by depart pick the lowest power, then earliest finish, then id; otherwise the earliest finish (then id) with status 'late'. Return [id, finish, status] or None when no charger is usable.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = max(now, free_at)
        finish = start + math.ceil(need * 60 / pw)
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] <= depart]
    if ok:
        pw, finish, cid = min(ok)
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts)
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 10], [2, 3.7, 10], [3, 7.4, 60], [4, 3.7, 10], [5, 22, 60]], [45, 74, 7.4, False], 19],
   [1, 384, 'late']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 3.7, 10], [2, 3.7, 0], [3, 3.7, 0], [4, 150, 30]], [45, 37, 7.4, True], 24],
   [4, 48, 'late']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 7.4, 10], [3, 150, 60], [4, 3.7, 30], [5, 7.4, 60]], [45, 336, 11, False], 2],
   [1, 367, 'late']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 0], [2, 7.4, 30], [3, 50, 60], [4, 3.7, 30]], [30, 129, 7.4, False], 26],
   [1, 270, 'late']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 3.7, 60], [3, 3.7, 0], [4, 7.4, 0]], [30, 244, 11, True], 29],
   [1, 273, 'late']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, '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
import math
N = 1
observations = []
def solve(chargers, vehicle, now):
    need, depart, max_ac, dc_ok = vehicle
    opts = []
    for cid, kw, free_at in chargers:
        if kw > 22:
            if not dc_ok:
                continue
            pw = kw
        else:
            pw = min(kw, max_ac)
        start = max(now, free_at)
        finish = start + math.ceil(need * 60 / pw)
        opts.append([pw, finish, cid])
    if not opts:
        return None
    ok = [o for o in opts if o[1] <= depart]
    if ok:
        pw, finish, cid = min(ok)
        return [cid, finish, 'ok']
    pw, finish, cid = min(opts, key=lambda o: (o[1], -o[0]))
    return [cid, finish, 'late']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 10], [2, 3.7, 10], [3, 7.4, 60], [4, 3.7, 10], [5, 22, 60]], [45, 74, 7.4, False], 19],
   [1, 384, 'late']],
  ['control 1', [[[1, 22, 60]], [5, 244, 11, False], 8], [1, 88, 'ok']],
  ['control 2', [[[1, 50, 0], [2, 50, 0]], [5, 160, 11, False], 39], None]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 3.7, 10], [2, 3.7, 0], [3, 3.7, 0], [4, 150, 30]], [45, 37, 7.4, True], 24],
   [4, 48, 'late']],
  ['control 1', [[[1, 50, 0]], [45, 63, 7.4, True], 12], [1, 66, 'late']],
  ['control 2',
   [[[1, 7.4, 60], [2, 7.4, 10], [3, 22, 10], [4, 11, 120], [5, 50, 120]], [45, 353, 7.4, True],
    45],
   [5, 174, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 7.4, 10], [3, 150, 60], [4, 3.7, 30], [5, 7.4, 60]], [45, 336, 11, False], 2],
   [1, 367, 'late']],
  ['control 1', [[[1, 7.4, 10], [2, 7.4, 0]], [45, 88, 7.4, True], 40], [1, 405, 'late']],
  ['control 2', [[[1, 3.7, 10], [2, 3.7, 120], [3, 11, 10], [4, 50, 0]], [5, 42, 7.4, True], 27],
   [4, 33, 'ok']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 22, 0], [2, 7.4, 30], [3, 50, 60], [4, 3.7, 30]], [30, 129, 7.4, False], 26],
   [1, 270, 'late']],
  ['control 1', [[[1, 7.4, 60]], [30, 240, 3.7, True], 21], [1, 547, 'late']],
  ['control 2', [[[1, 3.7, 60], [2, 3.7, 120], [3, 150, 30], [4, 150, 0]], [45, 67, 11, False], 57],
   [1, 790, 'late']]],
 [['boundary: 22 kW AC charger', [[[1, 22, 0]], [11, 300, 11, False], 0], [1, 60, 'ok']],
  ['boundary: finish exactly at departure', [[[1, 7.4, 0]], [37, 300, 7.4, True], 0],
   [1, 300, 'ok']],
  ['boundary: only DC and no DC support', [[[1, 50, 0]], [10, 100, 11, False], 0], None],
  ['regression: late tie on finish time', [[[1, 7.4, 0], [2, 11, 27]], [10, 50, 11, False], 0],
   [1, 82, 'late']],
  ['regression: late fallback ranking',
   [[[1, 7.4, 0], [2, 3.7, 60], [3, 3.7, 0], [4, 7.4, 0]], [30, 244, 11, True], 29],
   [1, 273, 'late']],
  ['control 1', [[[1, 50, 60], [2, 50, 60]], [45, 130, 7.4, True], 48], [1, 114, 'ok']],
  ['control 2', [[[1, 150, 0], [2, 7.4, 10]], [10, 89, 3.7, True], 57], [1, 61, '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:
When nothing can finish in time the vehicle is sent to the slowest charger.

chargers are [id, kw, free_at]; kw > 22 is DC (usable only if dc_ok, full kw), otherwise AC limited to the vehicle onboard max_ac. vehicle is [need_kwh, depart, max_ac, dc_ok]. Finish = max(now, free_at) + ceil(need*60/power) minutes. Among chargers finishing by depart pick the lowest power, then earliest finish, then id; otherwise the earliest finish (then id) with status 'late'. Return [id, finish, status] or None when no charger is usable.

split: open-access


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

N = 1
observations = []
def solve(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % max_delay if max_delay else 0
    start = max(tariff_start, now) + delay
    latest = depart - dur
    if start > latest:
        start = max(latest, now)
    status = 'ok' if start + dur <= depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP278', 28, 172, 319, 97, 30], [181, 9, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP201', 49, 94, 552, 247, 5],
   [98, 4, 'ok']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP272', 217, 184, 482, 298, 15], [184, 15, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP363', 205, 166, 509, 88, 10],
   [209, 4, 'ok']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP201', 269, 83, 492, 35, 10], [269, 0, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP896', 198, 47, 277, 26, 15],
   [211, 13, 'ok']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP996', 26, 122, 444, 207, 5], [124, 2, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP267', 210, 178, 655, 84, 5],
   [214, 4, 'ok']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP353', 241, 118, 320, 150, 5], [170, 1, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP168', 85, 91, 538, 99, 30],
   [93, 2, 'ok']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % (max_delay - 1) if max_delay > 1 else 0
    start = max(tariff_start, now) + delay
    latest = depart - dur
    if start > latest:
        start = max(latest, now)
    status = 'ok' if start + dur <= depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP278', 28, 172, 319, 97, 30], [181, 9, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP201', 49, 94, 552, 247, 5],
   [98, 4, 'ok']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP272', 217, 184, 482, 298, 15], [184, 15, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP363', 205, 166, 509, 88, 10],
   [209, 4, 'ok']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP201', 269, 83, 492, 35, 10], [269, 0, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP896', 198, 47, 277, 26, 15],
   [211, 13, 'ok']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP996', 26, 122, 444, 207, 5], [124, 2, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP267', 210, 178, 655, 84, 5],
   [214, 4, 'ok']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: delay modulus range', ['CP353', 241, 118, 320, 150, 5], [170, 1, 'ok']],
  ['regression: delay modulus range (partial repair)', ['CP168', 85, 91, 538, 99, 30],
   [93, 2, 'ok']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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 configured maximum delay is never used and some chargers start earlier than intended.

To avoid a demand spike at a tariff switch each charger delays its start by delay = sum((i+1)*ord(c) for i, c in enumerate(cid)) % (max_delay+1) minutes after max(tariff_start, now). If that start is later than depart - dur it is pulled back to max(depart - dur, now). Status is 'ok' when start + dur <= depart else 'late'. Return [start, delay, status].

split: open-access


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

N = 1
observations = []
def solve(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % (max_delay + 1)
    start = tariff_start + delay
    latest = depart - dur
    if start > latest:
        start = max(latest, now)
    status = 'ok' if start + dur <= depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP201', 49, 94, 552, 247, 5], [98, 4, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP778', 179, 65, 525, 61, 0],
   [179, 0, 'ok']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP321', 7, 32, 498, 89, 15], [41, 9, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP363', 205, 166, 509, 88, 10],
   [209, 4, 'ok']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP473', 52, 113, 448, 84, 0], [113, 0, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP201', 269, 83, 492, 35, 10],
   [269, 0, 'ok']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP951', 78, 134, 388, 193, 0], [134, 0, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP907', 199, 117, 410, 31, 0],
   [199, 0, 'ok']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP544', 22, 72, 471, 102, 5], [74, 2, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP353', 241, 118, 320, 150, 5],
   [170, 1, 'ok']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % (max_delay + 1)
    start = now + delay
    latest = depart - dur
    if start > latest:
        start = max(latest, now)
    status = 'ok' if start + dur <= depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP201', 49, 94, 552, 247, 5], [98, 4, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP778', 179, 65, 525, 61, 0],
   [179, 0, 'ok']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP321', 7, 32, 498, 89, 15], [41, 9, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP363', 205, 166, 509, 88, 10],
   [209, 4, 'ok']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP473', 52, 113, 448, 84, 0], [113, 0, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP201', 269, 83, 492, 35, 10],
   [269, 0, 'ok']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP951', 78, 134, 388, 193, 0], [134, 0, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP907', 199, 117, 410, 31, 0],
   [199, 0, 'ok']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: stagger base time', ['CP544', 22, 72, 471, 102, 5], [74, 2, 'ok']],
  ['regression: stagger base time (partial repair)', ['CP353', 241, 118, 320, 150, 5],
   [170, 1, 'ok']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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:
Chargers plugged in after the tariff switch are scheduled to start in the past.

To avoid a demand spike at a tariff switch each charger delays its start by delay = sum((i+1)*ord(c) for i, c in enumerate(cid)) % (max_delay+1) minutes after max(tariff_start, now). If that start is later than depart - dur it is pulled back to max(depart - dur, now). Status is 'ok' when start + dur <= depart else 'late'. Return [start, delay, status].

split: open-access


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

N = 1
observations = []
def solve(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % (max_delay + 1)
    start = max(tariff_start, now) + delay
    latest = depart - dur
    status = 'ok' if start + dur <= depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP495', 117, 47, 359, 266, 0], [93, 0, 'ok']],
  ['regression: deadline pull-back (partial repair)', ['CP294', 180, 7, 58, 277, 5],
   [7, 1, 'late']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP272', 217, 184, 482, 298, 15], [184, 15, 'ok']],
  ['regression: deadline pull-back (partial repair)', ['CP811', 93, 183, 218, 113, 30],
   [183, 30, 'late']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP803', 164, 112, 215, 145, 5], [112, 2, 'late']],
  ['regression: deadline pull-back (partial repair)', ['CP542', 144, 130, 131, 254, 30],
   [130, 7, 'late']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP174', 226, 53, 139, 171, 5], [53, 2, 'late']],
  ['regression: deadline pull-back (partial repair)', ['CP172', 184, 1, 37, 143, 30],
   [1, 7, 'late']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP353', 241, 118, 320, 150, 5], [170, 1, 'ok']],
  ['regression: deadline pull-back (partial repair)', ['CP776', 104, 179, 210, 259, 30],
   [179, 14, 'late']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % (max_delay + 1)
    start = max(tariff_start, now) + delay
    latest = depart - dur
    if start > latest:
        start = latest
    status = 'ok' if start + dur <= depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP495', 117, 47, 359, 266, 0], [93, 0, 'ok']],
  ['regression: deadline pull-back (partial repair)', ['CP294', 180, 7, 58, 277, 5],
   [7, 1, 'late']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP272', 217, 184, 482, 298, 15], [184, 15, 'ok']],
  ['regression: deadline pull-back (partial repair)', ['CP811', 93, 183, 218, 113, 30],
   [183, 30, 'late']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP803', 164, 112, 215, 145, 5], [112, 2, 'late']],
  ['regression: deadline pull-back (partial repair)', ['CP542', 144, 130, 131, 254, 30],
   [130, 7, 'late']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP174', 226, 53, 139, 171, 5], [53, 2, 'late']],
  ['regression: deadline pull-back (partial repair)', ['CP172', 184, 1, 37, 143, 30],
   [1, 7, 'late']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: deadline pull-back', ['CP353', 241, 118, 320, 150, 5], [170, 1, 'ok']],
  ['regression: deadline pull-back (partial repair)', ['CP776', 104, 179, 210, 259, 30],
   [179, 14, 'late']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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 staggered start pushes a short-dwell session past its departure.

To avoid a demand spike at a tariff switch each charger delays its start by delay = sum((i+1)*ord(c) for i, c in enumerate(cid)) % (max_delay+1) minutes after max(tariff_start, now). If that start is later than depart - dur it is pulled back to max(depart - dur, now). Status is 'ok' when start + dur <= depart else 'late'. Return [start, delay, status].

split: open-access


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

N = 1
observations = []
def solve(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % (max_delay + 1)
    start = max(tariff_start, now) + delay
    latest = depart - dur
    if start > latest:
        start = max(latest, now)
    status = 'ok' if start + dur < depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP495', 117, 47, 359, 266, 0], [93, 0, 'ok']],
  ['regression: late status test (partial repair)', ['CP929', 258, 12, 235, 31, 30],
   [204, 15, 'ok']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP272', 217, 184, 482, 298, 15], [184, 15, 'ok']],
  ['regression: late status test (partial repair)', ['CP990', 237, 16, 437, 299, 30],
   [138, 29, 'ok']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP959', 232, 65, 118, 10, 0], [108, 0, 'ok']],
  ['regression: late status test (partial repair)', ['CP466', 247, 123, 302, 127, 5],
   [175, 5, 'ok']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['regression: late status test (partial repair)', ['CP456', 283, 85, 221, 105, 30],
   [116, 28, 'ok']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP353', 241, 118, 320, 150, 5], [170, 1, 'ok']],
  ['regression: late status test (partial repair)', ['CP688', 218, 40, 172, 121, 10],
   [51, 2, 'ok']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % (max_delay + 1)
    start = max(tariff_start, now) + delay
    latest = depart - dur
    if start > latest:
        start = max(latest, now)
    status = 'ok' if start + dur + delay <= depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP495', 117, 47, 359, 266, 0], [93, 0, 'ok']],
  ['regression: late status test (partial repair)', ['CP929', 258, 12, 235, 31, 30],
   [204, 15, 'ok']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP272', 217, 184, 482, 298, 15], [184, 15, 'ok']],
  ['regression: late status test (partial repair)', ['CP990', 237, 16, 437, 299, 30],
   [138, 29, 'ok']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP959', 232, 65, 118, 10, 0], [108, 0, 'ok']],
  ['regression: late status test (partial repair)', ['CP466', 247, 123, 302, 127, 5],
   [175, 5, 'ok']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['regression: late status test (partial repair)', ['CP456', 283, 85, 221, 105, 30],
   [116, 28, 'ok']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: late status test', ['CP353', 241, 118, 320, 150, 5], [170, 1, 'ok']],
  ['regression: late status test (partial repair)', ['CP688', 218, 40, 172, 121, 10],
   [51, 2, 'ok']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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:
Sessions that finish exactly at departure are flagged late.

To avoid a demand spike at a tariff switch each charger delays its start by delay = sum((i+1)*ord(c) for i, c in enumerate(cid)) % (max_delay+1) minutes after max(tariff_start, now). If that start is later than depart - dur it is pulled back to max(depart - dur, now). Status is 'ok' when start + dur <= depart else 'late'. Return [start, delay, status].

split: open-access


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

N = 1
observations = []
def solve(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % (max_delay + 1)
    start = max(tariff_start, now) + delay
    latest = depart - dur - delay
    if start > latest:
        start = max(latest, now)
    status = 'ok' if start + dur <= depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP929', 258, 12, 235, 31, 30], [204, 15, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP495', 117, 47, 359, 266, 0],
   [93, 0, 'ok']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP990', 237, 16, 437, 299, 30], [138, 29, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP272', 217, 184, 482, 298, 15],
   [184, 15, 'ok']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP466', 247, 123, 302, 127, 5], [175, 5, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP803', 164, 112, 215, 145, 5],
   [112, 2, 'late']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP174', 226, 53, 139, 171, 5],
   [53, 2, 'late']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP353', 241, 118, 320, 150, 5], [170, 1, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP776', 104, 179, 210, 259, 30],
   [179, 14, 'late']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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(cid, tariff_start, now, depart, dur, max_delay):
    delay = sum((i + 1) * ord(c) for i, c in enumerate(cid)) % (max_delay + 1)
    start = max(tariff_start, now) + delay
    latest = depart
    if start > latest:
        start = max(latest, now)
    status = 'ok' if start + dur <= depart else 'late'
    return [start, delay, status]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP929', 258, 12, 235, 31, 30], [204, 15, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP495', 117, 47, 359, 266, 0],
   [93, 0, 'ok']],
  ['control 1', ['CP310', 208, 18, 199, 159, 0], [40, 0, 'ok']],
  ['control 2', ['CP766', 294, 150, 208, 201, 30], [150, 10, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP990', 237, 16, 437, 299, 30], [138, 29, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP272', 217, 184, 482, 298, 15],
   [184, 15, 'ok']],
  ['control 1', ['CP883', 235, 120, 211, 80, 5], [131, 4, 'ok']],
  ['control 2', ['CP742', 19, 177, 199, 247, 10], [177, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP466', 247, 123, 302, 127, 5], [175, 5, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP803', 164, 112, 215, 145, 5],
   [112, 2, 'late']],
  ['control 1', ['CP783', 204, 99, 341, 202, 5], [139, 1, 'ok']],
  ['control 2', ['CP490', 211, 107, 512, 167, 10], [215, 4, 'ok']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP174', 226, 53, 139, 171, 5],
   [53, 2, 'late']],
  ['control 1', ['CP137', 10, 19, 66, 6, 15], [24, 5, 'ok']],
  ['control 2', ['CP783', 210, 193, 350, 267, 30], [193, 3, 'late']]],
 [['boundary: no stagger configured', ['CP7', 100, 50, 400, 60, 0], [100, 0, 'ok']],
  ['boundary: deadline forces immediate start', ['CP12', 100, 50, 120, 70, 30], [50, 16, 'ok']],
  ['boundary: tariff already active', ['CP3', 10, 50, 400, 60, 10], [56, 6, 'ok']],
  ['regression: latest start derivation', ['CP353', 241, 118, 320, 150, 5], [170, 1, 'ok']],
  ['regression: latest start derivation (partial repair)', ['CP776', 104, 179, 210, 259, 30],
   [179, 14, 'late']],
  ['control 1', ['CP873', 194, 7, 146, 117, 15], [29, 6, 'ok']],
  ['control 2', ['CP733', 56, 136, 418, 4, 0], [136, 0, '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 pulled forward even when the staggered start would still finish in time.

To avoid a demand spike at a tariff switch each charger delays its start by delay = sum((i+1)*ord(c) for i, c in enumerate(cid)) % (max_delay+1) minutes after max(tariff_start, now). If that start is later than depart - dur it is pulled back to max(depart - dur, now). Status is 'ok' when start + dur <= depart else 'late'. Return [start, delay, status].

split: open-access


prompt:
A zero-length placeholder interval inserts a spurious zero-power change point.

plan holds [start, end, kw] charging intervals ([start, end), zero-length ignored). Build the site profile as change points [[t, total_kw]] over the interval breakpoints, merging equal consecutive levels, and close with [last breakpoint, 0] unless the profile already ends at 0. Also return the start points of segments whose total exceeds site_max. Return [profile, overloads].

split: open-access


prompt:
The final segment of every charging interval drops out of the site profile.

plan holds [start, end, kw] charging intervals ([start, end), zero-length ignored). Build the site profile as change points [[t, total_kw]] over the interval breakpoints, merging equal consecutive levels, and close with [last breakpoint, 0] unless the profile already ends at 0. Also return the start points of segments whose total exceeds site_max. Return [profile, overloads].

split: open-access


prompt:
The profile repeats the same power level at every breakpoint.

plan holds [start, end, kw] charging intervals ([start, end), zero-length ignored). Build the site profile as change points [[t, total_kw]] over the interval breakpoints, merging equal consecutive levels, and close with [last breakpoint, 0] unless the profile already ends at 0. Also return the start points of segments whose total exceeds site_max. Return [profile, overloads].

split: open-access


prompt:
Running exactly at the site limit is reported as an overload.

plan holds [start, end, kw] charging intervals ([start, end), zero-length ignored). Build the site profile as change points [[t, total_kw]] over the interval breakpoints, merging equal consecutive levels, and close with [last breakpoint, 0] unless the profile already ends at 0. Also return the start points of segments whose total exceeds site_max. Return [profile, overloads].

split: open-access


prompt:
Profiles that already end at zero get a duplicate zero change point.

plan holds [start, end, kw] charging intervals ([start, end), zero-length ignored). Build the site profile as change points [[t, total_kw]] over the interval breakpoints, merging equal consecutive levels, and close with [last breakpoint, 0] unless the profile already ends at 0. Also return the start points of segments whose total exceeds site_max. Return [profile, overloads].

split: open-access