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

N = 1
observations = []
def solve(x):
    hr = x['hr']
    pts = 1 if hr < 100 else 2
    pts += ['absent', 'weak', 'good'].index(x['resp'])
    pts += ['limp', 'some', 'active'].index(x['tone'])
    pts += ['none', 'grimace', 'cry'].index(x['reflex'])
    pts += ['blue', 'acro', 'pink'].index(x['color'])
    cat = 'REASSURING' if pts >= 7 else 'MODERATE' if pts >= 4 else 'LOW'
    rep = 5 if x['minute'] == 1 else x['minute'] + 5 if pts < 7 and x['minute'] < 20 else None
    return {'score': pts, 'category': cat, 'repeat_at': rep}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 5},
   {'score': 0, 'category': 'LOW', 'repeat_at': 10}),
  ('slow heart rate 50',
   {'hr': 51, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 65, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 41, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 81, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 10},
   {'score': 0, 'category': 'LOW', 'repeat_at': 15}),
  ('slow heart rate 50',
   {'hr': 52, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 70, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 42, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 82, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 0, 'category': 'LOW', 'repeat_at': 20}),
  ('slow heart rate 50',
   {'hr': 53, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 75, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 43, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 83, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 54, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 80, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 44, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 84, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 25},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 55, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 85, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 45, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 85, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})]]
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(x):
    hr = x['hr']
    pts = 0 if hr < 60 else 1 if hr < 100 else 2
    pts += ['absent', 'weak', 'good'].index(x['resp'])
    pts += ['limp', 'some', 'active'].index(x['tone'])
    pts += ['none', 'grimace', 'cry'].index(x['reflex'])
    pts += ['blue', 'acro', 'pink'].index(x['color'])
    cat = 'REASSURING' if pts >= 7 else 'MODERATE' if pts >= 4 else 'LOW'
    rep = 5 if x['minute'] == 1 else x['minute'] + 5 if pts < 7 and x['minute'] < 20 else None
    return {'score': pts, 'category': cat, 'repeat_at': rep}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 5},
   {'score': 0, 'category': 'LOW', 'repeat_at': 10}),
  ('slow heart rate 50',
   {'hr': 51, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 65, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 41, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 81, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 10},
   {'score': 0, 'category': 'LOW', 'repeat_at': 15}),
  ('slow heart rate 50',
   {'hr': 52, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 70, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 42, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 82, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 0, 'category': 'LOW', 'repeat_at': 20}),
  ('slow heart rate 50',
   {'hr': 53, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 75, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 43, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 83, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 54, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 80, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 44, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 84, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 25},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 55, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 85, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 45, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 85, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})]]
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 newborn with no heart rate receives a heart-rate point.

Input {hr, resp (absent|weak|good), tone (limp|some|active), reflex (none|grimace|cry), color (blue|acro|pink), minute}. Heart rate: 0 scores 0, 1-99 scores 1, >= 100 scores 2; the other signs score 0/1/2 in the listed order. Category: 7-10 REASSURING, 4-6 MODERATE, 0-3 LOW. repeat_at is 5 after any 1-minute score; after later scores it is minute + 5 when the total is below 7 and minute < 20, else null. Return {score, category, repeat_at}.

split: open-access


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

N = 1
observations = []
def solve(x):
    hr = x['hr']
    pts = 0 if hr == 0 else 1 if hr < 100 else 2
    pts += ['absent', 'weak', 'good'].index(x['resp'])
    pts += ['limp', 'some', 'active'].index(x['tone'])
    pts += ['none', 'grimace', 'cry'].index(x['reflex'])
    pts += ['blue', 'acro', 'pink'].index(x['color'])
    cat = 'REASSURING' if pts > 7 else 'MODERATE' if pts >= 4 else 'LOW'
    rep = 5 if x['minute'] == 1 else x['minute'] + 5 if pts < 7 and x['minute'] < 20 else None
    return {'score': pts, 'category': cat, 'repeat_at': rep}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 5},
   {'score': 0, 'category': 'LOW', 'repeat_at': 10}),
  ('slow heart rate 50',
   {'hr': 51, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 65, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 41, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 81, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 10},
   {'score': 0, 'category': 'LOW', 'repeat_at': 15}),
  ('slow heart rate 50',
   {'hr': 52, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 70, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 42, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 82, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 0, 'category': 'LOW', 'repeat_at': 20}),
  ('slow heart rate 50',
   {'hr': 53, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 75, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 43, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 83, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 54, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 80, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 44, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 84, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 25},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 55, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 85, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 45, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 85, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})]]
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(x):
    hr = x['hr']
    pts = 0 if hr == 0 else 1 if hr < 100 else 2
    pts += ['absent', 'weak', 'good'].index(x['resp'])
    pts += ['limp', 'some', 'active'].index(x['tone'])
    pts += ['none', 'grimace', 'cry'].index(x['reflex'])
    pts += ['blue', 'acro', 'pink'].index(x['color'])
    cat = 'REASSURING' if pts >= 7 and hr >= 100 else 'MODERATE' if pts >= 4 else 'LOW'
    rep = 5 if x['minute'] == 1 else x['minute'] + 5 if pts < 7 and x['minute'] < 20 else None
    return {'score': pts, 'category': cat, 'repeat_at': rep}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 5},
   {'score': 0, 'category': 'LOW', 'repeat_at': 10}),
  ('slow heart rate 50',
   {'hr': 51, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 65, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 41, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 81, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 10},
   {'score': 0, 'category': 'LOW', 'repeat_at': 15}),
  ('slow heart rate 50',
   {'hr': 52, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 70, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 42, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 82, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 0, 'category': 'LOW', 'repeat_at': 20}),
  ('slow heart rate 50',
   {'hr': 53, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 75, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 43, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 83, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 54, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 80, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 44, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 84, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 25},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 55, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 85, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 45, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 85, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})]]
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 total of 7 is reported as moderate.

Input {hr, resp (absent|weak|good), tone (limp|some|active), reflex (none|grimace|cry), color (blue|acro|pink), minute}. Heart rate: 0 scores 0, 1-99 scores 1, >= 100 scores 2; the other signs score 0/1/2 in the listed order. Category: 7-10 REASSURING, 4-6 MODERATE, 0-3 LOW. repeat_at is 5 after any 1-minute score; after later scores it is minute + 5 when the total is below 7 and minute < 20, else null. Return {score, category, repeat_at}.

split: open-access


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

N = 1
observations = []
def solve(x):
    hr = x['hr']
    pts = 0 if hr == 0 else 1 if hr < 100 else 2
    pts += ['absent', 'weak', 'good'].index(x['resp'])
    pts += ['limp', 'some', 'active'].index(x['tone'])
    pts += ['none', 'grimace', 'cry'].index(x['reflex'])
    pts += ['blue', 'acro', 'pink'].index(x['color'])
    cat = 'REASSURING' if pts >= 7 else 'MODERATE' if pts >= 4 else 'LOW'
    rep = x['minute'] + 5 if pts < 7 and x['minute'] < 20 else None
    return {'score': pts, 'category': cat, 'repeat_at': rep}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 5},
   {'score': 0, 'category': 'LOW', 'repeat_at': 10}),
  ('slow heart rate 50',
   {'hr': 51, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 65, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 41, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 81, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 10},
   {'score': 0, 'category': 'LOW', 'repeat_at': 15}),
  ('slow heart rate 50',
   {'hr': 52, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 70, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 42, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 82, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 0, 'category': 'LOW', 'repeat_at': 20}),
  ('slow heart rate 50',
   {'hr': 53, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 75, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 43, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 83, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 54, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 80, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 44, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 84, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 25},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 55, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 85, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 45, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 85, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})]]
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(x):
    hr = x['hr']
    pts = 0 if hr == 0 else 1 if hr < 100 else 2
    pts += ['absent', 'weak', 'good'].index(x['resp'])
    pts += ['limp', 'some', 'active'].index(x['tone'])
    pts += ['none', 'grimace', 'cry'].index(x['reflex'])
    pts += ['blue', 'acro', 'pink'].index(x['color'])
    cat = 'REASSURING' if pts >= 7 else 'MODERATE' if pts >= 4 else 'LOW'
    rep = 5 if x['minute'] == 1 and pts < 7 else x['minute'] + 5 if pts < 7 and x['minute'] < 20 else None
    return {'score': pts, 'category': cat, 'repeat_at': rep}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 5},
   {'score': 0, 'category': 'LOW', 'repeat_at': 10}),
  ('slow heart rate 50',
   {'hr': 51, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 65, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 41, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 81, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 10},
   {'score': 0, 'category': 'LOW', 'repeat_at': 15}),
  ('slow heart rate 50',
   {'hr': 52, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 70, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 42, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 82, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 0, 'category': 'LOW', 'repeat_at': 20}),
  ('slow heart rate 50',
   {'hr': 53, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 75, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 43, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 83, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 54, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 80, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 44, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 84, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 25},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 55, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 85, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 45, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 85, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})]]
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 vigorous newborn scored at 1 minute is never scheduled for the 5-minute score.

Input {hr, resp (absent|weak|good), tone (limp|some|active), reflex (none|grimace|cry), color (blue|acro|pink), minute}. Heart rate: 0 scores 0, 1-99 scores 1, >= 100 scores 2; the other signs score 0/1/2 in the listed order. Category: 7-10 REASSURING, 4-6 MODERATE, 0-3 LOW. repeat_at is 5 after any 1-minute score; after later scores it is minute + 5 when the total is below 7 and minute < 20, else null. Return {score, category, repeat_at}.

split: open-access


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

N = 1
observations = []
def solve(x):
    hr = x['hr']
    pts = 0 if hr == 0 else 1 if hr < 100 else 2
    pts += ['absent', 'weak', 'good'].index(x['resp'])
    pts += ['limp', 'some', 'active'].index(x['tone'])
    pts += ['none', 'grimace', 'cry'].index(x['reflex'])
    pts += ['blue', 'acro', 'pink'].index(x['color'])
    cat = 'REASSURING' if pts >= 7 else 'MODERATE' if pts >= 4 else 'LOW'
    rep = 5 if x['minute'] == 1 else x['minute'] + 5 if pts < 4 and x['minute'] < 20 else None
    return {'score': pts, 'category': cat, 'repeat_at': rep}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 5},
   {'score': 0, 'category': 'LOW', 'repeat_at': 10}),
  ('slow heart rate 50',
   {'hr': 51, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 65, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 41, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 81, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 10},
   {'score': 0, 'category': 'LOW', 'repeat_at': 15}),
  ('slow heart rate 50',
   {'hr': 52, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 70, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 42, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 82, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 0, 'category': 'LOW', 'repeat_at': 20}),
  ('slow heart rate 50',
   {'hr': 53, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 75, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 43, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 83, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 54, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 80, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 44, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 84, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 25},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 55, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 85, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 45, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 85, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})]]
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(x):
    hr = x['hr']
    pts = 0 if hr == 0 else 1 if hr < 100 else 2
    pts += ['absent', 'weak', 'good'].index(x['resp'])
    pts += ['limp', 'some', 'active'].index(x['tone'])
    pts += ['none', 'grimace', 'cry'].index(x['reflex'])
    pts += ['blue', 'acro', 'pink'].index(x['color'])
    cat = 'REASSURING' if pts >= 7 else 'MODERATE' if pts >= 4 else 'LOW'
    rep = 5 if x['minute'] == 1 else x['minute'] + 5 if pts <= 7 and x['minute'] < 20 else None
    return {'score': pts, 'category': cat, 'repeat_at': rep}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 5},
   {'score': 0, 'category': 'LOW', 'repeat_at': 10}),
  ('slow heart rate 50',
   {'hr': 51, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 65, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 41, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 81, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 10},
   {'score': 0, 'category': 'LOW', 'repeat_at': 15}),
  ('slow heart rate 50',
   {'hr': 52, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 70, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 42, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 82, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 0, 'category': 'LOW', 'repeat_at': 20}),
  ('slow heart rate 50',
   {'hr': 53, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 75, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 43, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 83, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'acro', 'minute': 1},
   {'score': 9, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 54, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 5},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 10}),
  ('total 7 with slow heart rate',
   {'hr': 80, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 44, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 84, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})],
 [('vigorous newborn',
   {'hr': 140, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'pink', 'minute': 1},
   {'score': 10, 'category': 'REASSURING', 'repeat_at': 5}),
  ('absent heart rate',
   {'hr': 0, 'resp': 'absent', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 25},
   {'score': 0, 'category': 'LOW', 'repeat_at': None}),
  ('slow heart rate 50',
   {'hr': 55, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 5}),
  ('total exactly 7',
   {'hr': 120, 'resp': 'good', 'tone': 'some', 'reflex': 'grimace', 'color': 'acro', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 4',
   {'hr': 90, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 10},
   {'score': 4, 'category': 'MODERATE', 'repeat_at': 15}),
  ('total 7 with slow heart rate',
   {'hr': 85, 'resp': 'good', 'tone': 'active', 'reflex': 'cry', 'color': 'blue', 'minute': 5},
   {'score': 7, 'category': 'REASSURING', 'repeat_at': None}),
  ('total exactly 3',
   {'hr': 45, 'resp': 'weak', 'tone': 'some', 'reflex': 'none', 'color': 'blue', 'minute': 1},
   {'score': 3, 'category': 'LOW', 'repeat_at': 5}),
  ('low score at 15 minutes',
   {'hr': 80, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 15},
   {'score': 2, 'category': 'LOW', 'repeat_at': 20}),
  ('low score at 20 minutes stops',
   {'hr': 85, 'resp': 'weak', 'tone': 'limp', 'reflex': 'none', 'color': 'blue', 'minute': 20},
   {'score': 2, 'category': 'LOW', 'repeat_at': None}),
  ('moderate at one minute',
   {'hr': 110, 'resp': 'weak', 'tone': 'some', 'reflex': 'grimace', 'color': 'blue', 'minute': 1},
   {'score': 5, 'category': 'MODERATE', 'repeat_at': 5})]]
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:
Newborns scoring 4-6 are not scheduled for reassessment.

Input {hr, resp (absent|weak|good), tone (limp|some|active), reflex (none|grimace|cry), color (blue|acro|pink), minute}. Heart rate: 0 scores 0, 1-99 scores 1, >= 100 scores 2; the other signs score 0/1/2 in the listed order. Category: 7-10 REASSURING, 4-6 MODERATE, 0-3 LOW. repeat_at is 5 after any 1-minute score; after later scores it is minute + 5 when the total is below 7 and minute < 20, else null. Return {score, category, repeat_at}.

split: open-access