broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if u < 65 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 120 else 1 if hb >= 100 else 6
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2 if bp > 90 else 3
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] >= 100 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s == 0 else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if u < 65 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 120 else 1 if hb >= 100 else 6
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] >= 100 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s == 0 else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
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 systolic pressure of exactly 90 scores 3.

Input {urea (mmol/L), hb (g/dL), sex, sbp, hr, melena, syncope, hepatic, cardiac}. Toy points: urea < 6.5:0, 6.5-7.9:2, 8.0-9.9:3, 10.0-24.9:4, >=25:6. Hb male >=13:0, 12-12.9:1, 10-11.9:3, <10:6; female >=12:0, 10-11.9:1, <10:6. SBP >=110:0, 100-109:1, 90-99:2, <90:3. hr >= 100:1, melena 1, syncope 2, hepatic disease 2, cardiac failure 2. Disposition: 0 DISCHARGE, 1-6 ADMIT, >= 7 URGENT. Return {score, disposition}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if u < 65 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 120 else 1 if hb >= 100 else 6
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2 if bp >= 90 else 3
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] >= 100 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s <= 1 else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if u < 65 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 120 else 1 if hb >= 100 else 6
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2 if bp >= 90 else 3
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] >= 100 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s < 2 and not x['melena'] else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
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 scoring 1 for tachycardia is discharged.

Input {urea (mmol/L), hb (g/dL), sex, sbp, hr, melena, syncope, hepatic, cardiac}. Toy points: urea < 6.5:0, 6.5-7.9:2, 8.0-9.9:3, 10.0-24.9:4, >=25:6. Hb male >=13:0, 12-12.9:1, 10-11.9:3, <10:6; female >=12:0, 10-11.9:1, <10:6. SBP >=110:0, 100-109:1, 90-99:2, <90:3. hr >= 100:1, melena 1, syncope 2, hepatic disease 2, cardiac failure 2. Disposition: 0 DISCHARGE, 1-6 ADMIT, >= 7 URGENT. Return {score, disposition}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if u < 65 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 120 else 1 if hb >= 100 else 6
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2 if bp >= 90 else 3
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] > 100 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s == 0 else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if u < 65 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 120 else 1 if hb >= 100 else 6
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2 if bp >= 90 else 3
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] >= 100 and bp >= 90 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s == 0 else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
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 heart rate of exactly 100 is not scored.

Input {urea (mmol/L), hb (g/dL), sex, sbp, hr, melena, syncope, hepatic, cardiac}. Toy points: urea < 6.5:0, 6.5-7.9:2, 8.0-9.9:3, 10.0-24.9:4, >=25:6. Hb male >=13:0, 12-12.9:1, 10-11.9:3, <10:6; female >=12:0, 10-11.9:1, <10:6. SBP >=110:0, 100-109:1, 90-99:2, <90:3. hr >= 100:1, melena 1, syncope 2, hepatic disease 2, cardiac failure 2. Disposition: 0 DISCHARGE, 1-6 ADMIT, >= 7 URGENT. Return {score, disposition}.

split: open-access