broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    def r2(v):
        return float(Fraction(math.floor(v * 100), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp <= 0 or dbp >= sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(hr, sbp)
    mp = Fraction(sbp + 2 * dbp, 3)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 >= 7 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    def r2(v):
        return float(Fraction(round(v * 100), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp <= 0 or dbp >= sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(hr, sbp)
    mp = Fraction(sbp + 2 * dbp, 3)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 >= 7 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A shock index of 0.665 is reported as 0.66.

Input {hr, sbp, dbp}. Invalid when sbp <= 0, dbp <= 0 or dbp >= sbp ({error INVALID_BP}). SI = hr/sbp; MAP = (sbp + 2*dbp)/3; modified SI = hr/MAP. Category: SI >= 1.0 SHOCK_LIKELY, SI >= 0.7 ELEVATED, else NORMAL. msi_flag when modified SI > 1.3; map_low when MAP < 65. SI and MAP are reported rounded half-up to 2 decimals. Return {si, map, category, msi_flag, map_low}.

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']
    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'])
    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)

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']
    p_age = 2 if a >= 65 else 1 if a // 10 >= 4 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'])
    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:
A 45-year-old receives no age point.

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']
    p_age = 2 if a >= 65 else 1 if a >= 45 else 0
    rf = x['risk_factors']
    p_rf = 2 if rf >= 3 else 1 if rf >= 1 or x['known_athero'] else 0
    t = Fraction(x['troponin'], 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)

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'] and rf > 0) else 1 if rf >= 1 else 0
    t = Fraction(x['troponin'], 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:
Known atherosclerotic disease scores only 1 risk-factor point.

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']
    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'])
    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'])
    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:
Troponin exactly at the upper limit scores 1 and exactly three times the limit scores 2.

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']
    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'])
    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'])
    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 4 <= s < 6 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:
A score of 4 is reported as low risk.

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