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

N = 1
observations = []
def solve(x):
    s = x['face'] + x['arm'] + x['grip']
    lvo = s >= 4
    def mins(t):
        h, m = map(int, t.split(':'))
        return h * 60 + m
    elapsed = mins(x['now']) - mins(x['lkw']) + (1440 if x['lkw_yesterday'] else 0)
    if elapsed <= 270:
        path = 'THROMBOLYSIS_WINDOW'
    elif elapsed <= 1440 and lvo:
        path = 'THROMBECTOMY_EVAL'
    else:
        path = 'OUTSIDE_WINDOW'
    dest = 'COMPREHENSIVE' if lvo and elapsed <= 270 else 'NEAREST'
    return {'score': s, 'lvo': lvo, 'elapsed_min': elapsed, 'pathway': path, 'destination': dest}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:10', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 10, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '01:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 180,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '01:00', 'now': '05:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:46', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 286, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:10', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1450,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '01:00', 'now': '01:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})],
 [('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:20', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 20, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '02:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 240,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '02:00', 'now': '06:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:47', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 287, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:20', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1460,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '02:00', 'now': '02:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})],
 [('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:30', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 30, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '03:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 300,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '03:00', 'now': '07:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:48', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 288, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:30', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1470,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '03:00', 'now': '03:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})],
 [('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:40', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 40, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '04:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 360,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '04:00', 'now': '08:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:49', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 289, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:40', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1480,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '04:00', 'now': '04:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})],
 [('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:50', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 50, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '05:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 420,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '05:00', 'now': '09:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:50', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 290, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:50', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1490,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '05:00', 'now': '05:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})]]
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):
    s = x['face'] + x['arm'] + x['grip']
    lvo = s >= 4
    def mins(t):
        h, m = map(int, t.split(':'))
        return h * 60 + m
    elapsed = mins(x['now']) - mins(x['lkw']) + (1440 if x['lkw_yesterday'] else 0)
    if elapsed <= 270:
        path = 'THROMBOLYSIS_WINDOW'
    elif elapsed <= 1440 and lvo:
        path = 'THROMBECTOMY_EVAL'
    else:
        path = 'OUTSIDE_WINDOW'
    dest = 'COMPREHENSIVE' if lvo and elapsed <= 1440 else 'NEAREST'
    return {'score': s, 'lvo': lvo, 'elapsed_min': elapsed, 'pathway': path, 'destination': dest}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:10', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 10, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '01:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 180,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '01:00', 'now': '05:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:46', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 286, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:10', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1450,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '01:00', 'now': '01:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})],
 [('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:20', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 20, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '02:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 240,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '02:00', 'now': '06:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:47', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 287, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:20', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1460,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '02:00', 'now': '02:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})],
 [('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:30', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 30, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '03:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 300,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '03:00', 'now': '07:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:48', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 288, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:30', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1470,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '03:00', 'now': '03:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})],
 [('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:40', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 40, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '04:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 360,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '04:00', 'now': '08:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:49', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 289, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:40', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1480,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '04:00', 'now': '04:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})],
 [('mild deficit early',
   {'face': 1, 'arm': 1, 'grip': 0, 'lkw': '10:00', 'now': '10:50', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 50, 'pathway': 'THROMBOLYSIS_WINDOW', 'destination': 'NEAREST'}),
  ('score exactly 4 without facial droop',
   {'face': 0, 'arm': 2, 'grip': 2, 'lkw': '10:00', 'now': '12:00', 'lkw_yesterday': False},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 120,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('last known well yesterday evening',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '22:00', 'now': '05:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 420,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('exactly 4.5 hours',
   {'face': 1, 'arm': 1, 'grip': 1, 'lkw': '05:00', 'now': '09:30', 'lkw_yesterday': False},
   {'score': 3,
    'lvo': False,
    'elapsed_min': 270,
    'pathway': 'THROMBOLYSIS_WINDOW',
    'destination': 'NEAREST'}),
  ('4 hours 50 minutes',
   {'face': 0, 'arm': 1, 'grip': 1, 'lkw': '08:00', 'now': '12:50', 'lkw_yesterday': False},
   {'score': 2, 'lvo': False, 'elapsed_min': 290, 'pathway': 'OUTSIDE_WINDOW', 'destination': 'NEAREST'}),
  ('large vessel at 20 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '14:00', 'now': '10:00', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1200,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel beyond 24 hours',
   {'face': 1, 'arm': 2, 'grip': 2, 'lkw': '08:00', 'now': '08:50', 'lkw_yesterday': True},
   {'score': 5,
    'lvo': True,
    'elapsed_min': 1490,
    'pathway': 'OUTSIDE_WINDOW',
    'destination': 'COMPREHENSIVE'}),
  ('large vessel exactly 24 hours',
   {'face': 1, 'arm': 2, 'grip': 1, 'lkw': '05:00', 'now': '05:00', 'lkw_yesterday': True},
   {'score': 4,
    'lvo': True,
    'elapsed_min': 1440,
    'pathway': 'THROMBECTOMY_EVAL',
    'destination': 'COMPREHENSIVE'})]]
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:
Large-vessel patients outside the thrombolysis window are sent to the nearest centre.

Input {face 0-1, arm 0-2, grip 0-2, lkw "HH:MM", now "HH:MM", lkw_yesterday}. Score = face+arm+grip; large-vessel suspicion when score >= 4. elapsed = now - lkw in minutes (+1440 if last known well was yesterday). Pathway: elapsed <= 270 THROMBOLYSIS_WINDOW; else elapsed <= 1440 with suspicion THROMBECTOMY_EVAL; else OUTSIDE_WINDOW. Destination COMPREHENSIVE for any large-vessel suspicion, else NEAREST. Return {score, lvo, elapsed_min, pathway, destination}.

split: open-access


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

N = 1
observations = []
def solve(x):
    a = x['age']
    sbp_lim = 90
    if x['gcs'] <= 13 or x['sbp'] < sbp_lim or x['rr'] < 10 or x['rr'] > 29:
        return {'tier': 'TIER1', 'step': 1}
    if x['penetrating_torso'] or x['flail_chest'] or x['two_long_bone_fx']:
        return {'tier': 'TIER1', 'step': 2}
    fall_lim = 3 if a < 15 else 6
    if x['fall_m'] > fall_lim or x['ejection']:
        return {'tier': 'TIER2', 'step': 3}
    if x['anticoag'] or x['pregnant_weeks'] > 20 or a >= 65:
        return {'tier': 'TIER3', 'step': 4}
    return {'tier': 'LOCAL', 'step': 0}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 101,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 21,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 1,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 51,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 29,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 11},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 102,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 22,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 2,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 52,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 30,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 10},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 103,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 23,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 3,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 53,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 9},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 34,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 104,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 24,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 54,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 8},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 35,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 105,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 25,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 55,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 7},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})]]
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):
    a = x['age']
    sbp_lim = 110 if a > 65 else 90
    if x['gcs'] <= 13 or x['sbp'] < sbp_lim or x['rr'] < 10 or x['rr'] > 29:
        return {'tier': 'TIER1', 'step': 1}
    if x['penetrating_torso'] or x['flail_chest'] or x['two_long_bone_fx']:
        return {'tier': 'TIER1', 'step': 2}
    fall_lim = 3 if a < 15 else 6
    if x['fall_m'] > fall_lim or x['ejection']:
        return {'tier': 'TIER2', 'step': 3}
    if x['anticoag'] or x['pregnant_weeks'] > 20 or a >= 65:
        return {'tier': 'TIER3', 'step': 4}
    return {'tier': 'LOCAL', 'step': 0}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 101,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 21,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 1,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 51,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 29,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 11},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 102,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 22,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 2,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 52,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 30,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 10},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 103,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 23,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 3,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 53,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 9},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 34,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 104,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 24,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 54,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 8},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 35,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 105,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 25,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 55,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 7},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})]]
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 65-year-old with systolic 101 is not recognised as hypotensive for their age.

Input {gcs, sbp, rr, age, penetrating_torso, flail_chest, two_long_bone_fx, fall_m, ejection, anticoag, pregnant_weeks}. Toy steps in order: (1) gcs <= 13, sbp below 90 (below 110 when age >= 65), rr < 10 or rr > 29 -> TIER1 step 1; (2) penetrating torso, flail chest or two long-bone fractures -> TIER1 step 2; (3) fall above 6 m (above 3 m when age < 15) or ejection -> TIER2 step 3; (4) anticoagulation, pregnancy beyond 20 weeks or age >= 65 -> TIER3 step 4; else LOCAL step 0. Return {tier, step}.

split: open-access


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

N = 1
observations = []
def solve(x):
    a = x['age']
    sbp_lim = 110 if a >= 65 else 90
    if x['gcs'] <= 13 or x['sbp'] < sbp_lim or x['rr'] > 29:
        return {'tier': 'TIER1', 'step': 1}
    if x['penetrating_torso'] or x['flail_chest'] or x['two_long_bone_fx']:
        return {'tier': 'TIER1', 'step': 2}
    fall_lim = 3 if a < 15 else 6
    if x['fall_m'] > fall_lim or x['ejection']:
        return {'tier': 'TIER2', 'step': 3}
    if x['anticoag'] or x['pregnant_weeks'] > 20 or a >= 65:
        return {'tier': 'TIER3', 'step': 4}
    return {'tier': 'LOCAL', 'step': 0}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 101,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 21,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 1,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 51,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 29,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 11},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 102,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 22,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 2,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 52,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 30,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 10},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 103,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 23,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 3,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 53,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 9},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 34,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 104,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 24,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 54,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 8},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 35,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 105,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 25,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 55,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 7},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})]]
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):
    a = x['age']
    sbp_lim = 110 if a >= 65 else 90
    if x['gcs'] <= 13 or x['sbp'] < sbp_lim or x['rr'] <= 10 or x['rr'] >= 29:
        return {'tier': 'TIER1', 'step': 1}
    if x['penetrating_torso'] or x['flail_chest'] or x['two_long_bone_fx']:
        return {'tier': 'TIER1', 'step': 2}
    fall_lim = 3 if a < 15 else 6
    if x['fall_m'] > fall_lim or x['ejection']:
        return {'tier': 'TIER2', 'step': 3}
    if x['anticoag'] or x['pregnant_weeks'] > 20 or a >= 65:
        return {'tier': 'TIER3', 'step': 4}
    return {'tier': 'LOCAL', 'step': 0}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 101,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 21,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 1,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 51,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 29,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 11},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 102,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 22,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 2,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 52,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 30,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 10},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 103,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 23,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 3,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 53,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 9},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 34,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 104,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 24,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 54,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 8},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 35,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 105,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 25,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 55,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 7},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})]]
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 breathing 8 times a minute is not triaged to the highest tier.

Input {gcs, sbp, rr, age, penetrating_torso, flail_chest, two_long_bone_fx, fall_m, ejection, anticoag, pregnant_weeks}. Toy steps in order: (1) gcs <= 13, sbp below 90 (below 110 when age >= 65), rr < 10 or rr > 29 -> TIER1 step 1; (2) penetrating torso, flail chest or two long-bone fractures -> TIER1 step 2; (3) fall above 6 m (above 3 m when age < 15) or ejection -> TIER2 step 3; (4) anticoagulation, pregnancy beyond 20 weeks or age >= 65 -> TIER3 step 4; else LOCAL step 0. Return {tier, step}.

split: open-access