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

N = 1
observations = []
def solve(x):
    if x['age'] < 16 or x['gcs'] < 15:
        return {'decision': 'NOT_APPLICABLE'}
    if x['age'] >= 65 or x['dangerous_mechanism'] or x['paresthesias']:
        return {'decision': 'IMAGE'}
    low = [x['simple_rear_end'], x['sitting'], x['ambulatory'], x['delayed_onset'], x['no_midline_tenderness']]
    if not any(low):
        return {'decision': 'IMAGE'}
    if x['rotate_left'] >= 45 or x['rotate_right'] >= 45:
        return {'decision': 'NO_IMAGE'}
    return {'decision': 'IMAGE'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 51,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 61},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 31,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 21,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 31,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 26,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 52,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 62},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 32,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 22,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 32,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 27,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 53,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 63},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 33,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 23,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 33,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 28,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 54,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 64},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 34,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 24,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 34,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 29,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 55,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 65},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 25,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 35,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 30,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    if x['age'] < 16 or x['gcs'] < 15:
        return {'decision': 'NOT_APPLICABLE'}
    if x['age'] >= 65 or x['dangerous_mechanism'] or x['paresthesias']:
        return {'decision': 'IMAGE'}
    low = [x['simple_rear_end'], x['sitting'], x['ambulatory'], x['delayed_onset'], x['no_midline_tenderness']]
    if not any(low):
        return {'decision': 'IMAGE'}
    if min(x['rotate_left'], x['rotate_right']) > 45:
        return {'decision': 'NO_IMAGE'}
    return {'decision': 'IMAGE'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 51,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 61},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 31,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 21,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 31,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 26,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 52,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 62},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 32,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 22,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 32,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 27,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 53,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 63},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 33,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 23,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 33,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 28,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 54,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 64},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 34,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 24,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 34,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 29,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 55,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 65},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 25,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 35,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 30,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})]]
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 patient who can only rotate to one side is cleared.

Input {age, gcs, dangerous_mechanism, paresthesias, simple_rear_end, sitting, ambulatory, delayed_onset, no_midline_tenderness, rotate_left, rotate_right (degrees)}. Toy rule: age < 16 or gcs < 15 NOT_APPLICABLE. High risk (age >= 65, dangerous mechanism or paresthesias) -> IMAGE. If none of the low-risk factors (simple rear-end collision, sitting, ambulatory, delayed onset, no midline tenderness) is present -> IMAGE. Otherwise NO_IMAGE when active rotation reaches 45 degrees both left and right, else IMAGE. Return {decision}.

split: open-access


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

N = 1
observations = []
def solve(x):
    if x['age'] < 16 or x['gcs'] < 15:
        return {'decision': 'NOT_APPLICABLE'}
    if x['age'] >= 65 or x['dangerous_mechanism']:
        return {'decision': 'IMAGE'}
    low = [x['simple_rear_end'], x['sitting'], x['ambulatory'], x['delayed_onset'], x['no_midline_tenderness']]
    if not any(low):
        return {'decision': 'IMAGE'}
    if x['rotate_left'] >= 45 and x['rotate_right'] >= 45:
        return {'decision': 'NO_IMAGE'}
    return {'decision': 'IMAGE'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 51,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 61},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 31,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 21,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 31,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 26,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 52,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 62},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 32,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 22,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 32,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 27,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 53,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 63},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 33,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 23,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 33,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 28,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 54,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 64},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 34,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 24,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 34,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 29,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 55,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 65},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 25,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 35,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 30,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(x):
    if x['age'] < 16 or x['gcs'] < 15:
        return {'decision': 'NOT_APPLICABLE'}
    if x['age'] >= 65 or x['dangerous_mechanism'] or (x['paresthesias'] and not x['ambulatory']):
        return {'decision': 'IMAGE'}
    low = [x['simple_rear_end'], x['sitting'], x['ambulatory'], x['delayed_onset'], x['no_midline_tenderness']]
    if not any(low):
        return {'decision': 'IMAGE'}
    if x['rotate_left'] >= 45 and x['rotate_right'] >= 45:
        return {'decision': 'NO_IMAGE'}
    return {'decision': 'IMAGE'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 51,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 61},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 31,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 21,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 31,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 26,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 52,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 62},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 32,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 22,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 32,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 27,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 53,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 63},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 33,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 23,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 33,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 28,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 54,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 64},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 34,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 24,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 34,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 29,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})],
 [('age exactly 65',
   {'age': 65,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('age 64 with low-risk factors',
   {'age': 64,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('single low-risk factor',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 55,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('two low-risk factors',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 65},
   {'decision': 'NO_IMAGE'}),
  ('all low-risk factors',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': True,
    'sitting': True,
    'ambulatory': True,
    'delayed_onset': True,
    'no_midline_tenderness': True,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NO_IMAGE'}),
  ('rotation exactly 45 both ways',
   {'age': 25,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 45,
    'rotate_right': 45},
   {'decision': 'NO_IMAGE'}),
  ('rotation limited to one side',
   {'age': 40,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 35,
    'rotate_right': 70},
   {'decision': 'IMAGE'}),
  ('paresthesias in ambulatory patient',
   {'age': 30,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('paresthesias non-ambulatory',
   {'age': 35,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': True,
    'simple_rear_end': False,
    'sitting': True,
    'ambulatory': False,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'IMAGE'}),
  ('adolescent below applicability',
   {'age': 15,
    'gcs': 15,
    'dangerous_mechanism': False,
    'paresthesias': False,
    'simple_rear_end': False,
    'sitting': False,
    'ambulatory': True,
    'delayed_onset': False,
    'no_midline_tenderness': False,
    'rotate_left': 60,
    'rotate_right': 60},
   {'decision': 'NOT_APPLICABLE'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Patients reporting extremity paresthesias are cleared by the rotation test.

Input {age, gcs, dangerous_mechanism, paresthesias, simple_rear_end, sitting, ambulatory, delayed_onset, no_midline_tenderness, rotate_left, rotate_right (degrees)}. Toy rule: age < 16 or gcs < 15 NOT_APPLICABLE. High risk (age >= 65, dangerous mechanism or paresthesias) -> IMAGE. If none of the low-risk factors (simple rear-end collision, sitting, ambulatory, delayed onset, no midline tenderness) is present -> IMAGE. Otherwise NO_IMAGE when active rotation reaches 45 degrees both left and right, else IMAGE. Return {decision}.

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):
    pct = Fraction(x['pef'], x['best'])
    if pct < 33 or x['spo2'] < 92:
        sev = 'LIFE_THREATENING'
    elif pct <= 50 or x['rr'] >= 25 or x['hr'] >= 110 or not x['sentences']:
        sev = 'ACUTE_SEVERE'
    elif pct <= 75:
        sev = 'MODERATE'
    else:
        sev = 'MILD'
    return {'pct': round(float(pct), 1), 'severity': sev}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('mild control',
   {'pef': 430, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 86.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 310, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 62.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 91, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 19, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 331, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.2, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 26, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 11},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 116, 'age': 6},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 401, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 80.2, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 110, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 24.4, 'severity': 'LIFE_THREATENING'})],
 [('mild control',
   {'pef': 440, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 88.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 320, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 64.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 92, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 20, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 332, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.4, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 27, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 12},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 117, 'age': 7},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 402, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 80.4, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 120, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 26.7, 'severity': 'LIFE_THREATENING'})],
 [('mild control',
   {'pef': 450, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 90.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 330, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 93, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 21, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 333, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.6, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 28, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 13},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 118, 'age': 8},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 403, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 80.6, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 130, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 28.9, 'severity': 'LIFE_THREATENING'})],
 [('mild control',
   {'pef': 460, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 92.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 340, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 68.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 94, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 22, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 334, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.8, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 29, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 14},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 119, 'age': 9},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 404, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 80.8, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 140, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 31.1, 'severity': 'LIFE_THREATENING'})],
 [('mild control',
   {'pef': 470, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 94.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 95, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 23, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 335, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 67.0, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 30, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 15},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 120, 'age': 10},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 405, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 81.0, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 150, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 33.3, 'severity': 'ACUTE_SEVERE'})]]
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):
    pct = Fraction((x['best'] - x['pef']) * 100, x['best'])
    if pct < 33 or x['spo2'] < 92:
        sev = 'LIFE_THREATENING'
    elif pct <= 50 or x['rr'] >= 25 or x['hr'] >= 110 or not x['sentences']:
        sev = 'ACUTE_SEVERE'
    elif pct <= 75:
        sev = 'MODERATE'
    else:
        sev = 'MILD'
    return {'pct': round(float(pct), 1), 'severity': sev}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('mild control',
   {'pef': 430, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 86.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 310, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 62.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 91, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 19, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 331, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.2, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 26, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 11},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 116, 'age': 6},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 401, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 80.2, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 110, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 24.4, 'severity': 'LIFE_THREATENING'})],
 [('mild control',
   {'pef': 440, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 88.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 320, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 64.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 92, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 20, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 332, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.4, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 27, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 12},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 117, 'age': 7},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 402, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 80.4, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 120, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 26.7, 'severity': 'LIFE_THREATENING'})],
 [('mild control',
   {'pef': 450, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 90.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 330, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 93, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 21, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 333, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.6, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 28, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 13},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 118, 'age': 8},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 403, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 80.6, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 130, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 28.9, 'severity': 'LIFE_THREATENING'})],
 [('mild control',
   {'pef': 460, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 92.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 340, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 68.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 94, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 22, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 334, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 66.8, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 29, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 14},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 119, 'age': 9},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 404, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 80.8, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 140, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 31.1, 'severity': 'LIFE_THREATENING'})],
 [('mild control',
   {'pef': 470, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 94.0, 'severity': 'MILD'}),
  ('moderate',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'MODERATE'}),
  ('exactly 50 percent',
   {'pef': 250, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 95, 'age': 30},
   {'pct': 50.0, 'severity': 'ACUTE_SEVERE'}),
  ('exactly 33 percent',
   {'pef': 165, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 23, 'hr': 90, 'age': 30},
   {'pct': 33.0, 'severity': 'ACUTE_SEVERE'}),
  ('hypoxic with fair peak flow',
   {'pef': 335, 'best': 500, 'spo2': 90, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 67.0, 'severity': 'LIFE_THREATENING'}),
  ('severe by rate alone',
   {'pef': 350, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 30, 'hr': 90, 'age': 30},
   {'pct': 70.0, 'severity': 'ACUTE_SEVERE'}),
  ('heart rate exactly 110',
   {'pef': 360, 'best': 500, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 110, 'age': 15},
   {'pct': 72.0, 'severity': 'ACUTE_SEVERE'}),
  ('tachycardic child',
   {'pef': 200, 'best': 250, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 120, 'age': 10},
   {'pct': 80.0, 'severity': 'ACUTE_SEVERE'}),
  ('cannot finish sentences',
   {'pef': 405, 'best': 500, 'spo2': 97, 'sentences': False, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 81.0, 'severity': 'ACUTE_SEVERE'}),
  ('below one third',
   {'pef': 150, 'best': 450, 'spo2': 97, 'sentences': True, 'rr': 18, 'hr': 90, 'age': 30},
   {'pct': 33.3, 'severity': 'ACUTE_SEVERE'})]]
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:
Every patient is classified as life-threatening.

Input {pef, best (best or predicted PEF), spo2, sentences (can complete sentences), rr, hr, age}. pct = pef*100/best. Toy classification: LIFE_THREATENING when pct < 33 or spo2 < 92; ACUTE_SEVERE when pct <= 50, rr >= 25, hr >= 110 or sentences cannot be completed; MODERATE when pct <= 75; else MILD. Return {pct (1 dp), severity}.

split: open-access