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

N = 1
observations = []
def solve(samples):
    last = None
    out = []
    for readings in samples:
        valid = [(t, occ) for room, t, occ in readings if t is not None and 320 <= t <= 1000]
        pool = [t for t, occ in valid for _w in range(2 if occ else 1)]
        if pool:
            last = (2 * sum(pool) + len(pool)) // (2 * len(pool))
        out.append(last)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: scenario 1',
   [[[['living', 611, False], ['bed', 799, True]],
     [['living', 697, True]],
     [['living', 697, False], ['bed', 609, True]],
     [['living', 751, False], ['bed', 736, True], ['den', 616, True]],
     [['living', 1100, False], ['bed', 686, True]],
     [['living', 798, False], ['bed', 743, True], ['den', 646, False], ['office', 720, False]],
     [['living', 668, False], ['bed', None, True], ['den', None, True], ['office', 795, False]]]],
   [799, 697, 609, 676, 686, 743, 732]],
  ['regression: scenario 2',
   [[[['living', 602, False], ['bed', 665, False], ['den', 790, False], ['office', 677, False]],
     [['living', 638, False]],
     [['living', 602, False], ['bed', 750, True]],
     [['living', None, True], ['bed', 250, False], ['den', 250, True]],
     [['living', 744, True], ['bed', 711, True], ['den', 676, False], ['office', 640, True]],
     [['living', 771, False], ['bed', 646, True]],
     [['living', 608, False]],
     [['living', 663, True], ['bed', 793, True], ['den', 250, True], ['office', 743, False]]]],
   [684, 638, 750, 750, 698, 646, 608, 728]],
  ['regression: scenario 3',
   [[[['living', 677, True]],
     [['living', 624, True], ['bed', 620, True]],
     [['living', 605, True], ['bed', 250, False]],
     [['living', 764, False]],
     [['living', 612, False], ['bed', None, True], ['den', 664, True]],
     [['living', None, True], ['bed', 250, False], ['den', 250, True]],
     [['living', 745, True], ['bed', None, False]],
     [['living', 665, True]]]],
   [677, 622, 605, 764, 664, 664, 745, 665]],
  ['regression: scenario 4',
   [[[['living', 600, True]],
     [['living', 742, True], ['bed', 607, False], ['den', 638, True], ['office', 791, True]],
     [['living', 710, False], ['bed', 602, True], ['den', 716, False]],
     [['living', 607, False], ['bed', 735, True], ['den', 739, False], ['office', 723, True]],
     [['living', 621, True], ['bed', 625, False], ['den', 688, True], ['office', 627, False]],
     [['living', 677, False], ['bed', 775, True]],
     [['living', 1100, False], ['bed', None, False], ['den', 687, False]]]],
   [600, 724, 602, 729, 655, 775, 687]]],
 [['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['regression: scenario 2',
   [[[['living', 675, True], ['bed', 724, False], ['den', 793, True]],
     [['living', 711, False], ['bed', 720, False]],
     [['living', 722, False], ['bed', 1100, False], ['den', 606, False], ['office', 625, True]],
     [['living', 657, False], ['bed', 619, True], ['den', 800, True], ['office', 629, True]],
     [['living', 765, True], ['bed', 726, True]],
     [['living', 785, False], ['bed', 626, False]]]],
   [734, 716, 625, 683, 746, 706]],
  ['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: scenario 1',
   [[[['living', 631, False], ['bed', None, True]],
     [['living', 674, True], ['bed', 788, True]],
     [['living', 629, False]],
     [['living', 617, False], ['bed', 636, True], ['den', 622, True]],
     [['living', 602, True], ['bed', 659, True], ['den', 604, False]],
     [['living', 641, True], ['bed', 600, True]],
     [['living', 781, True]],
     [['living', 615, True], ['bed', 788, True], ['den', 658, True]]]],
   [631, 731, 629, 629, 631, 621, 781, 687]],
  ['regression: scenario 3',
   [[[['living', 795, False]],
     [['living', 769, False], ['bed', 675, False]],
     [['living', 640, False]],
     [['living', None, False]],
     [['living', None, False], ['bed', 790, True], ['den', 684, False], ['office', 789, True]],
     [['living', 722, True], ['bed', 750, True], ['den', 250, True]],
     [['living', 663, True], ['bed', 670, True]],
     [['living', 628, False], ['bed', 687, False], ['den', 635, False]]]],
   [795, 722, 640, 640, 790, 736, 667, 650]],
  ['regression: scenario 4',
   [[[['living', 713, False]],
     [['living', 741, True], ['bed', 652, False], ['den', 796, False], ['office', 784, False]],
     [['living', 756, True], ['bed', 687, True], ['den', 250, False], ['office', 657, False]],
     [['living', 601, True], ['bed', 743, True], ['den', 250, True]],
     [['living', 728, False]],
     [['living', 605, False], ['bed', 766, True], ['den', 601, False]],
     [['living', 748, True]],
     [['living', 1100, True], ['bed', 622, False], ['den', 714, True], ['office', 644, True]],
     [['living', 773, True]]]],
   [713, 741, 722, 672, 728, 766, 748, 679, 773]]],
 [['regression: scenario 1',
   [[[['living', 627, False], ['bed', 693, True], ['den', 769, True], ['office', 704, True]],
     [['living', 738, True], ['bed', 638, True]],
     [['living', 760, True], ['bed', 696, True], ['den', 683, False]],
     [['living', 771, False], ['bed', 1100, False]],
     [['living', 686, True]],
     [['living', 734, True]],
     [['living', None, True], ['bed', 649, False], ['den', 767, False]],
     [['living', 722, True]],
     [['living', 686, True], ['bed', 715, False], ['den', 617, False], ['office', 250, False]],
     [['living', 790, True]]]],
   [722, 688, 728, 771, 686, 734, 708, 722, 686, 790]],
  ['regression: scenario 2',
   [[[['living', 663, False], ['bed', 781, True], ['den', 775, False], ['office', 722, True]],
     [['living', 655, False]],
     [['living', 777, False], ['bed', 790, True], ['den', 637, False], ['office', 682, False]],
     [['living', 250, False], ['bed', 701, True], ['den', 745, True], ['office', 626, False]],
     [['living', 619, False]],
     [['living', 619, True], ['bed', 710, True]],
     [['living', 732, False]],
     [['living', 772, False]],
     [['living', None, True], ['bed', 664, True], ['den', 728, True], ['office', 783, False]],
     [['living', 1100, True], ['bed', 734, True], ['den', 657, False], ['office', 601, False]]]],
   [752, 655, 790, 723, 619, 665, 732, 772, 696, 734]],
  ['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['regression: scenario 3',
   [[[['living', 740, True], ['bed', None, False], ['den', 718, True], ['office', 628, True]],
     [['living', 687, True]],
     [['living', 766, True], ['bed', 604, False], ['den', 725, False], ['office', 735, False]],
     [['living', 788, False], ['bed', 698, False], ['den', 700, False], ['office', None, True]],
     [['living', None, False], ['bed', 607, True], ['den', 754, False]],
     [['living', 250, False], ['bed', 649, True], ['den', 666, False]],
     [['living', None, True], ['bed', 785, True]],
     [['living', 715, True], ['bed', 699, False], ['den', 1100, True]],
     [['living', 605, False], ['bed', 735, False]]]],
   [695, 687, 766, 729, 607, 649, 785, 715, 670]],
  ['regression: scenario 4',
   [[[['living', 647, True], ['bed', 693, False]],
     [['living', None, False], ['bed', 1100, False], ['den', None, True], ['office', None, False]],
     [['living', 791, False], ['bed', 250, False], ['den', 778, True]],
     [['living', 650, False], ['bed', None, True]],
     [['living', 1100, True], ['bed', 680, False], ['den', 250, False]],
     [['living', 700, True], ['bed', 1100, True], ['den', 712, False]],
     [['living', 662, True], ['bed', 670, True]]]],
   [647, 647, 778, 650, 680, 700, 666]]],
 [['regression: scenario 2',
   [[[['living', 675, False], ['bed', 659, True], ['den', 738, False], ['office', 1100, False]],
     [['living', 250, True], ['bed', 649, True]],
     [['living', 604, True]],
     [['living', 629, True], ['bed', None, True], ['den', 610, True]],
     [['living', 633, False], ['bed', None, True], ['den', 778, True], ['office', 795, False]],
     [['living', None, False]]]],
   [659, 649, 604, 620, 778, 778]],
  ['regression: scenario 3',
   [[[['living', 687, True], ['bed', 761, True]],
     [['living', 719, False], ['bed', None, False], ['den', 774, True]],
     [['living', 723, False]],
     [['living', 649, False]],
     [['living', 649, False], ['bed', 705, True]],
     [['living', 699, True]]]],
   [724, 774, 723, 649, 705, 699]],
  ['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['regression: scenario 1',
   [[[['living', 782, False], ['bed', 708, True], ['den', 678, True]],
     [['living', 772, False], ['bed', 795, True]],
     [['living', 744, True], ['bed', 616, True], ['den', 694, True]],
     [['living', 790, False], ['bed', 733, True]],
     [['living', 722, True], ['bed', 701, False]],
     [['living', 699, False], ['bed', 636, False]]]],
   [693, 795, 685, 733, 722, 668]],
  ['control: scenario 4',
   [[[['living', 614, False]],
     [['living', 616, True], ['bed', None, True], ['den', 783, True]],
     [['living', 250, True], ['bed', 250, True]],
     [['living', None, True]],
     [['living', 663, True]],
     [['living', 656, True], ['bed', 250, True], ['den', 679, True]],
     [['living', 799, True], ['bed', 707, True], ['den', 751, True]],
     [['living', None, True]]]],
   [614, 700, 700, 700, 663, 668, 752, 752]]],
 [['regression: scenario 5',
   [[[['living', 677, False], ['bed', 765, True], ['den', 250, True], ['office', 793, False]],
     [['living', 759, True], ['bed', 250, False], ['den', 791, False]],
     [['living', 660, True], ['bed', 621, True], ['den', 740, False], ['office', None, False]],
     [['living', 618, False], ['bed', None, True], ['den', 703, False], ['office', 747, True]],
     [['living', 699, False], ['bed', 762, True]]]],
   [765, 759, 641, 747, 762]],
  ['regression: scenario 7',
   [[[['living', 1100, True], ['bed', 748, False], ['den', 797, False], ['office', 633, True]],
     [['living', None, False], ['bed', 616, False], ['den', 717, False]],
     [['living', 674, True], ['bed', 698, True], ['den', 722, False]],
     [['living', 616, False], ['bed', 634, False]],
     [['living', 736, False], ['bed', 753, False], ['den', 787, False]]]],
   [633, 667, 686, 625, 759]],
  ['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['regression: scenario 1',
   [[[['living', 1100, True]],
     [['living', 634, False], ['bed', 740, False], ['den', None, True]],
     [['living', 1100, True]],
     [['living', 618, False], ['bed', 787, False], ['den', 754, False]],
     [['living', 673, False], ['bed', 795, True], ['den', 612, False], ['office', 721, True]]]],
   [None, 687, 687, 720, 758]],
  ['control: scenario 2',
   [[[['living', 733, True], ['bed', 629, True], ['den', 631, True], ['office', 649, True]],
     [['living', 766, True]],
     [['living', 727, False], ['bed', 610, False]],
     [['living', None, True]],
     [['living', 627, False]],
     [['living', 689, True], ['bed', 635, True], ['den', 250, False]],
     [['living', 613, False], ['bed', 717, False]],
     [['living', 1100, True]]]],
   [661, 766, 669, 669, 627, 662, 665, 665]]]]
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(samples):
    last = None
    out = []
    for readings in samples:
        valid = [(t, occ) for room, t, occ in readings if t is not None and 320 <= t <= 1000]
        occ_pool = [t for t, occ in valid if occ]
        pool = occ_pool if len(occ_pool) > 1 else [t for t, occ in valid]
        if pool:
            last = (2 * sum(pool) + len(pool)) // (2 * len(pool))
        out.append(last)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: scenario 1',
   [[[['living', 611, False], ['bed', 799, True]],
     [['living', 697, True]],
     [['living', 697, False], ['bed', 609, True]],
     [['living', 751, False], ['bed', 736, True], ['den', 616, True]],
     [['living', 1100, False], ['bed', 686, True]],
     [['living', 798, False], ['bed', 743, True], ['den', 646, False], ['office', 720, False]],
     [['living', 668, False], ['bed', None, True], ['den', None, True], ['office', 795, False]]]],
   [799, 697, 609, 676, 686, 743, 732]],
  ['regression: scenario 2',
   [[[['living', 602, False], ['bed', 665, False], ['den', 790, False], ['office', 677, False]],
     [['living', 638, False]],
     [['living', 602, False], ['bed', 750, True]],
     [['living', None, True], ['bed', 250, False], ['den', 250, True]],
     [['living', 744, True], ['bed', 711, True], ['den', 676, False], ['office', 640, True]],
     [['living', 771, False], ['bed', 646, True]],
     [['living', 608, False]],
     [['living', 663, True], ['bed', 793, True], ['den', 250, True], ['office', 743, False]]]],
   [684, 638, 750, 750, 698, 646, 608, 728]],
  ['regression: scenario 3',
   [[[['living', 677, True]],
     [['living', 624, True], ['bed', 620, True]],
     [['living', 605, True], ['bed', 250, False]],
     [['living', 764, False]],
     [['living', 612, False], ['bed', None, True], ['den', 664, True]],
     [['living', None, True], ['bed', 250, False], ['den', 250, True]],
     [['living', 745, True], ['bed', None, False]],
     [['living', 665, True]]]],
   [677, 622, 605, 764, 664, 664, 745, 665]],
  ['regression: scenario 4',
   [[[['living', 600, True]],
     [['living', 742, True], ['bed', 607, False], ['den', 638, True], ['office', 791, True]],
     [['living', 710, False], ['bed', 602, True], ['den', 716, False]],
     [['living', 607, False], ['bed', 735, True], ['den', 739, False], ['office', 723, True]],
     [['living', 621, True], ['bed', 625, False], ['den', 688, True], ['office', 627, False]],
     [['living', 677, False], ['bed', 775, True]],
     [['living', 1100, False], ['bed', None, False], ['den', 687, False]]]],
   [600, 724, 602, 729, 655, 775, 687]]],
 [['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['regression: scenario 2',
   [[[['living', 675, True], ['bed', 724, False], ['den', 793, True]],
     [['living', 711, False], ['bed', 720, False]],
     [['living', 722, False], ['bed', 1100, False], ['den', 606, False], ['office', 625, True]],
     [['living', 657, False], ['bed', 619, True], ['den', 800, True], ['office', 629, True]],
     [['living', 765, True], ['bed', 726, True]],
     [['living', 785, False], ['bed', 626, False]]]],
   [734, 716, 625, 683, 746, 706]],
  ['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: scenario 1',
   [[[['living', 631, False], ['bed', None, True]],
     [['living', 674, True], ['bed', 788, True]],
     [['living', 629, False]],
     [['living', 617, False], ['bed', 636, True], ['den', 622, True]],
     [['living', 602, True], ['bed', 659, True], ['den', 604, False]],
     [['living', 641, True], ['bed', 600, True]],
     [['living', 781, True]],
     [['living', 615, True], ['bed', 788, True], ['den', 658, True]]]],
   [631, 731, 629, 629, 631, 621, 781, 687]],
  ['regression: scenario 3',
   [[[['living', 795, False]],
     [['living', 769, False], ['bed', 675, False]],
     [['living', 640, False]],
     [['living', None, False]],
     [['living', None, False], ['bed', 790, True], ['den', 684, False], ['office', 789, True]],
     [['living', 722, True], ['bed', 750, True], ['den', 250, True]],
     [['living', 663, True], ['bed', 670, True]],
     [['living', 628, False], ['bed', 687, False], ['den', 635, False]]]],
   [795, 722, 640, 640, 790, 736, 667, 650]],
  ['regression: scenario 4',
   [[[['living', 713, False]],
     [['living', 741, True], ['bed', 652, False], ['den', 796, False], ['office', 784, False]],
     [['living', 756, True], ['bed', 687, True], ['den', 250, False], ['office', 657, False]],
     [['living', 601, True], ['bed', 743, True], ['den', 250, True]],
     [['living', 728, False]],
     [['living', 605, False], ['bed', 766, True], ['den', 601, False]],
     [['living', 748, True]],
     [['living', 1100, True], ['bed', 622, False], ['den', 714, True], ['office', 644, True]],
     [['living', 773, True]]]],
   [713, 741, 722, 672, 728, 766, 748, 679, 773]]],
 [['regression: scenario 1',
   [[[['living', 627, False], ['bed', 693, True], ['den', 769, True], ['office', 704, True]],
     [['living', 738, True], ['bed', 638, True]],
     [['living', 760, True], ['bed', 696, True], ['den', 683, False]],
     [['living', 771, False], ['bed', 1100, False]],
     [['living', 686, True]],
     [['living', 734, True]],
     [['living', None, True], ['bed', 649, False], ['den', 767, False]],
     [['living', 722, True]],
     [['living', 686, True], ['bed', 715, False], ['den', 617, False], ['office', 250, False]],
     [['living', 790, True]]]],
   [722, 688, 728, 771, 686, 734, 708, 722, 686, 790]],
  ['regression: scenario 2',
   [[[['living', 663, False], ['bed', 781, True], ['den', 775, False], ['office', 722, True]],
     [['living', 655, False]],
     [['living', 777, False], ['bed', 790, True], ['den', 637, False], ['office', 682, False]],
     [['living', 250, False], ['bed', 701, True], ['den', 745, True], ['office', 626, False]],
     [['living', 619, False]],
     [['living', 619, True], ['bed', 710, True]],
     [['living', 732, False]],
     [['living', 772, False]],
     [['living', None, True], ['bed', 664, True], ['den', 728, True], ['office', 783, False]],
     [['living', 1100, True], ['bed', 734, True], ['den', 657, False], ['office', 601, False]]]],
   [752, 655, 790, 723, 619, 665, 732, 772, 696, 734]],
  ['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['regression: scenario 3',
   [[[['living', 740, True], ['bed', None, False], ['den', 718, True], ['office', 628, True]],
     [['living', 687, True]],
     [['living', 766, True], ['bed', 604, False], ['den', 725, False], ['office', 735, False]],
     [['living', 788, False], ['bed', 698, False], ['den', 700, False], ['office', None, True]],
     [['living', None, False], ['bed', 607, True], ['den', 754, False]],
     [['living', 250, False], ['bed', 649, True], ['den', 666, False]],
     [['living', None, True], ['bed', 785, True]],
     [['living', 715, True], ['bed', 699, False], ['den', 1100, True]],
     [['living', 605, False], ['bed', 735, False]]]],
   [695, 687, 766, 729, 607, 649, 785, 715, 670]],
  ['regression: scenario 4',
   [[[['living', 647, True], ['bed', 693, False]],
     [['living', None, False], ['bed', 1100, False], ['den', None, True], ['office', None, False]],
     [['living', 791, False], ['bed', 250, False], ['den', 778, True]],
     [['living', 650, False], ['bed', None, True]],
     [['living', 1100, True], ['bed', 680, False], ['den', 250, False]],
     [['living', 700, True], ['bed', 1100, True], ['den', 712, False]],
     [['living', 662, True], ['bed', 670, True]]]],
   [647, 647, 778, 650, 680, 700, 666]]],
 [['regression: scenario 2',
   [[[['living', 675, False], ['bed', 659, True], ['den', 738, False], ['office', 1100, False]],
     [['living', 250, True], ['bed', 649, True]],
     [['living', 604, True]],
     [['living', 629, True], ['bed', None, True], ['den', 610, True]],
     [['living', 633, False], ['bed', None, True], ['den', 778, True], ['office', 795, False]],
     [['living', None, False]]]],
   [659, 649, 604, 620, 778, 778]],
  ['regression: scenario 3',
   [[[['living', 687, True], ['bed', 761, True]],
     [['living', 719, False], ['bed', None, False], ['den', 774, True]],
     [['living', 723, False]],
     [['living', 649, False]],
     [['living', 649, False], ['bed', 705, True]],
     [['living', 699, True]]]],
   [724, 774, 723, 649, 705, 699]],
  ['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['regression: scenario 1',
   [[[['living', 782, False], ['bed', 708, True], ['den', 678, True]],
     [['living', 772, False], ['bed', 795, True]],
     [['living', 744, True], ['bed', 616, True], ['den', 694, True]],
     [['living', 790, False], ['bed', 733, True]],
     [['living', 722, True], ['bed', 701, False]],
     [['living', 699, False], ['bed', 636, False]]]],
   [693, 795, 685, 733, 722, 668]],
  ['control: scenario 4',
   [[[['living', 614, False]],
     [['living', 616, True], ['bed', None, True], ['den', 783, True]],
     [['living', 250, True], ['bed', 250, True]],
     [['living', None, True]],
     [['living', 663, True]],
     [['living', 656, True], ['bed', 250, True], ['den', 679, True]],
     [['living', 799, True], ['bed', 707, True], ['den', 751, True]],
     [['living', None, True]]]],
   [614, 700, 700, 700, 663, 668, 752, 752]]],
 [['regression: scenario 5',
   [[[['living', 677, False], ['bed', 765, True], ['den', 250, True], ['office', 793, False]],
     [['living', 759, True], ['bed', 250, False], ['den', 791, False]],
     [['living', 660, True], ['bed', 621, True], ['den', 740, False], ['office', None, False]],
     [['living', 618, False], ['bed', None, True], ['den', 703, False], ['office', 747, True]],
     [['living', 699, False], ['bed', 762, True]]]],
   [765, 759, 641, 747, 762]],
  ['regression: scenario 7',
   [[[['living', 1100, True], ['bed', 748, False], ['den', 797, False], ['office', 633, True]],
     [['living', None, False], ['bed', 616, False], ['den', 717, False]],
     [['living', 674, True], ['bed', 698, True], ['den', 722, False]],
     [['living', 616, False], ['bed', 634, False]],
     [['living', 736, False], ['bed', 753, False], ['den', 787, False]]]],
   [633, 667, 686, 625, 759]],
  ['regression: occupancy and faults',
   [[[['liv', 700, True], ['bed', 680, False]],
     [['liv', None, True], ['bed', 681, False], ['den', 690, False]],
     [['liv', 1200, True]],
     [['liv', 701, True], ['bed', 702, True]]]],
   [700, 686, 686, 702]],
  ['control: shorted sensor',
   [[[['a', 700, True], ['b', 5, True]], [['a', 1300, False], ['b', 690, False]]]],
   [700, 690]],
  ['control: first sample all invalid',
   [[[['a', None, True]], [['a', 700, True]], [['a', None, False]]]],
   [None, 700, 700]],
  ['regression: single occupied room',
   [[[['a', 700, True], ['b', 650, False], ['c', 660, False]], [['a', 707, True], ['b', 704, True]]]],
   [700, 706]],
  ['regression: scenario 1',
   [[[['living', 1100, True]],
     [['living', 634, False], ['bed', 740, False], ['den', None, True]],
     [['living', 1100, True]],
     [['living', 618, False], ['bed', 787, False], ['den', 754, False]],
     [['living', 673, False], ['bed', 795, True], ['den', 612, False], ['office', 721, True]]]],
   [None, 687, 687, 720, 758]],
  ['control: scenario 2',
   [[[['living', 733, True], ['bed', 629, True], ['den', 631, True], ['office', 649, True]],
     [['living', 766, True]],
     [['living', 727, False], ['bed', 610, False]],
     [['living', None, True]],
     [['living', 627, False]],
     [['living', 689, True], ['bed', 635, True], ['den', 250, False]],
     [['living', 613, False], ['bed', 717, False]],
     [['living', 1100, True]]]],
   [661, 766, 669, 669, 627, 662, 665, 665]]]]
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:
Empty cold rooms pull the control temperature down while people are elsewhere.

Thermostat with remote room sensors; each sample is a list of [room, reading tenths F or None, occupied]. Readings outside 32.0-100.0 F or None are invalid. The control temperature is the mean of valid readings from occupied rooms, or of all valid readings if no occupied room has one, rounded half up to a tenth; if nothing is valid the previous control temperature is held (None initially). Return the control temperature per sample.

split: open-access


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

N = 1
observations = []
def solve(settings, samples):
    dm = 0
    comp = False
    aux = False
    out = []
    for supply, target in samples:
        dm = max(settings['floor'], min(100, dm + target - supply))
        if comp and dm >= settings['stop_dm']:
            comp = False
        elif not comp and dm <= settings['start_dm']:
            comp = True
        if aux and dm >= settings['start_dm']:
            aux = False
        elif not aux and dm <= settings['aux_dm']:
            aux = True
        out.append([dm, comp, aux])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[11, 40],
     [50, 40],
     [49, 40],
     [53, 40],
     [49, 40],
     [71, 40],
     [105, 40],
     [100, 40],
     [17, 40],
     [13, 40],
     [102, 40],
     [102, 40],
     [99, 40],
     [105, 40],
     [96, 40],
     [50, 40],
     [48, 40],
     [46, 40],
     [47, 40],
     [50, 40],
     [52, 40],
     [48, 40],
     [71, 40]]],
   [[-29, False, False],
    [-19, False, False],
    [-10, False, False],
    [3, False, False],
    [12, False, False],
    [43, False, False],
    [100, False, False],
    [100, False, False],
    [77, False, False],
    [50, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -250},
    [[67, 40],
     [67, 40],
     [73, 40],
     [71, 40],
     [11, 40],
     [19, 40],
     [69, 40],
     [70, 40],
     [65, 40],
     [70, 40],
     [66, 40],
     [66, 40],
     [71, 40],
     [68, 40],
     [70, 40],
     [73, 40],
     [74, 40],
     [73, 40],
     [65, 40],
     [75, 40],
     [104, 40]]],
   [[27, False, False],
    [54, False, False],
    [87, False, False],
    [100, False, False],
    [71, False, False],
    [50, False, False],
    [79, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -400},
    [[71, 40],
     [75, 40],
     [72, 40],
     [68, 40],
     [75, 40],
     [48, 40],
     [45, 40],
     [30, 40],
     [18, 40],
     [19, 40],
     [12, 40],
     [16, 40],
     [10, 40],
     [18, 40],
     [18, 40],
     [18, 40],
     [72, 40],
     [20, 40],
     [20, 40],
     [17, 40]]],
   [[31, False, False],
    [66, False, False],
    [98, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [90, False, False],
    [68, False, False],
    [47, False, False],
    [19, False, False],
    [-5, False, False],
    [-35, False, False],
    [-57, False, False],
    [-79, True, False],
    [-101, True, False],
    [-69, True, False],
    [-89, True, False],
    [-109, True, False],
    [-132, True, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[27, 40],
     [23, 40],
     [28, 40],
     [67, 40],
     [96, 40],
     [101, 40],
     [18, 40],
     [11, 40],
     [16, 40],
     [18, 40],
     [13, 40],
     [16, 40],
     [18, 40],
     [16, 40],
     [17, 40],
     [10, 40],
     [15, 40]]],
   [[-13, False, False],
    [-30, False, False],
    [-42, False, False],
    [-15, False, False],
    [41, False, False],
    [100, False, False],
    [78, False, False],
    [49, False, False],
    [25, False, False],
    [3, False, False],
    [-24, False, False],
    [-48, False, False],
    [-70, True, False],
    [-94, True, False],
    [-117, True, False],
    [-147, True, False],
    [-172, True, True]]]],
 [['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -250},
    [[57, 40],
     [101, 40],
     [100, 40],
     [98, 40],
     [95, 40],
     [100, 40],
     [101, 40],
     [103, 40],
     [96, 40],
     [97, 40],
     [14, 40],
     [17, 40],
     [12, 40],
     [20, 40],
     [13, 40]]],
   [[17, False, False],
    [78, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [74, False, False],
    [51, False, False],
    [23, False, False],
    [3, False, False],
    [-24, False, False]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[10, 40],
     [10, 40],
     [19, 40],
     [28, 40],
     [26, 40],
     [27, 40],
     [28, 40],
     [26, 40],
     [75, 40],
     [65, 40],
     [73, 40],
     [71, 40],
     [71, 40],
     [72, 40],
     [11, 40],
     [13, 40],
     [19, 40],
     [15, 40],
     [27, 40],
     [30, 40]]],
   [[-30, False, False],
    [-60, True, False],
    [-81, True, False],
    [-93, True, False],
    [-107, True, False],
    [-120, True, False],
    [-132, True, False],
    [-146, True, False],
    [-111, True, False],
    [-86, True, False],
    [-53, True, False],
    [-22, True, False],
    [9, False, False],
    [41, False, False],
    [12, False, False],
    [-15, False, False],
    [-36, False, False],
    [-61, True, False],
    [-74, True, False],
    [-84, True, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[13, 40],
     [95, 40],
     [100, 40],
     [49, 40],
     [97, 40],
     [103, 40],
     [97, 40],
     [101, 40],
     [99, 40],
     [99, 40],
     [105, 40],
     [101, 40]]],
   [[-27, False, False],
    [28, False, False],
    [88, False, False],
    [97, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[21, 40],
     [25, 40],
     [46, 40],
     [48, 40],
     [21, 40],
     [24, 40],
     [26, 40],
     [25, 40],
     [25, 40],
     [45, 40],
     [49, 40],
     [50, 40],
     [50, 40],
     [48, 40],
     [45, 40],
     [55, 40],
     [20, 40],
     [23, 40],
     [103, 40],
     [102, 40],
     [73, 40],
     [75, 40]]],
   [[-19, False, False],
    [-34, False, False],
    [-28, False, False],
    [-20, False, False],
    [-39, False, False],
    [-55, False, False],
    [-69, True, False],
    [-84, True, False],
    [-99, True, False],
    [-94, True, False],
    [-85, True, False],
    [-75, True, False],
    [-65, True, False],
    [-57, True, False],
    [-52, True, False],
    [-37, True, False],
    [-57, True, False],
    [-74, True, False],
    [-11, True, False],
    [51, False, False],
    [84, False, False],
    [100, False, False]]]],
 [['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[14, 40],
     [17, 40],
     [19, 40],
     [12, 40],
     [16, 40],
     [10, 40],
     [16, 40],
     [12, 40],
     [16, 40],
     [19, 40],
     [16, 40],
     [12, 40],
     [20, 40],
     [10, 40],
     [20, 40],
     [11, 40],
     [20, 40]]],
   [[-26, False, False],
    [-49, False, False],
    [-70, True, False],
    [-98, True, False],
    [-122, True, False],
    [-152, True, True],
    [-176, True, True],
    [-204, True, True],
    [-228, True, True],
    [-249, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[68, 40],
     [72, 40],
     [75, 40],
     [69, 40],
     [70, 40],
     [66, 40],
     [65, 40],
     [68, 40],
     [75, 40],
     [71, 40],
     [70, 40],
     [74, 40],
     [68, 40],
     [74, 40],
     [68, 40],
     [67, 40],
     [69, 40],
     [72, 40],
     [68, 40],
     [70, 40],
     [75, 40],
     [72, 40],
     [75, 40],
     [66, 40]]],
   [[28, False, False],
    [60, False, False],
    [95, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -250},
    [[67, 40],
     [23, 40],
     [22, 40],
     [25, 40],
     [49, 40],
     [10, 40],
     [100, 40],
     [95, 40],
     [103, 40],
     [100, 40],
     [104, 40],
     [14, 40],
     [50, 40],
     [48, 40],
     [51, 40],
     [48, 40],
     [46, 40],
     [53, 40],
     [52, 40],
     [47, 40],
     [52, 40]]],
   [[27, False, False],
    [10, False, False],
    [-8, False, False],
    [-23, False, False],
    [-14, False, False],
    [-44, False, False],
    [16, False, False],
    [71, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [74, False, False],
    [84, False, False],
    [92, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[57, 40],
     [54, 40],
     [54, 40],
     [50, 40],
     [55, 40],
     [52, 40],
     [53, 40],
     [50, 40],
     [59, 40],
     [50, 40],
     [51, 40],
     [57, 40],
     [73, 40],
     [67, 40],
     [15, 40],
     [71, 40],
     [65, 40],
     [74, 40]]],
   [[17, False, False],
    [31, False, False],
    [45, False, False],
    [55, False, False],
    [70, False, False],
    [82, False, False],
    [95, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [75, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]]],
 [['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -400},
    [[55, 40],
     [51, 40],
     [74, 40],
     [47, 40],
     [27, 40],
     [24, 40],
     [105, 40],
     [55, 40],
     [46, 40],
     [45, 40],
     [55, 40],
     [53, 40],
     [101, 40],
     [105, 40],
     [95, 40],
     [54, 40]]],
   [[15, False, False],
    [26, False, False],
    [60, False, False],
    [67, False, False],
    [54, False, False],
    [38, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -400},
    [[52, 40],
     [102, 40],
     [104, 40],
     [97, 40],
     [46, 40],
     [49, 40],
     [53, 40],
     [53, 40],
     [51, 40],
     [50, 40],
     [47, 40],
     [52, 40]]],
   [[12, False, False],
    [74, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[102, 40],
     [98, 40],
     [95, 40],
     [51, 40],
     [53, 40],
     [52, 40],
     [51, 40],
     [53, 40],
     [53, 40],
     [52, 40],
     [46, 40],
     [53, 40],
     [47, 40],
     [46, 40],
     [46, 40]]],
   [[62, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -400},
    [[14, 40], [17, 40], [17, 40], [13, 40], [12, 40], [20, 40], [12, 40], [19, 40], [14, 40], [20, 40]]],
   [[-26, False, False],
    [-49, False, False],
    [-72, True, False],
    [-99, True, False],
    [-127, True, False],
    [-147, True, False],
    [-175, True, False],
    [-196, True, False],
    [-222, True, False],
    [-242, True, False]]]],
 [['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[67, 40],
     [73, 40],
     [101, 40],
     [96, 40],
     [104, 40],
     [99, 40],
     [101, 40],
     [98, 40],
     [95, 40],
     [95, 40],
     [65, 40],
     [71, 40]]],
   [[27, False, False],
    [60, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[20, 40], [25, 40], [21, 40], [22, 40], [26, 40], [25, 40], [26, 40], [24, 40], [73, 40], [71, 40]]],
   [[-20, False, False],
    [-35, False, False],
    [-54, False, False],
    [-72, True, False],
    [-86, True, False],
    [-101, True, False],
    [-115, True, False],
    [-131, True, False],
    [-98, True, False],
    [-67, True, False]]],
  ['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[10, 40],
     [18, 40],
     [24, 40],
     [27, 40],
     [27, 40],
     [27, 40],
     [30, 40],
     [25, 40],
     [26, 40],
     [103, 40],
     [99, 40],
     [97, 40],
     [101, 40],
     [14, 40],
     [19, 40],
     [17, 40]]],
   [[-30, False, False],
    [-52, False, False],
    [-68, True, False],
    [-81, True, False],
    [-94, True, False],
    [-107, True, False],
    [-117, True, False],
    [-132, True, False],
    [-146, True, False],
    [-83, True, False],
    [-24, True, False],
    [33, False, False],
    [94, False, False],
    [68, False, False],
    [47, False, False],
    [24, False, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[104, 40],
     [99, 40],
     [100, 40],
     [98, 40],
     [96, 40],
     [96, 40],
     [100, 40],
     [103, 40],
     [99, 40],
     [105, 40]]],
   [[64, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, 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)

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(settings, samples):
    dm = 0
    comp = False
    aux = False
    out = []
    for supply, target in samples:
        dm = max(settings['floor'], min(100, dm - abs(supply - target)))
        if comp and dm >= settings['stop_dm']:
            comp = False
        elif not comp and dm <= settings['start_dm']:
            comp = True
        if aux and dm >= settings['start_dm']:
            aux = False
        elif not aux and dm <= settings['aux_dm']:
            aux = True
        out.append([dm, comp, aux])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[11, 40],
     [50, 40],
     [49, 40],
     [53, 40],
     [49, 40],
     [71, 40],
     [105, 40],
     [100, 40],
     [17, 40],
     [13, 40],
     [102, 40],
     [102, 40],
     [99, 40],
     [105, 40],
     [96, 40],
     [50, 40],
     [48, 40],
     [46, 40],
     [47, 40],
     [50, 40],
     [52, 40],
     [48, 40],
     [71, 40]]],
   [[-29, False, False],
    [-19, False, False],
    [-10, False, False],
    [3, False, False],
    [12, False, False],
    [43, False, False],
    [100, False, False],
    [100, False, False],
    [77, False, False],
    [50, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -250},
    [[67, 40],
     [67, 40],
     [73, 40],
     [71, 40],
     [11, 40],
     [19, 40],
     [69, 40],
     [70, 40],
     [65, 40],
     [70, 40],
     [66, 40],
     [66, 40],
     [71, 40],
     [68, 40],
     [70, 40],
     [73, 40],
     [74, 40],
     [73, 40],
     [65, 40],
     [75, 40],
     [104, 40]]],
   [[27, False, False],
    [54, False, False],
    [87, False, False],
    [100, False, False],
    [71, False, False],
    [50, False, False],
    [79, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -400},
    [[71, 40],
     [75, 40],
     [72, 40],
     [68, 40],
     [75, 40],
     [48, 40],
     [45, 40],
     [30, 40],
     [18, 40],
     [19, 40],
     [12, 40],
     [16, 40],
     [10, 40],
     [18, 40],
     [18, 40],
     [18, 40],
     [72, 40],
     [20, 40],
     [20, 40],
     [17, 40]]],
   [[31, False, False],
    [66, False, False],
    [98, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [90, False, False],
    [68, False, False],
    [47, False, False],
    [19, False, False],
    [-5, False, False],
    [-35, False, False],
    [-57, False, False],
    [-79, True, False],
    [-101, True, False],
    [-69, True, False],
    [-89, True, False],
    [-109, True, False],
    [-132, True, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[27, 40],
     [23, 40],
     [28, 40],
     [67, 40],
     [96, 40],
     [101, 40],
     [18, 40],
     [11, 40],
     [16, 40],
     [18, 40],
     [13, 40],
     [16, 40],
     [18, 40],
     [16, 40],
     [17, 40],
     [10, 40],
     [15, 40]]],
   [[-13, False, False],
    [-30, False, False],
    [-42, False, False],
    [-15, False, False],
    [41, False, False],
    [100, False, False],
    [78, False, False],
    [49, False, False],
    [25, False, False],
    [3, False, False],
    [-24, False, False],
    [-48, False, False],
    [-70, True, False],
    [-94, True, False],
    [-117, True, False],
    [-147, True, False],
    [-172, True, True]]]],
 [['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -250},
    [[57, 40],
     [101, 40],
     [100, 40],
     [98, 40],
     [95, 40],
     [100, 40],
     [101, 40],
     [103, 40],
     [96, 40],
     [97, 40],
     [14, 40],
     [17, 40],
     [12, 40],
     [20, 40],
     [13, 40]]],
   [[17, False, False],
    [78, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [74, False, False],
    [51, False, False],
    [23, False, False],
    [3, False, False],
    [-24, False, False]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[10, 40],
     [10, 40],
     [19, 40],
     [28, 40],
     [26, 40],
     [27, 40],
     [28, 40],
     [26, 40],
     [75, 40],
     [65, 40],
     [73, 40],
     [71, 40],
     [71, 40],
     [72, 40],
     [11, 40],
     [13, 40],
     [19, 40],
     [15, 40],
     [27, 40],
     [30, 40]]],
   [[-30, False, False],
    [-60, True, False],
    [-81, True, False],
    [-93, True, False],
    [-107, True, False],
    [-120, True, False],
    [-132, True, False],
    [-146, True, False],
    [-111, True, False],
    [-86, True, False],
    [-53, True, False],
    [-22, True, False],
    [9, False, False],
    [41, False, False],
    [12, False, False],
    [-15, False, False],
    [-36, False, False],
    [-61, True, False],
    [-74, True, False],
    [-84, True, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[13, 40],
     [95, 40],
     [100, 40],
     [49, 40],
     [97, 40],
     [103, 40],
     [97, 40],
     [101, 40],
     [99, 40],
     [99, 40],
     [105, 40],
     [101, 40]]],
   [[-27, False, False],
    [28, False, False],
    [88, False, False],
    [97, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[21, 40],
     [25, 40],
     [46, 40],
     [48, 40],
     [21, 40],
     [24, 40],
     [26, 40],
     [25, 40],
     [25, 40],
     [45, 40],
     [49, 40],
     [50, 40],
     [50, 40],
     [48, 40],
     [45, 40],
     [55, 40],
     [20, 40],
     [23, 40],
     [103, 40],
     [102, 40],
     [73, 40],
     [75, 40]]],
   [[-19, False, False],
    [-34, False, False],
    [-28, False, False],
    [-20, False, False],
    [-39, False, False],
    [-55, False, False],
    [-69, True, False],
    [-84, True, False],
    [-99, True, False],
    [-94, True, False],
    [-85, True, False],
    [-75, True, False],
    [-65, True, False],
    [-57, True, False],
    [-52, True, False],
    [-37, True, False],
    [-57, True, False],
    [-74, True, False],
    [-11, True, False],
    [51, False, False],
    [84, False, False],
    [100, False, False]]]],
 [['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[14, 40],
     [17, 40],
     [19, 40],
     [12, 40],
     [16, 40],
     [10, 40],
     [16, 40],
     [12, 40],
     [16, 40],
     [19, 40],
     [16, 40],
     [12, 40],
     [20, 40],
     [10, 40],
     [20, 40],
     [11, 40],
     [20, 40]]],
   [[-26, False, False],
    [-49, False, False],
    [-70, True, False],
    [-98, True, False],
    [-122, True, False],
    [-152, True, True],
    [-176, True, True],
    [-204, True, True],
    [-228, True, True],
    [-249, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True],
    [-250, True, True]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[68, 40],
     [72, 40],
     [75, 40],
     [69, 40],
     [70, 40],
     [66, 40],
     [65, 40],
     [68, 40],
     [75, 40],
     [71, 40],
     [70, 40],
     [74, 40],
     [68, 40],
     [74, 40],
     [68, 40],
     [67, 40],
     [69, 40],
     [72, 40],
     [68, 40],
     [70, 40],
     [75, 40],
     [72, 40],
     [75, 40],
     [66, 40]]],
   [[28, False, False],
    [60, False, False],
    [95, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -250},
    [[67, 40],
     [23, 40],
     [22, 40],
     [25, 40],
     [49, 40],
     [10, 40],
     [100, 40],
     [95, 40],
     [103, 40],
     [100, 40],
     [104, 40],
     [14, 40],
     [50, 40],
     [48, 40],
     [51, 40],
     [48, 40],
     [46, 40],
     [53, 40],
     [52, 40],
     [47, 40],
     [52, 40]]],
   [[27, False, False],
    [10, False, False],
    [-8, False, False],
    [-23, False, False],
    [-14, False, False],
    [-44, False, False],
    [16, False, False],
    [71, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [74, False, False],
    [84, False, False],
    [92, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[57, 40],
     [54, 40],
     [54, 40],
     [50, 40],
     [55, 40],
     [52, 40],
     [53, 40],
     [50, 40],
     [59, 40],
     [50, 40],
     [51, 40],
     [57, 40],
     [73, 40],
     [67, 40],
     [15, 40],
     [71, 40],
     [65, 40],
     [74, 40]]],
   [[17, False, False],
    [31, False, False],
    [45, False, False],
    [55, False, False],
    [70, False, False],
    [82, False, False],
    [95, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [75, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]]],
 [['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -400},
    [[55, 40],
     [51, 40],
     [74, 40],
     [47, 40],
     [27, 40],
     [24, 40],
     [105, 40],
     [55, 40],
     [46, 40],
     [45, 40],
     [55, 40],
     [53, 40],
     [101, 40],
     [105, 40],
     [95, 40],
     [54, 40]]],
   [[15, False, False],
    [26, False, False],
    [60, False, False],
    [67, False, False],
    [54, False, False],
    [38, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -400},
    [[52, 40],
     [102, 40],
     [104, 40],
     [97, 40],
     [46, 40],
     [49, 40],
     [53, 40],
     [53, 40],
     [51, 40],
     [50, 40],
     [47, 40],
     [52, 40]]],
   [[12, False, False],
    [74, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[102, 40],
     [98, 40],
     [95, 40],
     [51, 40],
     [53, 40],
     [52, 40],
     [51, 40],
     [53, 40],
     [53, 40],
     [52, 40],
     [46, 40],
     [53, 40],
     [47, 40],
     [46, 40],
     [46, 40]]],
   [[62, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -300, 'floor': -400},
    [[14, 40], [17, 40], [17, 40], [13, 40], [12, 40], [20, 40], [12, 40], [19, 40], [14, 40], [20, 40]]],
   [[-26, False, False],
    [-49, False, False],
    [-72, True, False],
    [-99, True, False],
    [-127, True, False],
    [-147, True, False],
    [-175, True, False],
    [-196, True, False],
    [-222, True, False],
    [-242, True, False]]]],
 [['regression: scenario 1',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[67, 40],
     [73, 40],
     [101, 40],
     [96, 40],
     [104, 40],
     [99, 40],
     [101, 40],
     [98, 40],
     [95, 40],
     [95, 40],
     [65, 40],
     [71, 40]]],
   [[27, False, False],
    [60, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False]]],
  ['regression: scenario 2',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[20, 40], [25, 40], [21, 40], [22, 40], [26, 40], [25, 40], [26, 40], [24, 40], [73, 40], [71, 40]]],
   [[-20, False, False],
    [-35, False, False],
    [-54, False, False],
    [-72, True, False],
    [-86, True, False],
    [-101, True, False],
    [-115, True, False],
    [-131, True, False],
    [-98, True, False],
    [-67, True, False]]],
  ['regression: deficit and recovery',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40],
     [60, 40]]],
   [[-20, False, False],
    [-40, False, False],
    [-60, True, False],
    [-80, True, False],
    [-100, True, True],
    [-120, True, True],
    [-140, True, True],
    [-120, True, True],
    [-100, True, True],
    [-80, True, True],
    [-60, True, False],
    [-40, True, False],
    [-20, True, False],
    [0, False, False]]],
  ['regression: long surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [70, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40],
     [20, 40]]],
   [[30, False, False],
    [60, False, False],
    [90, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [80, False, False],
    [60, False, False],
    [40, False, False],
    [20, False, False],
    [0, False, False]]],
  ['regression: deep deficit floor',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [0, 40], [80, 40], [80, 40], [80, 40], [80, 40]]],
   [[-40, False, False],
    [-80, True, False],
    [-120, True, True],
    [-150, True, True],
    [-150, True, True],
    [-150, True, True],
    [-110, True, True],
    [-70, True, True],
    [-30, True, False],
    [10, False, False]]],
  ['regression: start then immediate surplus',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -100, 'floor': -150},
    [[0, 40], [20, 40], [70, 40], [70, 40], [45, 40]]],
   [[-40, False, False], [-60, True, False], [-30, True, False], [0, False, False], [5, False, False]]],
  ['regression: scenario 3',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -400},
    [[10, 40],
     [18, 40],
     [24, 40],
     [27, 40],
     [27, 40],
     [27, 40],
     [30, 40],
     [25, 40],
     [26, 40],
     [103, 40],
     [99, 40],
     [97, 40],
     [101, 40],
     [14, 40],
     [19, 40],
     [17, 40]]],
   [[-30, False, False],
    [-52, False, False],
    [-68, True, False],
    [-81, True, False],
    [-94, True, False],
    [-107, True, False],
    [-117, True, False],
    [-132, True, False],
    [-146, True, False],
    [-83, True, False],
    [-24, True, False],
    [33, False, False],
    [94, False, False],
    [68, False, False],
    [47, False, False],
    [24, False, False]]],
  ['regression: scenario 4',
   [{'start_dm': -60, 'stop_dm': 0, 'aux_dm': -150, 'floor': -250},
    [[104, 40],
     [99, 40],
     [100, 40],
     [98, 40],
     [96, 40],
     [96, 40],
     [100, 40],
     [103, 40],
     [99, 40],
     [105, 40]]],
   [[64, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, False],
    [100, False, 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:
A cold supply drives DM positive and the compressor never starts.

Hydronic heat pump degree-minute controller, one sample per minute of [supply_temp, target_supply] in whole F. Degree-minutes DM accumulate supply - target each minute and are clamped to [floor, 100]. The compressor starts when DM <= start_dm and stops when DM >= stop_dm. Auxiliary heat starts when DM <= aux_dm and stops when DM >= start_dm. Decisions use the DM value after this minute's update. Return [DM, compressor, aux] per minute.

split: open-access