broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    p_age = 2 if a >= 65 else 1 if a >= 45 else 0
    rf = x['risk_factors']
    p_rf = 2 if rf >= 3 or x['known_athero'] else 1 if rf >= 1 else 0
    t = Fraction(x['troponin'])
    p_t = 0 if t <= 1 else 1 if t <= 3 else 2
    s = x['history'] + x['ecg'] + p_age + p_rf + p_t
    risk = 'HIGH' if s >= 7 else 'MODERATE' if s >= 4 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('low risk control',
   {'history': 1, 'ecg': 0, 'age': 31, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 31, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 1, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 3, 'risk': 'LOW'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 41, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 51, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 5, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 2, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 44, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 16, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 1, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})],
 [('low risk control',
   {'history': 1, 'ecg': 0, 'age': 32, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 32, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 2, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 42, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 52, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 2, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 1, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 5, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 45, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 17, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 2, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})],
 [('low risk control',
   {'history': 1, 'ecg': 0, 'age': 33, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 33, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 0, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 43, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 53, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 0, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 2, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 46, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 18, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 3, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})],
 [('low risk control',
   {'history': 1, 'ecg': 0, 'age': 34, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 34, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 1, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 3, 'risk': 'LOW'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 54, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 5, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 1, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 5, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 47, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 19, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 4, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})],
 [('low risk control',
   {'history': 1, 'ecg': 0, 'age': 35, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 35, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 2, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 41, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 55, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 2, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 2, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 48, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 20, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 5, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    p_age = 2 if a >= 65 else 1 if a >= 45 else 0
    rf = x['risk_factors']
    p_rf = 2 if rf >= 3 or x['known_athero'] else 1 if rf >= 1 else 0
    t = Fraction(x['troponin'] - x['uln'], x['uln'])
    p_t = 0 if t <= 1 else 1 if t <= 3 else 2
    s = x['history'] + x['ecg'] + p_age + p_rf + p_t
    risk = 'HIGH' if s >= 7 else 'MODERATE' if s >= 4 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('low risk control',
   {'history': 1, 'ecg': 0, 'age': 31, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 31, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 1, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 3, 'risk': 'LOW'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 41, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 51, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 5, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 2, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 44, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 16, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 1, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})],
 [('low risk control',
   {'history': 1, 'ecg': 0, 'age': 32, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 32, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 2, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 42, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 52, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 2, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 1, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 5, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 45, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 17, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 2, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})],
 [('low risk control',
   {'history': 1, 'ecg': 0, 'age': 33, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 33, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 0, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 43, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 53, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 0, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 2, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 46, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 18, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 3, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})],
 [('low risk control',
   {'history': 1, 'ecg': 0, 'age': 34, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 34, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 1, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 3, 'risk': 'LOW'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 54, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 5, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 1, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 5, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 47, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 19, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 4, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})],
 [('low risk control',
   {'history': 1, 'ecg': 0, 'age': 35, 'risk_factors': 0, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 1, 'risk': 'LOW'}),
  ('troponin just over limit with other assay limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 1, 'known_athero': False, 'troponin': 35, 'uln': 26},
   {'score': 2, 'risk': 'LOW'}),
  ('age exactly 45',
   {'history': 2, 'ecg': 0, 'age': 45, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('age 42',
   {'history': 2, 'ecg': 1, 'age': 41, 'risk_factors': 1, 'known_athero': False, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('known atherosclerosis without risk factors',
   {'history': 1, 'ecg': 0, 'age': 55, 'risk_factors': 0, 'known_athero': True, 'troponin': 7, 'uln': 14},
   {'score': 4, 'risk': 'MODERATE'}),
  ('troponin exactly at limit',
   {'history': 2, 'ecg': 2, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 14, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin exactly three times limit',
   {'history': 1, 'ecg': 2, 'age': 60, 'risk_factors': 1, 'known_athero': False, 'troponin': 42, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('troponin above three times limit',
   {'history': 0, 'ecg': 0, 'age': 40, 'risk_factors': 0, 'known_athero': False, 'troponin': 48, 'uln': 14},
   {'score': 2, 'risk': 'LOW'}),
  ('score exactly 6',
   {'history': 2, 'ecg': 1, 'age': 50, 'risk_factors': 1, 'known_athero': False, 'troponin': 20, 'uln': 14},
   {'score': 6, 'risk': 'MODERATE'}),
  ('score exactly 7',
   {'history': 2, 'ecg': 2, 'age': 70, 'risk_factors': 1, 'known_athero': False, 'troponin': 5, 'uln': 14},
   {'score': 7, 'risk': 'HIGH'})]]
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:
Almost every troponin, even a normal one, scores 2 points.

Input {history 0-2, ecg 0-2, age, risk_factors (count), known_athero, troponin (ng/L), uln (ng/L)}. Toy points: age < 45:0, 45-64:1, >=65:2; risk factors 0:0, 1-2:1, >=3 or known atherosclerosis:2; troponin as a multiple of the upper limit (troponin/uln) <= 1:0, <= 3:1, > 3:2. Risk: 0-3 LOW, 4-6 MODERATE, 7-10 HIGH. Return {score, risk}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    if a < 3:
        return {'error': 'NOT_APPLICABLE'}
    t = Fraction(str(x['temp'])) * 10
    s = (1 if t > 380 else 0) + bool(x['cough_absent']) + bool(x['exudate']) + bool(x['nodes'])
    s += 1 if a <= 14 else 0
    act = 'NO_TEST' if s <= 1 else 'TEST' if s <= 3 else 'TEST_OR_EMPIRIC'
    return {'score': s, 'action': act}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult control',
   {'age': 26, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.1', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.1', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 51, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.1', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 27, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.2', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.2', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 52, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.2', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 28, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.3', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.3', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 53, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.3', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 29, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.4', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.4', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 54, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.4', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 30, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.5', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.5', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 55, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.5', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    if a < 3:
        return {'error': 'NOT_APPLICABLE'}
    t = Fraction(str(x['temp'])) * 10
    s = (1 if t > 380 else 0) + bool(x['cough_absent']) + bool(x['exudate']) + bool(x['nodes'])
    s += 1 if a <= 14 else 0 if a < 44 else -1
    act = 'NO_TEST' if s <= 1 else 'TEST' if s <= 3 else 'TEST_OR_EMPIRIC'
    return {'score': s, 'action': act}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult control',
   {'age': 26, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.1', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.1', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 51, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.1', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 27, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.2', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.2', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 52, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.2', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 28, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.3', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.3', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 53, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.3', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 29, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.4', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.4', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 54, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.4', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 30, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.5', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.5', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 55, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.5', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})]]
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:
Patients aged 45 and over receive no age deduction.

Input {age, temp (1 dp), cough_absent, exudate, nodes}. Ages below 3 return {error NOT_APPLICABLE}. Points: temp > 38.0, absent cough, tonsillar exudate, tender nodes (1 each); age 3-14 +1, 15-44 0, >= 45 -1. The score is reported as computed (can be -1). Action: <= 1 NO_TEST, 2-3 TEST, >= 4 TEST_OR_EMPIRIC. Return {score, action}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    if a < 3:
        return {'error': 'NOT_APPLICABLE'}
    t = Fraction(str(x['temp'])) * 10
    s = (1 if t > 380 else 0) + bool(x['cough_absent']) + bool(x['exudate']) + bool(x['nodes'])
    s += 1 if a < 14 else 0 if a <= 44 else -1
    act = 'NO_TEST' if s <= 1 else 'TEST' if s <= 3 else 'TEST_OR_EMPIRIC'
    return {'score': s, 'action': act}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult control',
   {'age': 26, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.1', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.1', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 51, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.1', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 27, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.2', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.2', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 52, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.2', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 28, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.3', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.3', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 53, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.3', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 29, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.4', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.4', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 54, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.4', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 30, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.5', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.5', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 55, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.5', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    if a < 3:
        return {'error': 'NOT_APPLICABLE'}
    t = Fraction(str(x['temp'])) * 10
    s = (1 if t > 380 else 0) + bool(x['cough_absent']) + bool(x['exudate']) + bool(x['nodes'])
    s += 1 if a <= 15 else 0 if a <= 44 else -1
    act = 'NO_TEST' if s <= 1 else 'TEST' if s <= 3 else 'TEST_OR_EMPIRIC'
    return {'score': s, 'action': act}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult control',
   {'age': 26, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.1', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.1', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 51, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.1', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 27, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.2', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.2', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 52, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.2', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 28, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.3', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.3', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 53, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.3', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 29, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.4', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.4', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 54, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.4', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 30, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.5', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.5', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 55, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.5', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})]]
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 14-year-old receives no child point.

Input {age, temp (1 dp), cough_absent, exudate, nodes}. Ages below 3 return {error NOT_APPLICABLE}. Points: temp > 38.0, absent cough, tonsillar exudate, tender nodes (1 each); age 3-14 +1, 15-44 0, >= 45 -1. The score is reported as computed (can be -1). Action: <= 1 NO_TEST, 2-3 TEST, >= 4 TEST_OR_EMPIRIC. Return {score, action}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    if a <= 3:
        return {'error': 'NOT_APPLICABLE'}
    t = Fraction(str(x['temp'])) * 10
    s = (1 if t > 380 else 0) + bool(x['cough_absent']) + bool(x['exudate']) + bool(x['nodes'])
    s += 1 if a <= 14 else 0 if a <= 44 else -1
    act = 'NO_TEST' if s <= 1 else 'TEST' if s <= 3 else 'TEST_OR_EMPIRIC'
    return {'score': s, 'action': act}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult control',
   {'age': 26, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.1', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.1', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 51, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.1', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 27, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.2', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.2', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 52, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.2', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 28, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.3', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.3', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 53, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.3', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 29, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.4', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.4', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 54, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.4', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 30, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.5', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.5', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 55, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.5', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    if a < 3 or a > 75:
        return {'error': 'NOT_APPLICABLE'}
    t = Fraction(str(x['temp'])) * 10
    s = (1 if t > 380 else 0) + bool(x['cough_absent']) + bool(x['exudate']) + bool(x['nodes'])
    s += 1 if a <= 14 else 0 if a <= 44 else -1
    act = 'NO_TEST' if s <= 1 else 'TEST' if s <= 3 else 'TEST_OR_EMPIRIC'
    return {'score': s, 'action': act}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult control',
   {'age': 26, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.1', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.1', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 51, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.1', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 27, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.2', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.2', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 52, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.2', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 28, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.3', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.3', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 53, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.3', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 29, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.4', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.4', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 54, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.4', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 30, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.5', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.5', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 55, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.5', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})]]
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 3-year-old is reported as not applicable.

Input {age, temp (1 dp), cough_absent, exudate, nodes}. Ages below 3 return {error NOT_APPLICABLE}. Points: temp > 38.0, absent cough, tonsillar exudate, tender nodes (1 each); age 3-14 +1, 15-44 0, >= 45 -1. The score is reported as computed (can be -1). Action: <= 1 NO_TEST, 2-3 TEST, >= 4 TEST_OR_EMPIRIC. Return {score, action}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    if a < 3:
        return {'error': 'NOT_APPLICABLE'}
    t = Fraction(str(x['temp'])) * 10
    s = (1 if t >= 380 else 0) + bool(x['cough_absent']) + bool(x['exudate']) + bool(x['nodes'])
    s += 1 if a <= 14 else 0 if a <= 44 else -1
    act = 'NO_TEST' if s <= 1 else 'TEST' if s <= 3 else 'TEST_OR_EMPIRIC'
    return {'score': s, 'action': act}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult control',
   {'age': 26, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.1', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.1', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 51, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.1', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 27, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.2', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.2', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 52, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.2', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 28, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.3', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.3', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 53, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.3', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 29, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.4', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.4', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 54, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.4', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 30, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.5', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.5', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 55, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.5', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age']
    if a < 3:
        return {'error': 'NOT_APPLICABLE'}
    t = Fraction(str(x['temp'])) * 10
    s = (1 if math.floor(t / 10) > 38 else 0) + bool(x['cough_absent']) + bool(x['exudate']) + bool(x['nodes'])
    s += 1 if a <= 14 else 0 if a <= 44 else -1
    act = 'NO_TEST' if s <= 1 else 'TEST' if s <= 3 else 'TEST_OR_EMPIRIC'
    return {'score': s, 'action': act}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult control',
   {'age': 26, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.1', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.1', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 51, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.1', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 27, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.2', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.2', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 52, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.2', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 28, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.3', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.3', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 53, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.3', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 29, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.4', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.4', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 54, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.4', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})],
 [('adult control',
   {'age': 30, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 0, 'action': 'NO_TEST'}),
  ('toddler below eligibility',
   {'age': 2, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'error': 'NOT_APPLICABLE'}),
  ('three-year-old eligible',
   {'age': 3, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': 1, 'action': 'NO_TEST'}),
  ('fourteen-year-old gets child point',
   {'age': 14, 'temp': '38.5', 'cough_absent': False, 'exudate': False, 'nodes': True},
   {'score': 3, 'action': 'TEST'}),
  ('fifteen-year-old no modifier',
   {'age': 15, 'temp': '37.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('44-year-old no modifier',
   {'age': 44, 'temp': '37.5', 'cough_absent': True, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('older adult negative score',
   {'age': 55, 'temp': '37.0', 'cough_absent': False, 'exudate': False, 'nodes': False},
   {'score': -1, 'action': 'NO_TEST'}),
  ('temperature 38.0 not fever',
   {'age': 30, 'temp': '38.0', 'cough_absent': False, 'exudate': True, 'nodes': True},
   {'score': 2, 'action': 'TEST'}),
  ('temperature 38.x is fever',
   {'age': 30, 'temp': '38.5', 'cough_absent': False, 'exudate': True, 'nodes': False},
   {'score': 2, 'action': 'TEST'}),
  ('all criteria child',
   {'age': 8, 'temp': '38.9', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 5, 'action': 'TEST_OR_EMPIRIC'}),
  ('elderly with all criteria',
   {'age': 80, 'temp': '38.5', 'cough_absent': True, 'exudate': True, 'nodes': True},
   {'score': 3, 'action': 'TEST'})]]
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 temperature of exactly 38.0 earns the fever point.

Input {age, temp (1 dp), cough_absent, exudate, nodes}. Ages below 3 return {error NOT_APPLICABLE}. Points: temp > 38.0, absent cough, tonsillar exudate, tender nodes (1 each); age 3-14 +1, 15-44 0, >= 45 -1. The score is reported as computed (can be -1). Action: <= 1 NO_TEST, 2-3 TEST, >= 4 TEST_OR_EMPIRIC. Return {score, action}.

split: open-access