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

N = 1
observations = []
def solve(steps, scans):
    active = 0
    elapsed = 0
    entered = True
    out = []
    for dt, inputs in scans:
        if not entered:
            elapsed += dt
        entered = False
        for _hop in range(len(steps) - 1):
            min_ms, cond = steps[active]
            if not (elapsed >= min_ms and inputs.get(cond, False)):
                break
            active = (active + 1) % len(steps)
            elapsed = 0
            entered = True
        out.append([active, elapsed, entered])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2'], [100, 'T2']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [1, 90, False],
    [1, 110, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False]]],
  ['control: scenario 2',
   [[[20, 'T3'], [20, 'T3'], [20, 'T1']],
    [[50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [1, 80, False],
    [1, 105, False]]],
  ['control: scenario 3',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [2, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T2'], [0, 'T3'], [0, 'T3'], [0, 'T2']],
    [[20, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [3, 0, True],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True],
    [2, 0, True]]]],
 [['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [0, 'T1'], [50, 'T1']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [0, 0, True],
    [0, 0, False],
    [0, 25, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 1',
   [[[100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 65, False],
    [0, 75, False],
    [1, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 75, False]]],
  ['control: scenario 2',
   [[[100, 'T2'], [0, 'T1'], [50, 'T2'], [20, 'T2']],
    [[50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [0, 40, False],
    [0, 65, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 10, False],
    [2, 20, False],
    [2, 45, False],
    [2, 70, False],
    [2, 120, False],
    [3, 0, True],
    [3, 0, False]]],
  ['control: scenario 4',
   [[[0, 'T1'], [20, 'T2'], [20, 'T3']],
    [[40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 40, False],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: scenario 1',
   [[[0, 'T3'], [20, 'T2'], [0, 'T2']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False],
    [0, 0, True]]],
  ['regression: scenario 3',
   [[[50, 'T2'], [0, 'T3'], [100, 'T1'], [20, 'T3']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 25, False],
    [0, 35, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 60, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 2',
   [[[50, 'T3'], [0, 'T2'], [100, 'T1']],
    [[40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 80, False],
    [1, 0, True],
    [1, 0, False],
    [1, 25, False],
    [1, 35, False],
    [1, 60, False],
    [2, 0, True],
    [2, 0, False]]],
  ['control: scenario 4',
   [[[100, 'T1'], [50, 'T3'], [0, 'T1'], [0, 'T1']],
    [[10, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 50, False],
    [0, 70, False],
    [0, 90, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: scenario 3',
   [[[100, 'T2'], [0, 'T2'], [0, 'T3']],
    [[50, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 70, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: scenario 4',
   [[[100, 'T2'], [20, 'T1'], [0, 'T3']],
    [[50, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 40, False],
    [0, 80, False],
    [0, 105, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 70, False],
    [1, 120, False],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 1',
   [[[50, 'T1'], [50, 'T1'], [100, 'T3'], [20, 'T3']],
    [[20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False]]],
  ['regression: scenario 2',
   [[[0, 'T2'], [20, 'T3'], [0, 'T3'], [20, 'T1']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[0, 0, False], [0, 10, False], [0, 60, False], [1, 0, True], [1, 0, False], [2, 0, True]]]],
 [['regression: scenario 11',
   [[[0, 'T2'], [0, 'T1'], [0, 'T1'], [0, 'T2']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [0, 25, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 10, False],
    [3, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 65, False],
    [1, 0, True],
    [2, 0, True]]],
  ['regression: scenario 12',
   [[[50, 'T3'], [0, 'T3'], [100, 'T1']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 50, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [1, 100, False],
    [2, 0, True]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T1'], [20, 'T2']],
    [[40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 60, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [1, 90, False]]],
  ['control: scenario 2',
   [[[20, 'T1'], [20, 'T2'], [100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 35, False],
    [1, 85, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False]]]]]
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(steps, scans):
    active = 0
    elapsed = 0
    entered = True
    out = []
    for dt, inputs in scans:
        if not entered:
            elapsed += dt
        entered = False
        for _hop in range(2):
            min_ms, cond = steps[active]
            if not (elapsed >= min_ms and inputs.get(cond, False)):
                break
            active = (active + 1) % len(steps)
            elapsed = 0
            entered = True
        out.append([active, elapsed, entered])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2'], [100, 'T2']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [1, 90, False],
    [1, 110, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False]]],
  ['control: scenario 2',
   [[[20, 'T3'], [20, 'T3'], [20, 'T1']],
    [[50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [1, 80, False],
    [1, 105, False]]],
  ['control: scenario 3',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [2, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T2'], [0, 'T3'], [0, 'T3'], [0, 'T2']],
    [[20, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [3, 0, True],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True],
    [2, 0, True]]]],
 [['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [0, 'T1'], [50, 'T1']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [0, 0, True],
    [0, 0, False],
    [0, 25, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 1',
   [[[100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 65, False],
    [0, 75, False],
    [1, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 75, False]]],
  ['control: scenario 2',
   [[[100, 'T2'], [0, 'T1'], [50, 'T2'], [20, 'T2']],
    [[50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [0, 40, False],
    [0, 65, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 10, False],
    [2, 20, False],
    [2, 45, False],
    [2, 70, False],
    [2, 120, False],
    [3, 0, True],
    [3, 0, False]]],
  ['control: scenario 4',
   [[[0, 'T1'], [20, 'T2'], [20, 'T3']],
    [[40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 40, False],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: scenario 1',
   [[[0, 'T3'], [20, 'T2'], [0, 'T2']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False],
    [0, 0, True]]],
  ['regression: scenario 3',
   [[[50, 'T2'], [0, 'T3'], [100, 'T1'], [20, 'T3']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 25, False],
    [0, 35, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 60, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 2',
   [[[50, 'T3'], [0, 'T2'], [100, 'T1']],
    [[40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 80, False],
    [1, 0, True],
    [1, 0, False],
    [1, 25, False],
    [1, 35, False],
    [1, 60, False],
    [2, 0, True],
    [2, 0, False]]],
  ['control: scenario 4',
   [[[100, 'T1'], [50, 'T3'], [0, 'T1'], [0, 'T1']],
    [[10, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 50, False],
    [0, 70, False],
    [0, 90, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: scenario 3',
   [[[100, 'T2'], [0, 'T2'], [0, 'T3']],
    [[50, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 70, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: scenario 4',
   [[[100, 'T2'], [20, 'T1'], [0, 'T3']],
    [[50, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 40, False],
    [0, 80, False],
    [0, 105, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 70, False],
    [1, 120, False],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 1',
   [[[50, 'T1'], [50, 'T1'], [100, 'T3'], [20, 'T3']],
    [[20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False]]],
  ['regression: scenario 2',
   [[[0, 'T2'], [20, 'T3'], [0, 'T3'], [20, 'T1']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[0, 0, False], [0, 10, False], [0, 60, False], [1, 0, True], [1, 0, False], [2, 0, True]]]],
 [['regression: scenario 11',
   [[[0, 'T2'], [0, 'T1'], [0, 'T1'], [0, 'T2']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [0, 25, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 10, False],
    [3, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 65, False],
    [1, 0, True],
    [2, 0, True]]],
  ['regression: scenario 12',
   [[[50, 'T3'], [0, 'T3'], [100, 'T1']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 50, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [1, 100, False],
    [2, 0, True]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['control: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['control: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['control: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T1'], [20, 'T2']],
    [[40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 60, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [1, 90, False]]],
  ['control: scenario 2',
   [[[20, 'T1'], [20, 'T2'], [100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 35, False],
    [1, 85, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False]]]]]
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:
Steps whose transition is already satisfied are skipped without ever being active for a scan.

Cyclic step sequence with one active step. steps is a list of [min_time_ms, transition_tag]. Each scan [dt, inputs] first adds dt to the step time unless the step became active on the previous scan, then fires the transition if step time >= min_time and the transition tag is true. At most one transition fires per scan; after the last step the sequence returns to step 0; the new step time is 0. Step 0 is active before the first scan as if just entered. Return [active_step, step_time, entered_this_scan].

split: open-access


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

N = 1
observations = []
def solve(steps, scans):
    active = 0
    elapsed = 0
    entered = True
    out = []
    for dt, inputs in scans:
        elapsed += dt
        entered = False
        min_ms, cond = steps[active]
        if elapsed >= min_ms and inputs.get(cond, False):
            active = (active + 1) % len(steps)
            elapsed = 0
            entered = True
        out.append([active, elapsed, entered])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2'], [100, 'T2']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [1, 90, False],
    [1, 110, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False]]],
  ['regression: scenario 2',
   [[[20, 'T3'], [20, 'T3'], [20, 'T1']],
    [[50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [1, 80, False],
    [1, 105, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [2, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T2'], [0, 'T3'], [0, 'T3'], [0, 'T2']],
    [[20, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [3, 0, True],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True],
    [2, 0, True]]]],
 [['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 1',
   [[[100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 65, False],
    [0, 75, False],
    [1, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 75, False]]],
  ['regression: scenario 2',
   [[[100, 'T2'], [0, 'T1'], [50, 'T2'], [20, 'T2']],
    [[50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [0, 40, False],
    [0, 65, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 10, False],
    [2, 20, False],
    [2, 45, False],
    [2, 70, False],
    [2, 120, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [0, 'T1'], [50, 'T1']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [0, 0, True],
    [0, 0, False],
    [0, 25, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T1'], [20, 'T2'], [20, 'T3']],
    [[40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 40, False],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: scenario 1',
   [[[0, 'T3'], [20, 'T2'], [0, 'T2']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False],
    [0, 0, True]]],
  ['regression: scenario 2',
   [[[50, 'T3'], [0, 'T2'], [100, 'T1']],
    [[40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 80, False],
    [1, 0, True],
    [1, 0, False],
    [1, 25, False],
    [1, 35, False],
    [1, 60, False],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: scenario 3',
   [[[50, 'T2'], [0, 'T3'], [100, 'T1'], [20, 'T3']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 25, False],
    [0, 35, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 60, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: scenario 4',
   [[[100, 'T1'], [50, 'T3'], [0, 'T1'], [0, 'T1']],
    [[10, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 50, False],
    [0, 70, False],
    [0, 90, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 1',
   [[[50, 'T1'], [50, 'T1'], [100, 'T3'], [20, 'T3']],
    [[20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: scenario 2',
   [[[0, 'T2'], [20, 'T3'], [0, 'T3'], [20, 'T1']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[0, 0, False], [0, 10, False], [0, 60, False], [1, 0, True], [1, 0, False], [2, 0, True]]],
  ['regression: scenario 3',
   [[[100, 'T2'], [0, 'T2'], [0, 'T3']],
    [[50, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 70, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: scenario 4',
   [[[100, 'T2'], [20, 'T1'], [0, 'T3']],
    [[50, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 40, False],
    [0, 80, False],
    [0, 105, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 70, False],
    [1, 120, False],
    [2, 0, True],
    [2, 0, False]]]],
 [['regression: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T1'], [20, 'T2']],
    [[40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 60, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [1, 90, False]]],
  ['regression: scenario 2',
   [[[20, 'T1'], [20, 'T2'], [100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 35, False],
    [1, 85, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 3',
   [[[20, 'T2'], [50, 'T2'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 10, False],
    [0, 35, False],
    [1, 0, True]]],
  ['regression: scenario 4',
   [[[20, 'T1'], [50, 'T1'], [50, 'T3'], [0, 'T3']],
    [[25, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 45, False],
    [2, 55, False],
    [3, 0, True],
    [3, 0, False],
    [0, 0, True]]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(steps, scans):
    active = 0
    elapsed = 0
    entered = True
    out = []
    for dt, inputs in scans:
        elapsed += dt if not entered else dt // 2
        entered = False
        min_ms, cond = steps[active]
        if elapsed >= min_ms and inputs.get(cond, False):
            active = (active + 1) % len(steps)
            elapsed = 0
            entered = True
        out.append([active, elapsed, entered])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2'], [100, 'T2']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [1, 90, False],
    [1, 110, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False]]],
  ['regression: scenario 2',
   [[[20, 'T3'], [20, 'T3'], [20, 'T1']],
    [[50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [1, 80, False],
    [1, 105, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [100, 'T3'], [100, 'T2']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [2, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T2'], [0, 'T3'], [0, 'T3'], [0, 'T2']],
    [[20, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [3, 0, True],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True],
    [2, 0, True]]]],
 [['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 1',
   [[[100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 65, False],
    [0, 75, False],
    [1, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 75, False]]],
  ['regression: scenario 2',
   [[[100, 'T2'], [0, 'T1'], [50, 'T2'], [20, 'T2']],
    [[50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [0, 40, False],
    [0, 65, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 10, False],
    [2, 20, False],
    [2, 45, False],
    [2, 70, False],
    [2, 120, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: scenario 3',
   [[[0, 'T2'], [0, 'T1'], [50, 'T1']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [0, 0, True],
    [0, 0, False],
    [0, 25, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False],
    [0, 0, True],
    [0, 0, False],
    [1, 0, True]]],
  ['regression: scenario 4',
   [[[0, 'T1'], [20, 'T2'], [20, 'T3']],
    [[40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}]]],
   [[1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 40, False],
    [0, 0, True],
    [0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: scenario 1',
   [[[0, 'T3'], [20, 'T2'], [0, 'T2']],
    [[40, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 20, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [2, 0, True],
    [2, 0, False],
    [2, 50, False],
    [0, 0, True]]],
  ['regression: scenario 2',
   [[[50, 'T3'], [0, 'T2'], [100, 'T1']],
    [[40, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 80, False],
    [1, 0, True],
    [1, 0, False],
    [1, 25, False],
    [1, 35, False],
    [1, 60, False],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: scenario 3',
   [[[50, 'T2'], [0, 'T3'], [100, 'T1'], [20, 'T3']],
    [[25, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 25, False],
    [0, 35, False],
    [1, 0, True],
    [1, 0, False],
    [1, 40, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 60, False],
    [3, 0, True],
    [3, 0, False]]],
  ['regression: scenario 4',
   [[[100, 'T1'], [50, 'T3'], [0, 'T1'], [0, 'T1']],
    [[10, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [0, 50, False],
    [0, 70, False],
    [0, 90, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False]]]],
 [['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 1',
   [[[50, 'T1'], [50, 'T1'], [100, 'T3'], [20, 'T3']],
    [[20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [1, 0, True],
    [1, 0, False],
    [1, 50, False],
    [2, 0, True],
    [2, 0, False],
    [2, 25, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: scenario 2',
   [[[0, 'T2'], [20, 'T3'], [0, 'T3'], [20, 'T1']],
    [[25, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': True}]]],
   [[0, 0, False], [0, 10, False], [0, 60, False], [1, 0, True], [1, 0, False], [2, 0, True]]],
  ['regression: scenario 3',
   [[[100, 'T2'], [0, 'T2'], [0, 'T3']],
    [[50, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 70, False],
    [1, 0, True],
    [2, 0, True],
    [2, 0, False]]],
  ['regression: scenario 4',
   [[[100, 'T2'], [20, 'T1'], [0, 'T3']],
    [[50, {'T1': False, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': False, 'T2': False, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [0, 10, False],
    [0, 30, False],
    [0, 40, False],
    [0, 80, False],
    [0, 105, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 70, False],
    [1, 120, False],
    [2, 0, True],
    [2, 0, False]]]],
 [['regression: scenario 1',
   [[[0, 'T2'], [100, 'T3'], [100, 'T1'], [20, 'T2']],
    [[40, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': False, 'T3': False}],
     [40, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': False, 'T3': True}]]],
   [[0, 0, False],
    [0, 40, False],
    [0, 50, False],
    [0, 60, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [1, 40, False],
    [1, 80, False],
    [1, 90, False]]],
  ['regression: scenario 2',
   [[[20, 'T1'], [20, 'T2'], [100, 'T3'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 10, False],
    [1, 35, False],
    [1, 85, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False]]],
  ['regression: zero-time step chain',
   [[[20, 'A'], [0, 'B'], [30, 'C']],
    [[10, {'A': True}],
     [10, {'A': True}],
     [10, {'A': True, 'B': True}],
     [15, {'B': True}],
     [15, {'C': True}],
     [15, {'C': True}],
     [15, {'C': True}]]],
   [[0, 0, False], [0, 10, False], [1, 0, True], [2, 0, True], [2, 0, False], [2, 15, False], [0, 0, True]]],
  ['regression: two zero-time steps',
   [[[0, 'A'], [0, 'A'], [0, 'A'], [50, 'B']], [[10, {'A': True}], [10, {'A': True}], [10, {}]]],
   [[1, 0, True], [2, 0, True], [2, 0, False]]],
  ['regression: exact minimum time',
   [[[30, 'X'], [10, 'Y']],
    [[10, {}], [10, {}], [10, {}], [10, {'X': True}], [10, {'Y': True}], [10, {'Y': True}]]],
   [[0, 0, False], [0, 10, False], [0, 20, False], [1, 0, True], [1, 0, False], [0, 0, True]]],
  ['regression: late condition',
   [[[20, 'X'], [20, 'Y']], [[15, {}], [15, {}], [15, {}], [15, {'X': True}], [15, {}], [15, {'Y': True}]]],
   [[0, 0, False], [0, 15, False], [0, 30, False], [1, 0, True], [1, 0, False], [1, 15, False]]],
  ['regression: scenario 3',
   [[[20, 'T2'], [50, 'T2'], [0, 'T1']],
    [[50, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': True, 'T3': True}],
     [25, {'T1': False, 'T2': False, 'T3': False}],
     [50, {'T1': False, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [10, {'T1': False, 'T2': False, 'T3': True}],
     [25, {'T1': True, 'T2': False, 'T3': True}],
     [25, {'T1': False, 'T2': True, 'T3': False}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [2, 0, True],
    [0, 0, True],
    [0, 0, False],
    [0, 10, False],
    [0, 35, False],
    [1, 0, True]]],
  ['regression: scenario 4',
   [[[20, 'T1'], [50, 'T1'], [50, 'T3'], [0, 'T3']],
    [[25, {'T1': True, 'T2': True, 'T3': False}],
     [40, {'T1': True, 'T2': False, 'T3': False}],
     [20, {'T1': False, 'T2': False, 'T3': False}],
     [20, {'T1': True, 'T2': False, 'T3': True}],
     [40, {'T1': True, 'T2': True, 'T3': True}],
     [50, {'T1': False, 'T2': True, 'T3': True}],
     [20, {'T1': False, 'T2': True, 'T3': False}],
     [25, {'T1': True, 'T2': False, 'T3': False}],
     [10, {'T1': False, 'T2': True, 'T3': False}],
     [50, {'T1': True, 'T2': True, 'T3': True}],
     [20, {'T1': True, 'T2': True, 'T3': False}],
     [10, {'T1': True, 'T2': True, 'T3': True}]]],
   [[0, 0, False],
    [1, 0, True],
    [1, 0, False],
    [1, 20, False],
    [2, 0, True],
    [2, 0, False],
    [2, 20, False],
    [2, 45, False],
    [2, 55, False],
    [3, 0, True],
    [3, 0, False],
    [0, 0, True]]]]]
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:
Minimum step dwell times finish one scan early.

Cyclic step sequence with one active step. steps is a list of [min_time_ms, transition_tag]. Each scan [dt, inputs] first adds dt to the step time unless the step became active on the previous scan, then fires the transition if step time >= min_time and the transition tag is true. At most one transition fires per scan; after the last step the sequence returns to step 0; the new step time is 0. Step 0 is active before the first scan as if just entered. Return [active_step, step_time, entered_this_scan].

split: open-access