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

N = 1
observations = []
def solve(interval, max_minutes, samples):
    acc = 0
    defrost_min = None
    out = []
    for running, coil, outdoor in samples:
        if defrost_min is not None:
            defrost_min += 1
            if coil >= 57 or defrost_min >= max_minutes:
                defrost_min = None
                out.append('heat' if running else 'off')
            else:
                out.append('defrost')
            continue
        if running:
            acc += 1
        if acc >= interval and outdoor <= 50:
            acc = 0
            defrost_min = 0
            out.append('defrost')
            continue
        out.append('heat' if running else 'off')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 1',
   [3,
    3,
    [[True, 40, 35],
     [True, 40, 50],
     [True, 40, 51],
     [True, 40, 51],
     [True, 40, 50],
     [True, 40, 50],
     [False, 20, 35],
     [False, 20, 51],
     [True, 20, 50],
     [True, 50, 20],
     [True, 50, 50],
     [True, 56, 50],
     [True, 40, 50],
     [True, 40, 50],
     [False, 40, 51],
     [True, 40, 50],
     [False, 20, 51],
     [False, 20, 60],
     [True, 57, 51],
     [False, 57, 51]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'off']],
  ['regression: scenario 2',
   [4,
    3,
    [[True, 33, 60],
     [False, 57, 20],
     [True, 57, 50],
     [True, 60, 20],
     [True, 60, 35],
     [True, 60, 50],
     [True, 28, 50],
     [True, 28, 20],
     [True, 28, 20],
     [False, 28, 50],
     [True, 28, 51],
     [True, 28, 35],
     [True, 28, 60],
     [True, 28, 50],
     [True, 40, 50],
     [True, 40, 50],
     [False, 40, 60]]],
   ['heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'off']],
  ['control: scenario 3',
   [5,
    3,
    [[True, 20, 20],
     [True, 20, 50],
     [True, 20, 50],
     [True, 20, 50],
     [True, 20, 35],
     [True, 40, 50],
     [False, 40, 20],
     [True, 40, 50],
     [True, 40, 50],
     [True, 33, 60],
     [False, 33, 60],
     [True, 60, 50]]],
   ['heat', 'heat', 'heat', 'heat', 'defrost', 'defrost', 'defrost', 'heat', 'heat', 'heat', 'off', 'heat']],
  ['regression: scenario 4',
   [3,
    4,
    [[True, 20, 50],
     [True, 20, 35],
     [True, 20, 60],
     [True, 20, 50],
     [False, 20, 50],
     [True, 20, 35],
     [True, 20, 60],
     [True, 20, 51],
     [False, 20, 20],
     [True, 50, 50],
     [True, 50, 50],
     [False, 50, 50],
     [True, 50, 35],
     [False, 33, 60],
     [True, 33, 60],
     [True, 33, 50],
     [True, 20, 35],
     [True, 20, 35],
     [True, 20, 50],
     [True, 50, 20]]],
   ['heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'off',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost']]],
 [['regression: scenario 1',
   [3,
    3,
    [[True, 28, 20],
     [True, 28, 50],
     [True, 32, 50],
     [False, 32, 35],
     [True, 60, 20],
     [True, 60, 35],
     [True, 60, 50],
     [True, 60, 50],
     [True, 57, 50],
     [True, 57, 50],
     [True, 60, 60],
     [False, 60, 50],
     [True, 60, 35],
     [True, 33, 50]]],
   ['heat',
    'heat',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat']],
  ['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 2',
   [4,
    4,
    [[True, 40, 50],
     [True, 40, 35],
     [True, 40, 60],
     [False, 56, 60],
     [True, 56, 35],
     [True, 50, 50],
     [True, 32, 35],
     [True, 32, 51],
     [True, 32, 20],
     [True, 32, 51],
     [True, 32, 60],
     [True, 57, 35],
     [True, 32, 50],
     [True, 32, 35],
     [True, 20, 35],
     [True, 50, 35],
     [True, 57, 35],
     [True, 57, 51],
     [False, 57, 50]]],
   ['heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'off']],
  ['regression: scenario 3',
   [3,
    6,
    [[False, 56, 51],
     [True, 56, 35],
     [False, 56, 35],
     [True, 56, 35],
     [True, 56, 35],
     [True, 33, 50],
     [True, 33, 20],
     [True, 33, 50],
     [False, 33, 60],
     [True, 33, 35],
     [True, 33, 35],
     [True, 33, 50],
     [True, 33, 60],
     [True, 33, 35],
     [True, 33, 35],
     [True, 20, 50],
     [True, 20, 51]]],
   ['off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 4',
   [4,
    4,
    [[False, 40, 50],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 50],
     [True, 40, 50],
     [True, 28, 50],
     [True, 28, 50],
     [False, 28, 60],
     [False, 28, 20],
     [True, 28, 60],
     [True, 28, 50],
     [False, 28, 60],
     [True, 28, 50],
     [True, 28, 35],
     [False, 28, 50],
     [True, 28, 20],
     [True, 28, 51],
     [True, 33, 20]]],
   ['off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'off',
    'heat',
    'heat',
    'heat']]],
 [['regression: scenario 2',
   [4,
    3,
    [[True, 32, 20],
     [True, 57, 60],
     [True, 57, 60],
     [True, 57, 20],
     [False, 40, 51],
     [True, 50, 50],
     [True, 50, 51],
     [True, 50, 50],
     [True, 56, 60],
     [True, 40, 20],
     [False, 40, 35],
     [True, 50, 35],
     [False, 50, 51],
     [False, 50, 35],
     [True, 57, 35],
     [True, 57, 20],
     [True, 57, 20],
     [True, 57, 50],
     [True, 57, 60]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 3',
   [3,
    6,
    [[True, 20, 60],
     [True, 33, 20],
     [True, 33, 60],
     [True, 33, 51],
     [True, 33, 35],
     [True, 32, 50],
     [True, 32, 35],
     [True, 32, 35],
     [True, 32, 60],
     [True, 32, 60],
     [False, 32, 60],
     [True, 32, 35],
     [False, 32, 50],
     [True, 40, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'off',
    'heat']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 1',
   [4,
    6,
    [[True, 33, 20],
     [True, 28, 50],
     [True, 56, 51],
     [True, 33, 51],
     [True, 28, 35],
     [False, 28, 50],
     [True, 28, 60],
     [True, 28, 20],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 51],
     [True, 40, 50],
     [True, 28, 60],
     [True, 28, 50],
     [True, 50, 35],
     [True, 60, 50],
     [True, 57, 20],
     [True, 40, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 4',
   [3,
    3,
    [[True, 28, 51],
     [True, 28, 35],
     [True, 56, 50],
     [False, 56, 51],
     [True, 56, 50],
     [True, 56, 20],
     [False, 40, 50],
     [True, 40, 20],
     [False, 60, 20],
     [True, 50, 50],
     [True, 56, 35],
     [True, 56, 35],
     [True, 56, 51],
     [True, 32, 60],
     [True, 32, 60],
     [True, 32, 35],
     [True, 32, 60],
     [True, 32, 20],
     [True, 32, 50],
     [True, 32, 60],
     [True, 32, 51],
     [True, 40, 20],
     [True, 40, 20],
     [True, 40, 20]]],
   ['heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']]],
 [['regression: scenario 4',
   [4,
    6,
    [[True, 28, 50],
     [True, 28, 35],
     [True, 28, 50],
     [True, 50, 35],
     [True, 40, 50],
     [True, 40, 51],
     [False, 40, 35],
     [True, 20, 50],
     [True, 20, 35],
     [True, 28, 50],
     [True, 32, 51],
     [True, 32, 51],
     [True, 28, 51],
     [False, 28, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'off']],
  ['regression: scenario 13',
   [4,
    4,
    [[True, 20, 51],
     [True, 20, 50],
     [True, 32, 20],
     [True, 56, 35],
     [True, 56, 50],
     [True, 56, 51],
     [True, 56, 50],
     [True, 56, 20],
     [True, 32, 20],
     [True, 32, 51],
     [True, 32, 60],
     [True, 33, 51],
     [True, 28, 60],
     [True, 28, 50],
     [True, 28, 50],
     [True, 28, 51],
     [True, 28, 50],
     [True, 28, 51]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 1',
   [5,
    4,
    [[True, 57, 60],
     [True, 57, 50],
     [True, 57, 50],
     [True, 57, 35],
     [True, 33, 50],
     [True, 33, 50],
     [True, 32, 50],
     [True, 50, 51],
     [True, 50, 51],
     [False, 50, 20],
     [False, 33, 50],
     [True, 56, 20],
     [True, 32, 60],
     [True, 32, 35],
     [True, 32, 20]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 2',
   [4,
    6,
    [[False, 28, 50],
     [True, 28, 51],
     [True, 28, 35],
     [True, 28, 50],
     [True, 57, 50],
     [True, 57, 20],
     [True, 57, 50],
     [True, 57, 50],
     [True, 56, 50],
     [True, 56, 35],
     [True, 56, 51],
     [True, 56, 50]]],
   ['off', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat']]],
 [['regression: scenario 4',
   [5,
    4,
    [[True, 28, 50],
     [True, 28, 35],
     [True, 28, 50],
     [True, 57, 51],
     [True, 57, 50],
     [True, 57, 20],
     [True, 57, 35],
     [True, 57, 20],
     [True, 57, 35],
     [True, 56, 20],
     [False, 56, 20],
     [True, 33, 35],
     [True, 33, 60],
     [True, 33, 50],
     [True, 20, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 6',
   [4,
    4,
    [[True, 40, 51],
     [True, 40, 20],
     [False, 40, 35],
     [True, 28, 51],
     [True, 28, 20],
     [True, 28, 60],
     [False, 28, 51],
     [False, 28, 51],
     [False, 32, 60],
     [True, 32, 35],
     [True, 20, 51],
     [True, 20, 35],
     [True, 20, 50],
     [True, 20, 20],
     [False, 20, 35]]],
   ['heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'off']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 1',
   [4,
    6,
    [[True, 32, 50],
     [True, 50, 50],
     [True, 50, 35],
     [True, 57, 51],
     [True, 57, 20],
     [False, 57, 51],
     [True, 57, 50],
     [True, 57, 51],
     [True, 32, 50],
     [True, 32, 51],
     [True, 32, 50],
     [False, 28, 50]]],
   ['heat', 'heat', 'heat', 'heat', 'heat', 'off', 'heat', 'heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['regression: scenario 2',
   [3,
    4,
    [[True, 32, 35],
     [True, 32, 35],
     [True, 33, 60],
     [True, 33, 50],
     [True, 33, 60],
     [True, 57, 51],
     [True, 20, 60],
     [True, 20, 50],
     [True, 33, 50],
     [False, 33, 51],
     [False, 33, 20],
     [True, 33, 20],
     [True, 40, 50],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 35],
     [True, 40, 51],
     [True, 28, 35],
     [True, 28, 51],
     [True, 33, 60],
     [False, 33, 60],
     [True, 56, 51],
     [True, 56, 60],
     [False, 56, 60]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'off']]]]
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(interval, max_minutes, samples):
    acc = 0
    defrost_min = None
    out = []
    for running, coil, outdoor in samples:
        if defrost_min is not None:
            defrost_min += 1
            if coil >= 57 or defrost_min >= max_minutes:
                defrost_min = None
                out.append('heat' if running else 'off')
            else:
                out.append('defrost')
            continue
        if running and coil < 32:
            acc += 1
        if acc >= interval and outdoor <= 50:
            acc = 0
            defrost_min = 0
            out.append('defrost')
            continue
        out.append('heat' if running else 'off')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 1',
   [3,
    3,
    [[True, 40, 35],
     [True, 40, 50],
     [True, 40, 51],
     [True, 40, 51],
     [True, 40, 50],
     [True, 40, 50],
     [False, 20, 35],
     [False, 20, 51],
     [True, 20, 50],
     [True, 50, 20],
     [True, 50, 50],
     [True, 56, 50],
     [True, 40, 50],
     [True, 40, 50],
     [False, 40, 51],
     [True, 40, 50],
     [False, 20, 51],
     [False, 20, 60],
     [True, 57, 51],
     [False, 57, 51]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'off']],
  ['regression: scenario 2',
   [4,
    3,
    [[True, 33, 60],
     [False, 57, 20],
     [True, 57, 50],
     [True, 60, 20],
     [True, 60, 35],
     [True, 60, 50],
     [True, 28, 50],
     [True, 28, 20],
     [True, 28, 20],
     [False, 28, 50],
     [True, 28, 51],
     [True, 28, 35],
     [True, 28, 60],
     [True, 28, 50],
     [True, 40, 50],
     [True, 40, 50],
     [False, 40, 60]]],
   ['heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'off']],
  ['control: scenario 3',
   [5,
    3,
    [[True, 20, 20],
     [True, 20, 50],
     [True, 20, 50],
     [True, 20, 50],
     [True, 20, 35],
     [True, 40, 50],
     [False, 40, 20],
     [True, 40, 50],
     [True, 40, 50],
     [True, 33, 60],
     [False, 33, 60],
     [True, 60, 50]]],
   ['heat', 'heat', 'heat', 'heat', 'defrost', 'defrost', 'defrost', 'heat', 'heat', 'heat', 'off', 'heat']],
  ['regression: scenario 4',
   [3,
    4,
    [[True, 20, 50],
     [True, 20, 35],
     [True, 20, 60],
     [True, 20, 50],
     [False, 20, 50],
     [True, 20, 35],
     [True, 20, 60],
     [True, 20, 51],
     [False, 20, 20],
     [True, 50, 50],
     [True, 50, 50],
     [False, 50, 50],
     [True, 50, 35],
     [False, 33, 60],
     [True, 33, 60],
     [True, 33, 50],
     [True, 20, 35],
     [True, 20, 35],
     [True, 20, 50],
     [True, 50, 20]]],
   ['heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'off',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost']]],
 [['regression: scenario 1',
   [3,
    3,
    [[True, 28, 20],
     [True, 28, 50],
     [True, 32, 50],
     [False, 32, 35],
     [True, 60, 20],
     [True, 60, 35],
     [True, 60, 50],
     [True, 60, 50],
     [True, 57, 50],
     [True, 57, 50],
     [True, 60, 60],
     [False, 60, 50],
     [True, 60, 35],
     [True, 33, 50]]],
   ['heat',
    'heat',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat']],
  ['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 2',
   [4,
    4,
    [[True, 40, 50],
     [True, 40, 35],
     [True, 40, 60],
     [False, 56, 60],
     [True, 56, 35],
     [True, 50, 50],
     [True, 32, 35],
     [True, 32, 51],
     [True, 32, 20],
     [True, 32, 51],
     [True, 32, 60],
     [True, 57, 35],
     [True, 32, 50],
     [True, 32, 35],
     [True, 20, 35],
     [True, 50, 35],
     [True, 57, 35],
     [True, 57, 51],
     [False, 57, 50]]],
   ['heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'off']],
  ['regression: scenario 3',
   [3,
    6,
    [[False, 56, 51],
     [True, 56, 35],
     [False, 56, 35],
     [True, 56, 35],
     [True, 56, 35],
     [True, 33, 50],
     [True, 33, 20],
     [True, 33, 50],
     [False, 33, 60],
     [True, 33, 35],
     [True, 33, 35],
     [True, 33, 50],
     [True, 33, 60],
     [True, 33, 35],
     [True, 33, 35],
     [True, 20, 50],
     [True, 20, 51]]],
   ['off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 4',
   [4,
    4,
    [[False, 40, 50],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 50],
     [True, 40, 50],
     [True, 28, 50],
     [True, 28, 50],
     [False, 28, 60],
     [False, 28, 20],
     [True, 28, 60],
     [True, 28, 50],
     [False, 28, 60],
     [True, 28, 50],
     [True, 28, 35],
     [False, 28, 50],
     [True, 28, 20],
     [True, 28, 51],
     [True, 33, 20]]],
   ['off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'off',
    'heat',
    'heat',
    'heat']]],
 [['regression: scenario 2',
   [4,
    3,
    [[True, 32, 20],
     [True, 57, 60],
     [True, 57, 60],
     [True, 57, 20],
     [False, 40, 51],
     [True, 50, 50],
     [True, 50, 51],
     [True, 50, 50],
     [True, 56, 60],
     [True, 40, 20],
     [False, 40, 35],
     [True, 50, 35],
     [False, 50, 51],
     [False, 50, 35],
     [True, 57, 35],
     [True, 57, 20],
     [True, 57, 20],
     [True, 57, 50],
     [True, 57, 60]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 3',
   [3,
    6,
    [[True, 20, 60],
     [True, 33, 20],
     [True, 33, 60],
     [True, 33, 51],
     [True, 33, 35],
     [True, 32, 50],
     [True, 32, 35],
     [True, 32, 35],
     [True, 32, 60],
     [True, 32, 60],
     [False, 32, 60],
     [True, 32, 35],
     [False, 32, 50],
     [True, 40, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'off',
    'heat']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 1',
   [4,
    6,
    [[True, 33, 20],
     [True, 28, 50],
     [True, 56, 51],
     [True, 33, 51],
     [True, 28, 35],
     [False, 28, 50],
     [True, 28, 60],
     [True, 28, 20],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 51],
     [True, 40, 50],
     [True, 28, 60],
     [True, 28, 50],
     [True, 50, 35],
     [True, 60, 50],
     [True, 57, 20],
     [True, 40, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 4',
   [3,
    3,
    [[True, 28, 51],
     [True, 28, 35],
     [True, 56, 50],
     [False, 56, 51],
     [True, 56, 50],
     [True, 56, 20],
     [False, 40, 50],
     [True, 40, 20],
     [False, 60, 20],
     [True, 50, 50],
     [True, 56, 35],
     [True, 56, 35],
     [True, 56, 51],
     [True, 32, 60],
     [True, 32, 60],
     [True, 32, 35],
     [True, 32, 60],
     [True, 32, 20],
     [True, 32, 50],
     [True, 32, 60],
     [True, 32, 51],
     [True, 40, 20],
     [True, 40, 20],
     [True, 40, 20]]],
   ['heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']]],
 [['regression: scenario 4',
   [4,
    6,
    [[True, 28, 50],
     [True, 28, 35],
     [True, 28, 50],
     [True, 50, 35],
     [True, 40, 50],
     [True, 40, 51],
     [False, 40, 35],
     [True, 20, 50],
     [True, 20, 35],
     [True, 28, 50],
     [True, 32, 51],
     [True, 32, 51],
     [True, 28, 51],
     [False, 28, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'off']],
  ['regression: scenario 13',
   [4,
    4,
    [[True, 20, 51],
     [True, 20, 50],
     [True, 32, 20],
     [True, 56, 35],
     [True, 56, 50],
     [True, 56, 51],
     [True, 56, 50],
     [True, 56, 20],
     [True, 32, 20],
     [True, 32, 51],
     [True, 32, 60],
     [True, 33, 51],
     [True, 28, 60],
     [True, 28, 50],
     [True, 28, 50],
     [True, 28, 51],
     [True, 28, 50],
     [True, 28, 51]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 1',
   [5,
    4,
    [[True, 57, 60],
     [True, 57, 50],
     [True, 57, 50],
     [True, 57, 35],
     [True, 33, 50],
     [True, 33, 50],
     [True, 32, 50],
     [True, 50, 51],
     [True, 50, 51],
     [False, 50, 20],
     [False, 33, 50],
     [True, 56, 20],
     [True, 32, 60],
     [True, 32, 35],
     [True, 32, 20]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 2',
   [4,
    6,
    [[False, 28, 50],
     [True, 28, 51],
     [True, 28, 35],
     [True, 28, 50],
     [True, 57, 50],
     [True, 57, 20],
     [True, 57, 50],
     [True, 57, 50],
     [True, 56, 50],
     [True, 56, 35],
     [True, 56, 51],
     [True, 56, 50]]],
   ['off', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat']]],
 [['regression: scenario 4',
   [5,
    4,
    [[True, 28, 50],
     [True, 28, 35],
     [True, 28, 50],
     [True, 57, 51],
     [True, 57, 50],
     [True, 57, 20],
     [True, 57, 35],
     [True, 57, 20],
     [True, 57, 35],
     [True, 56, 20],
     [False, 56, 20],
     [True, 33, 35],
     [True, 33, 60],
     [True, 33, 50],
     [True, 20, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['regression: scenario 6',
   [4,
    4,
    [[True, 40, 51],
     [True, 40, 20],
     [False, 40, 35],
     [True, 28, 51],
     [True, 28, 20],
     [True, 28, 60],
     [False, 28, 51],
     [False, 28, 51],
     [False, 32, 60],
     [True, 32, 35],
     [True, 20, 51],
     [True, 20, 35],
     [True, 20, 50],
     [True, 20, 20],
     [False, 20, 35]]],
   ['heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'off']],
  ['regression: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['regression: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['regression: scenario 1',
   [4,
    6,
    [[True, 32, 50],
     [True, 50, 50],
     [True, 50, 35],
     [True, 57, 51],
     [True, 57, 20],
     [False, 57, 51],
     [True, 57, 50],
     [True, 57, 51],
     [True, 32, 50],
     [True, 32, 51],
     [True, 32, 50],
     [False, 28, 50]]],
   ['heat', 'heat', 'heat', 'heat', 'heat', 'off', 'heat', 'heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['regression: scenario 2',
   [3,
    4,
    [[True, 32, 35],
     [True, 32, 35],
     [True, 33, 60],
     [True, 33, 50],
     [True, 33, 60],
     [True, 57, 51],
     [True, 20, 60],
     [True, 20, 50],
     [True, 33, 50],
     [False, 33, 51],
     [False, 33, 20],
     [True, 33, 20],
     [True, 40, 50],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 35],
     [True, 40, 51],
     [True, 28, 35],
     [True, 28, 51],
     [True, 33, 60],
     [False, 33, 60],
     [True, 56, 51],
     [True, 56, 60],
     [False, 56, 60]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'off']]]]
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 unit defrosts on schedule in dry mild weather even though the coil never got cold enough to frost.

Heat pump time-temperature defrost sampled per minute (degrees F); samples are [compressor_running, coil_temp, outdoor_temp]. Compressor run minutes accumulate only while coil <= 32. When the accumulation reaches interval and outdoor <= 50, defrost starts that minute and the accumulation resets; otherwise the accumulation keeps growing. Defrost ends on the first later minute with coil >= 57 or when it has lasted max_minutes minutes; that minute reports normal operation. Return heat, off or defrost per minute.

split: open-access


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

N = 1
observations = []
def solve(interval, max_minutes, samples):
    acc = 0
    defrost_min = None
    out = []
    for running, coil, outdoor in samples:
        if defrost_min is not None:
            defrost_min += 1
            if coil >= 57 or defrost_min >= max_minutes:
                defrost_min = None
                out.append('heat' if running else 'off')
            else:
                out.append('defrost')
            continue
        if running and coil <= 32:
            acc += 1
        if acc >= interval:
            acc = 0
            defrost_min = 0
            out.append('defrost')
            continue
        out.append('heat' if running else 'off')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['regression: scenario 2',
   [4,
    3,
    [[True, 33, 60],
     [False, 57, 20],
     [True, 57, 50],
     [True, 60, 20],
     [True, 60, 35],
     [True, 60, 50],
     [True, 28, 50],
     [True, 28, 20],
     [True, 28, 20],
     [False, 28, 50],
     [True, 28, 51],
     [True, 28, 35],
     [True, 28, 60],
     [True, 28, 50],
     [True, 40, 50],
     [True, 40, 50],
     [False, 40, 60]]],
   ['heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'off']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [3,
    3,
    [[True, 40, 35],
     [True, 40, 50],
     [True, 40, 51],
     [True, 40, 51],
     [True, 40, 50],
     [True, 40, 50],
     [False, 20, 35],
     [False, 20, 51],
     [True, 20, 50],
     [True, 50, 20],
     [True, 50, 50],
     [True, 56, 50],
     [True, 40, 50],
     [True, 40, 50],
     [False, 40, 51],
     [True, 40, 50],
     [False, 20, 51],
     [False, 20, 60],
     [True, 57, 51],
     [False, 57, 51]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'off']],
  ['control: scenario 3',
   [5,
    3,
    [[True, 20, 20],
     [True, 20, 50],
     [True, 20, 50],
     [True, 20, 50],
     [True, 20, 35],
     [True, 40, 50],
     [False, 40, 20],
     [True, 40, 50],
     [True, 40, 50],
     [True, 33, 60],
     [False, 33, 60],
     [True, 60, 50]]],
   ['heat', 'heat', 'heat', 'heat', 'defrost', 'defrost', 'defrost', 'heat', 'heat', 'heat', 'off', 'heat']],
  ['regression: scenario 4',
   [3,
    4,
    [[True, 20, 50],
     [True, 20, 35],
     [True, 20, 60],
     [True, 20, 50],
     [False, 20, 50],
     [True, 20, 35],
     [True, 20, 60],
     [True, 20, 51],
     [False, 20, 20],
     [True, 50, 50],
     [True, 50, 50],
     [False, 50, 50],
     [True, 50, 35],
     [False, 33, 60],
     [True, 33, 60],
     [True, 33, 50],
     [True, 20, 35],
     [True, 20, 35],
     [True, 20, 50],
     [True, 50, 20]]],
   ['heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'off',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost']]],
 [['regression: scenario 2',
   [4,
    4,
    [[True, 40, 50],
     [True, 40, 35],
     [True, 40, 60],
     [False, 56, 60],
     [True, 56, 35],
     [True, 50, 50],
     [True, 32, 35],
     [True, 32, 51],
     [True, 32, 20],
     [True, 32, 51],
     [True, 32, 60],
     [True, 57, 35],
     [True, 32, 50],
     [True, 32, 35],
     [True, 20, 35],
     [True, 50, 35],
     [True, 57, 35],
     [True, 57, 51],
     [False, 57, 50]]],
   ['heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'off']],
  ['regression: scenario 7',
   [4,
    3,
    [[False, 32, 20],
     [True, 20, 51],
     [True, 56, 35],
     [False, 56, 50],
     [True, 56, 20],
     [True, 56, 50],
     [True, 56, 51],
     [False, 32, 60],
     [True, 32, 50],
     [True, 32, 20],
     [True, 56, 20],
     [False, 57, 20],
     [True, 57, 35],
     [True, 57, 35],
     [True, 57, 35],
     [True, 57, 35],
     [True, 28, 51],
     [False, 28, 20],
     [True, 28, 51],
     [True, 28, 50],
     [True, 40, 20]]],
   ['off',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [3,
    3,
    [[True, 28, 20],
     [True, 28, 50],
     [True, 32, 50],
     [False, 32, 35],
     [True, 60, 20],
     [True, 60, 35],
     [True, 60, 50],
     [True, 60, 50],
     [True, 57, 50],
     [True, 57, 50],
     [True, 60, 60],
     [False, 60, 50],
     [True, 60, 35],
     [True, 33, 50]]],
   ['heat',
    'heat',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat']],
  ['control: scenario 3',
   [3,
    6,
    [[False, 56, 51],
     [True, 56, 35],
     [False, 56, 35],
     [True, 56, 35],
     [True, 56, 35],
     [True, 33, 50],
     [True, 33, 20],
     [True, 33, 50],
     [False, 33, 60],
     [True, 33, 35],
     [True, 33, 35],
     [True, 33, 50],
     [True, 33, 60],
     [True, 33, 35],
     [True, 33, 35],
     [True, 20, 50],
     [True, 20, 51]]],
   ['off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']]],
 [['regression: scenario 15',
   [3,
    6,
    [[False, 28, 60],
     [True, 28, 60],
     [True, 28, 51],
     [True, 50, 20],
     [True, 50, 60],
     [False, 60, 60],
     [True, 60, 20],
     [True, 28, 60],
     [True, 28, 20],
     [True, 28, 35],
     [True, 28, 35],
     [True, 28, 51],
     [True, 28, 20],
     [False, 28, 20],
     [True, 28, 50],
     [False, 28, 35],
     [True, 28, 50],
     [True, 28, 50],
     [False, 33, 50],
     [False, 56, 20],
     [True, 56, 35]]],
   ['off',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'off',
    'heat',
    'heat',
    'off',
    'off',
    'heat']],
  ['regression: scenario 20',
   [3,
    6,
    [[True, 28, 20],
     [True, 50, 35],
     [True, 50, 35],
     [False, 50, 50],
     [True, 60, 20],
     [True, 60, 50],
     [True, 60, 50],
     [False, 60, 60],
     [True, 20, 20],
     [True, 20, 60],
     [False, 20, 20],
     [False, 20, 35],
     [True, 50, 60]]],
   ['heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [4,
    6,
    [[True, 33, 20],
     [True, 28, 50],
     [True, 56, 51],
     [True, 33, 51],
     [True, 28, 35],
     [False, 28, 50],
     [True, 28, 60],
     [True, 28, 20],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 51],
     [True, 40, 50],
     [True, 28, 60],
     [True, 28, 50],
     [True, 50, 35],
     [True, 60, 50],
     [True, 57, 20],
     [True, 40, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['control: scenario 2',
   [4,
    3,
    [[True, 32, 20],
     [True, 57, 60],
     [True, 57, 60],
     [True, 57, 20],
     [False, 40, 51],
     [True, 50, 50],
     [True, 50, 51],
     [True, 50, 50],
     [True, 56, 60],
     [True, 40, 20],
     [False, 40, 35],
     [True, 50, 35],
     [False, 50, 51],
     [False, 50, 35],
     [True, 57, 35],
     [True, 57, 20],
     [True, 57, 20],
     [True, 57, 50],
     [True, 57, 60]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']]],
 [['regression: scenario 22',
   [5,
    4,
    [[True, 28, 20],
     [True, 28, 20],
     [True, 28, 50],
     [True, 28, 60],
     [True, 28, 51],
     [True, 28, 50],
     [True, 28, 20],
     [True, 28, 50],
     [False, 57, 35],
     [True, 50, 20],
     [True, 50, 50],
     [True, 28, 50],
     [False, 28, 35],
     [True, 20, 50],
     [False, 20, 20],
     [True, 20, 50],
     [True, 40, 20],
     [True, 33, 35],
     [True, 33, 51],
     [False, 33, 20]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'off']],
  ['regression: scenario 31',
   [3,
    3,
    [[True, 50, 50],
     [True, 50, 50],
     [True, 40, 35],
     [True, 40, 60],
     [True, 20, 20],
     [True, 20, 50],
     [True, 20, 60],
     [True, 20, 50],
     [True, 20, 51],
     [True, 32, 50],
     [True, 32, 50],
     [True, 32, 35],
     [True, 50, 50],
     [False, 28, 20],
     [True, 50, 35],
     [False, 57, 51],
     [False, 57, 35],
     [True, 57, 35],
     [True, 57, 50],
     [True, 60, 50],
     [False, 60, 50],
     [True, 60, 50],
     [True, 57, 51],
     [True, 57, 35]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [5,
    4,
    [[True, 57, 60],
     [True, 57, 50],
     [True, 57, 50],
     [True, 57, 35],
     [True, 33, 50],
     [True, 33, 50],
     [True, 32, 50],
     [True, 50, 51],
     [True, 50, 51],
     [False, 50, 20],
     [False, 33, 50],
     [True, 56, 20],
     [True, 32, 60],
     [True, 32, 35],
     [True, 32, 20]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['control: scenario 2',
   [4,
    6,
    [[False, 28, 50],
     [True, 28, 51],
     [True, 28, 35],
     [True, 28, 50],
     [True, 57, 50],
     [True, 57, 20],
     [True, 57, 50],
     [True, 57, 50],
     [True, 56, 50],
     [True, 56, 35],
     [True, 56, 51],
     [True, 56, 50]]],
   ['off', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat']]],
 [['regression: scenario 13',
   [3,
    6,
    [[True, 28, 50],
     [True, 28, 51],
     [True, 56, 35],
     [True, 20, 60],
     [True, 28, 60],
     [True, 28, 51],
     [True, 57, 50],
     [True, 40, 50],
     [False, 28, 35],
     [True, 28, 50],
     [True, 28, 60],
     [True, 28, 50],
     [False, 28, 60],
     [True, 28, 20],
     [False, 28, 20],
     [True, 20, 60],
     [True, 20, 35]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'off',
    'heat',
    'off',
    'heat',
    'defrost']],
  ['regression: scenario 17',
   [5,
    4,
    [[True, 32, 20],
     [True, 32, 35],
     [True, 32, 60],
     [True, 32, 51],
     [True, 50, 35],
     [True, 50, 60],
     [True, 50, 50],
     [True, 50, 35],
     [False, 50, 35],
     [True, 40, 51],
     [True, 40, 50],
     [True, 40, 51],
     [True, 40, 51],
     [True, 50, 50],
     [False, 57, 50],
     [True, 32, 51],
     [True, 20, 50],
     [True, 56, 20],
     [True, 56, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [4,
    6,
    [[True, 32, 50],
     [True, 50, 50],
     [True, 50, 35],
     [True, 57, 51],
     [True, 57, 20],
     [False, 57, 51],
     [True, 57, 50],
     [True, 57, 51],
     [True, 32, 50],
     [True, 32, 51],
     [True, 32, 50],
     [False, 28, 50]]],
   ['heat', 'heat', 'heat', 'heat', 'heat', 'off', 'heat', 'heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['regression: scenario 2',
   [3,
    4,
    [[True, 32, 35],
     [True, 32, 35],
     [True, 33, 60],
     [True, 33, 50],
     [True, 33, 60],
     [True, 57, 51],
     [True, 20, 60],
     [True, 20, 50],
     [True, 33, 50],
     [False, 33, 51],
     [False, 33, 20],
     [True, 33, 20],
     [True, 40, 50],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 35],
     [True, 40, 51],
     [True, 28, 35],
     [True, 28, 51],
     [True, 33, 60],
     [False, 33, 60],
     [True, 56, 51],
     [True, 56, 60],
     [False, 56, 60]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'off']]]]
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(interval, max_minutes, samples):
    acc = 0
    defrost_min = None
    out = []
    for running, coil, outdoor in samples:
        if defrost_min is not None:
            defrost_min += 1
            if coil >= 57 or defrost_min >= max_minutes:
                defrost_min = None
                out.append('heat' if running else 'off')
            else:
                out.append('defrost')
            continue
        if running and coil <= 32:
            acc += 1
        if acc >= interval and coil <= 50:
            acc = 0
            defrost_min = 0
            out.append('defrost')
            continue
        out.append('heat' if running else 'off')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['regression: scenario 2',
   [4,
    3,
    [[True, 33, 60],
     [False, 57, 20],
     [True, 57, 50],
     [True, 60, 20],
     [True, 60, 35],
     [True, 60, 50],
     [True, 28, 50],
     [True, 28, 20],
     [True, 28, 20],
     [False, 28, 50],
     [True, 28, 51],
     [True, 28, 35],
     [True, 28, 60],
     [True, 28, 50],
     [True, 40, 50],
     [True, 40, 50],
     [False, 40, 60]]],
   ['heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'off']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [3,
    3,
    [[True, 40, 35],
     [True, 40, 50],
     [True, 40, 51],
     [True, 40, 51],
     [True, 40, 50],
     [True, 40, 50],
     [False, 20, 35],
     [False, 20, 51],
     [True, 20, 50],
     [True, 50, 20],
     [True, 50, 50],
     [True, 56, 50],
     [True, 40, 50],
     [True, 40, 50],
     [False, 40, 51],
     [True, 40, 50],
     [False, 20, 51],
     [False, 20, 60],
     [True, 57, 51],
     [False, 57, 51]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'off']],
  ['control: scenario 3',
   [5,
    3,
    [[True, 20, 20],
     [True, 20, 50],
     [True, 20, 50],
     [True, 20, 50],
     [True, 20, 35],
     [True, 40, 50],
     [False, 40, 20],
     [True, 40, 50],
     [True, 40, 50],
     [True, 33, 60],
     [False, 33, 60],
     [True, 60, 50]]],
   ['heat', 'heat', 'heat', 'heat', 'defrost', 'defrost', 'defrost', 'heat', 'heat', 'heat', 'off', 'heat']],
  ['regression: scenario 4',
   [3,
    4,
    [[True, 20, 50],
     [True, 20, 35],
     [True, 20, 60],
     [True, 20, 50],
     [False, 20, 50],
     [True, 20, 35],
     [True, 20, 60],
     [True, 20, 51],
     [False, 20, 20],
     [True, 50, 50],
     [True, 50, 50],
     [False, 50, 50],
     [True, 50, 35],
     [False, 33, 60],
     [True, 33, 60],
     [True, 33, 50],
     [True, 20, 35],
     [True, 20, 35],
     [True, 20, 50],
     [True, 50, 20]]],
   ['heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'off',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost']]],
 [['regression: scenario 2',
   [4,
    4,
    [[True, 40, 50],
     [True, 40, 35],
     [True, 40, 60],
     [False, 56, 60],
     [True, 56, 35],
     [True, 50, 50],
     [True, 32, 35],
     [True, 32, 51],
     [True, 32, 20],
     [True, 32, 51],
     [True, 32, 60],
     [True, 57, 35],
     [True, 32, 50],
     [True, 32, 35],
     [True, 20, 35],
     [True, 50, 35],
     [True, 57, 35],
     [True, 57, 51],
     [False, 57, 50]]],
   ['heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'off']],
  ['regression: scenario 7',
   [4,
    3,
    [[False, 32, 20],
     [True, 20, 51],
     [True, 56, 35],
     [False, 56, 50],
     [True, 56, 20],
     [True, 56, 50],
     [True, 56, 51],
     [False, 32, 60],
     [True, 32, 50],
     [True, 32, 20],
     [True, 56, 20],
     [False, 57, 20],
     [True, 57, 35],
     [True, 57, 35],
     [True, 57, 35],
     [True, 57, 35],
     [True, 28, 51],
     [False, 28, 20],
     [True, 28, 51],
     [True, 28, 50],
     [True, 40, 20]]],
   ['off',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [3,
    3,
    [[True, 28, 20],
     [True, 28, 50],
     [True, 32, 50],
     [False, 32, 35],
     [True, 60, 20],
     [True, 60, 35],
     [True, 60, 50],
     [True, 60, 50],
     [True, 57, 50],
     [True, 57, 50],
     [True, 60, 60],
     [False, 60, 50],
     [True, 60, 35],
     [True, 33, 50]]],
   ['heat',
    'heat',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat']],
  ['control: scenario 3',
   [3,
    6,
    [[False, 56, 51],
     [True, 56, 35],
     [False, 56, 35],
     [True, 56, 35],
     [True, 56, 35],
     [True, 33, 50],
     [True, 33, 20],
     [True, 33, 50],
     [False, 33, 60],
     [True, 33, 35],
     [True, 33, 35],
     [True, 33, 50],
     [True, 33, 60],
     [True, 33, 35],
     [True, 33, 35],
     [True, 20, 50],
     [True, 20, 51]]],
   ['off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']]],
 [['regression: scenario 15',
   [3,
    6,
    [[False, 28, 60],
     [True, 28, 60],
     [True, 28, 51],
     [True, 50, 20],
     [True, 50, 60],
     [False, 60, 60],
     [True, 60, 20],
     [True, 28, 60],
     [True, 28, 20],
     [True, 28, 35],
     [True, 28, 35],
     [True, 28, 51],
     [True, 28, 20],
     [False, 28, 20],
     [True, 28, 50],
     [False, 28, 35],
     [True, 28, 50],
     [True, 28, 50],
     [False, 33, 50],
     [False, 56, 20],
     [True, 56, 35]]],
   ['off',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'off',
    'heat',
    'heat',
    'off',
    'off',
    'heat']],
  ['regression: scenario 20',
   [3,
    6,
    [[True, 28, 20],
     [True, 50, 35],
     [True, 50, 35],
     [False, 50, 50],
     [True, 60, 20],
     [True, 60, 50],
     [True, 60, 50],
     [False, 60, 60],
     [True, 20, 20],
     [True, 20, 60],
     [False, 20, 20],
     [False, 20, 35],
     [True, 50, 60]]],
   ['heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [4,
    6,
    [[True, 33, 20],
     [True, 28, 50],
     [True, 56, 51],
     [True, 33, 51],
     [True, 28, 35],
     [False, 28, 50],
     [True, 28, 60],
     [True, 28, 20],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 51],
     [True, 40, 50],
     [True, 28, 60],
     [True, 28, 50],
     [True, 50, 35],
     [True, 60, 50],
     [True, 57, 20],
     [True, 40, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['control: scenario 2',
   [4,
    3,
    [[True, 32, 20],
     [True, 57, 60],
     [True, 57, 60],
     [True, 57, 20],
     [False, 40, 51],
     [True, 50, 50],
     [True, 50, 51],
     [True, 50, 50],
     [True, 56, 60],
     [True, 40, 20],
     [False, 40, 35],
     [True, 50, 35],
     [False, 50, 51],
     [False, 50, 35],
     [True, 57, 35],
     [True, 57, 20],
     [True, 57, 20],
     [True, 57, 50],
     [True, 57, 60]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat']]],
 [['regression: scenario 22',
   [5,
    4,
    [[True, 28, 20],
     [True, 28, 20],
     [True, 28, 50],
     [True, 28, 60],
     [True, 28, 51],
     [True, 28, 50],
     [True, 28, 20],
     [True, 28, 50],
     [False, 57, 35],
     [True, 50, 20],
     [True, 50, 50],
     [True, 28, 50],
     [False, 28, 35],
     [True, 20, 50],
     [False, 20, 20],
     [True, 20, 50],
     [True, 40, 20],
     [True, 33, 35],
     [True, 33, 51],
     [False, 33, 20]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'off']],
  ['regression: scenario 31',
   [3,
    3,
    [[True, 50, 50],
     [True, 50, 50],
     [True, 40, 35],
     [True, 40, 60],
     [True, 20, 20],
     [True, 20, 50],
     [True, 20, 60],
     [True, 20, 50],
     [True, 20, 51],
     [True, 32, 50],
     [True, 32, 50],
     [True, 32, 35],
     [True, 50, 50],
     [False, 28, 20],
     [True, 50, 35],
     [False, 57, 51],
     [False, 57, 35],
     [True, 57, 35],
     [True, 57, 50],
     [True, 60, 50],
     [False, 60, 50],
     [True, 60, 50],
     [True, 57, 51],
     [True, 57, 35]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [5,
    4,
    [[True, 57, 60],
     [True, 57, 50],
     [True, 57, 50],
     [True, 57, 35],
     [True, 33, 50],
     [True, 33, 50],
     [True, 32, 50],
     [True, 50, 51],
     [True, 50, 51],
     [False, 50, 20],
     [False, 33, 50],
     [True, 56, 20],
     [True, 32, 60],
     [True, 32, 35],
     [True, 32, 20]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'off',
    'heat',
    'heat',
    'heat',
    'heat']],
  ['control: scenario 2',
   [4,
    6,
    [[False, 28, 50],
     [True, 28, 51],
     [True, 28, 35],
     [True, 28, 50],
     [True, 57, 50],
     [True, 57, 20],
     [True, 57, 50],
     [True, 57, 50],
     [True, 56, 50],
     [True, 56, 35],
     [True, 56, 51],
     [True, 56, 50]]],
   ['off', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat', 'heat']]],
 [['regression: scenario 13',
   [3,
    6,
    [[True, 28, 50],
     [True, 28, 51],
     [True, 56, 35],
     [True, 20, 60],
     [True, 28, 60],
     [True, 28, 51],
     [True, 57, 50],
     [True, 40, 50],
     [False, 28, 35],
     [True, 28, 50],
     [True, 28, 60],
     [True, 28, 50],
     [False, 28, 60],
     [True, 28, 20],
     [False, 28, 20],
     [True, 20, 60],
     [True, 20, 35]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'off',
    'heat',
    'off',
    'heat',
    'defrost']],
  ['regression: scenario 17',
   [5,
    4,
    [[True, 32, 20],
     [True, 32, 35],
     [True, 32, 60],
     [True, 32, 51],
     [True, 50, 35],
     [True, 50, 60],
     [True, 50, 50],
     [True, 50, 35],
     [False, 50, 35],
     [True, 40, 51],
     [True, 40, 50],
     [True, 40, 51],
     [True, 40, 51],
     [True, 50, 50],
     [False, 57, 50],
     [True, 32, 51],
     [True, 20, 50],
     [True, 56, 20],
     [True, 56, 50]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'defrost',
    'defrost',
    'defrost']],
  ['control: two defrosts',
   [3,
    4,
    [[True, 30, 20],
     [True, 30, 20],
     [False, 30, 20],
     [True, 32, 20],
     [True, 40, 20],
     [True, 45, 20],
     [True, 57, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20],
     [True, 20, 20]]],
   ['heat',
    'heat',
    'off',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat']],
  ['regression: warm outdoor inhibits',
   [2, 3, [[True, 30, 55], [True, 30, 55], [True, 30, 50], [True, 60, 50], [True, 30, 50]]],
   ['heat', 'heat', 'defrost', 'heat', 'heat']],
  ['control: dry coil runtime',
   [2, 3, [[True, 40, 20], [True, 33, 20], [True, 32, 20], [True, 31, 20], [True, 50, 20]]],
   ['heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['control: exact termination temperature',
   [1, 5, [[True, 30, 20], [True, 56, 20], [True, 57, 20], [False, 30, 20], [True, 30, 20]]],
   ['defrost', 'defrost', 'heat', 'off', 'defrost']],
  ['control: scenario 1',
   [4,
    6,
    [[True, 32, 50],
     [True, 50, 50],
     [True, 50, 35],
     [True, 57, 51],
     [True, 57, 20],
     [False, 57, 51],
     [True, 57, 50],
     [True, 57, 51],
     [True, 32, 50],
     [True, 32, 51],
     [True, 32, 50],
     [False, 28, 50]]],
   ['heat', 'heat', 'heat', 'heat', 'heat', 'off', 'heat', 'heat', 'heat', 'heat', 'defrost', 'defrost']],
  ['regression: scenario 2',
   [3,
    4,
    [[True, 32, 35],
     [True, 32, 35],
     [True, 33, 60],
     [True, 33, 50],
     [True, 33, 60],
     [True, 57, 51],
     [True, 20, 60],
     [True, 20, 50],
     [True, 33, 50],
     [False, 33, 51],
     [False, 33, 20],
     [True, 33, 20],
     [True, 40, 50],
     [True, 40, 50],
     [True, 40, 35],
     [True, 40, 35],
     [True, 40, 51],
     [True, 28, 35],
     [True, 28, 51],
     [True, 33, 60],
     [False, 33, 60],
     [True, 56, 51],
     [True, 56, 60],
     [False, 56, 60]]],
   ['heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'defrost',
    'defrost',
    'defrost',
    'defrost',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'heat',
    'off',
    'heat',
    'heat',
    'off']]]]
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 heat pump runs a defrost at 55 F outdoor, dumping cold air into the house for no reason.

Heat pump time-temperature defrost sampled per minute (degrees F); samples are [compressor_running, coil_temp, outdoor_temp]. Compressor run minutes accumulate only while coil <= 32. When the accumulation reaches interval and outdoor <= 50, defrost starts that minute and the accumulation resets; otherwise the accumulation keeps growing. Defrost ends on the first later minute with coil >= 57 or when it has lasted max_minutes minutes; that minute reports normal operation. Return heat, off or defrost per minute.

split: open-access