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

N = 1
observations = []
def solve(x):
    d = x['last_fall_days']
    fell = d is not None and d <= 90
    s = 25 if fell else 0
    s += 15 if x['secondary_dx'] else 0
    aid = x['aid']
    s += 15 if aid in ('crutches', 'cane', 'walker', 'furniture') else 0
    s += 20 if x['iv'] else 0
    g = x['gait']
    s += 20 if g == 'impaired' else 10 if g == 'weak' else 0
    s += 15 if x['mental'] in ('forgets', 'overestimates') else 0
    risk = 'HIGH' if s >= 45 else 'MODERATE' if s >= 25 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 301,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 10,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 31,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 6,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 302,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 20,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 32,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 7,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'immobile',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 303,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 30,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'crutches',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 33,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 8,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 304,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 40,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 34,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 9,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 305,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 50,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 35,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 10,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    d = x['last_fall_days']
    fell = d is not None and d <= 90
    s = 25 if fell else 0
    s += 15 if x['secondary_dx'] else 0
    aid = x['aid']
    s += 30 if aid == 'furniture' else 15 if aid in ('crutches', 'cane') else 0
    s += 20 if x['iv'] else 0
    g = x['gait']
    s += 20 if g == 'impaired' else 10 if g == 'weak' else 0
    s += 15 if x['mental'] in ('forgets', 'overestimates') else 0
    risk = 'HIGH' if s >= 45 else 'MODERATE' if s >= 25 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 301,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 10,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 31,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 6,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 302,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 20,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 32,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 7,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'immobile',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 303,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 30,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'crutches',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 33,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 8,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 304,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 40,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 34,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 9,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 305,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 50,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 35,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 10,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Patients holding on to furniture score like cane users.

Input {last_fall_days (or null), secondary_dx, aid, iv, gait, mental}. Toy points: a fall within the last 90 days (inclusive) 25; secondary diagnosis 15; aid none/bedrest/nurse 0, crutches/cane/walker 15, furniture 30; IV access 20; gait normal/bedrest/immobile 0, weak 10, impaired 20; mental status "forgets" or "overestimates" (overestimates own ability) 15, "oriented" 0. Risk: 0-24 LOW, 25-44 MODERATE, >= 45 HIGH. Return {score, risk}.

split: open-access


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

N = 1
observations = []
def solve(x):
    d = x['last_fall_days']
    fell = d is not None and d <= 90
    s = 25 if fell else 0
    s += 15 if x['secondary_dx'] else 0
    aid = x['aid']
    s += 30 if aid == 'furniture' else 15 if aid in ('crutches', 'cane', 'walker') else 0
    s += 20 if x['iv'] else 0
    g = x['gait']
    s += 20 if g in ('impaired', 'weak') else 0
    s += 15 if x['mental'] in ('forgets', 'overestimates') else 0
    risk = 'HIGH' if s >= 45 else 'MODERATE' if s >= 25 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 301,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 10,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 31,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 6,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 302,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 20,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 32,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 7,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'immobile',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 303,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 30,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'crutches',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 33,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 8,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 304,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 40,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 34,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 9,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 305,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 50,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 35,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 10,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(x):
    d = x['last_fall_days']
    fell = d is not None and d <= 90
    s = 25 if fell else 0
    s += 15 if x['secondary_dx'] else 0
    aid = x['aid']
    s += 30 if aid == 'furniture' else 15 if aid in ('crutches', 'cane', 'walker') else 0
    s += 20 if x['iv'] else 0
    g = x['gait']
    s += 10 if g in ('impaired', 'weak') else 0
    s += 15 if x['mental'] in ('forgets', 'overestimates') else 0
    risk = 'HIGH' if s >= 45 else 'MODERATE' if s >= 25 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 301,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 10,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 31,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 6,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 302,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 20,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 32,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 7,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'immobile',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 303,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 30,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'crutches',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 33,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 8,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 304,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 40,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 34,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 9,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 305,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 50,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 35,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 10,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A weak gait scores the same 20 points as an impaired gait.

Input {last_fall_days (or null), secondary_dx, aid, iv, gait, mental}. Toy points: a fall within the last 90 days (inclusive) 25; secondary diagnosis 15; aid none/bedrest/nurse 0, crutches/cane/walker 15, furniture 30; IV access 20; gait normal/bedrest/immobile 0, weak 10, impaired 20; mental status "forgets" or "overestimates" (overestimates own ability) 15, "oriented" 0. Risk: 0-24 LOW, 25-44 MODERATE, >= 45 HIGH. Return {score, risk}.

split: open-access


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

N = 1
observations = []
def solve(x):
    d = x['last_fall_days']
    fell = d is not None and d <= 90
    s = 25 if fell else 0
    s += 15 if x['secondary_dx'] else 0
    aid = x['aid']
    s += 30 if aid == 'furniture' else 15 if aid in ('crutches', 'cane', 'walker') else 0
    s += 20 if x['iv'] else 0
    g = x['gait']
    s += 20 if g == 'impaired' else 10 if g == 'weak' else 0
    s += 15 if x['mental'] in ('forgets', 'overestimates') else 0
    risk = 'HIGH' if s >= 45 else 'MODERATE' if s > 25 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 301,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 10,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 31,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 6,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 302,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 20,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 32,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 7,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'immobile',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 303,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 30,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'crutches',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 33,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 8,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 304,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 40,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 34,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 9,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 305,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 50,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 35,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 10,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    d = x['last_fall_days']
    fell = d is not None and d <= 90
    s = 25 if fell else 0
    s += 15 if x['secondary_dx'] else 0
    aid = x['aid']
    s += 30 if aid == 'furniture' else 15 if aid in ('crutches', 'cane', 'walker') else 0
    s += 20 if x['iv'] else 0
    g = x['gait']
    s += 20 if g == 'impaired' else 10 if g == 'weak' else 0
    s += 15 if x['mental'] in ('forgets', 'overestimates') else 0
    risk = 'HIGH' if s >= 45 else 'MODERATE' if 25 <= s < 40 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 301,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 10,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 31,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 6,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 302,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 20,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 32,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 7,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'immobile',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 303,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 30,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'crutches',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 33,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 8,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 304,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 40,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 34,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 9,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 305,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 50,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 35,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 10,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A score of 25 is reported as low risk.

Input {last_fall_days (or null), secondary_dx, aid, iv, gait, mental}. Toy points: a fall within the last 90 days (inclusive) 25; secondary diagnosis 15; aid none/bedrest/nurse 0, crutches/cane/walker 15, furniture 30; IV access 20; gait normal/bedrest/immobile 0, weak 10, impaired 20; mental status "forgets" or "overestimates" (overestimates own ability) 15, "oriented" 0. Risk: 0-24 LOW, 25-44 MODERATE, >= 45 HIGH. Return {score, risk}.

split: open-access


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

N = 1
observations = []
def solve(x):
    d = x['last_fall_days']
    fell = d is not None and d <= 90
    s = 25 if fell else 0
    s += 15 if x['secondary_dx'] else 0
    aid = x['aid']
    s += 30 if aid == 'furniture' else 15 if aid in ('crutches', 'cane', 'walker') else 0
    s += 20 if x['iv'] else 0
    g = x['gait']
    s += 20 if g == 'impaired' else 10 if g == 'weak' else 0
    s += 15 if x['mental'] == 'forgets' else 0
    risk = 'HIGH' if s >= 45 else 'MODERATE' if s >= 25 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 301,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 10,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 31,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 6,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 302,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 20,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 32,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 7,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'immobile',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 303,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 30,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'crutches',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 33,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 8,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 304,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 40,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 34,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 9,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 305,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 50,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 35,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 10,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    d = x['last_fall_days']
    fell = d is not None and d <= 90
    s = 25 if fell else 0
    s += 15 if x['secondary_dx'] else 0
    aid = x['aid']
    s += 30 if aid == 'furniture' else 15 if aid in ('crutches', 'cane', 'walker') else 0
    s += 20 if x['iv'] else 0
    g = x['gait']
    s += 20 if g == 'impaired' else 10 if g == 'weak' else 0
    s += 15 if x['mental'] in ('forgets', 'overestimate') else 0
    risk = 'HIGH' if s >= 45 else 'MODERATE' if s >= 25 else 'LOW'
    return {'score': s, 'risk': risk}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 301,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 10,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 31,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 6,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 302,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 20,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 32,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 7,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'immobile',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 303,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 30,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'crutches',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 33,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 8,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 304,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 40,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'cane',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 50, 'risk': 'HIGH'}),
  ('score exactly 25',
   {'last_fall_days': 34,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 9,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})],
 [('no risk factors',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'bedrest',
    'mental': 'oriented'},
   {'score': 0, 'risk': 'LOW'}),
  ('fall exactly 90 days ago',
   {'last_fall_days': 90,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('fall a year ago',
   {'last_fall_days': 305,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 20, 'risk': 'LOW'}),
  ('furniture walking',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'furniture',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('walker user',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'normal',
    'mental': 'forgets'},
   {'score': 45, 'risk': 'HIGH'}),
  ('weak gait',
   {'last_fall_days': None,
    'secondary_dx': False,
    'aid': 'cane',
    'iv': True,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'}),
  ('impaired gait',
   {'last_fall_days': 50,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'impaired',
    'mental': 'oriented'},
   {'score': 60, 'risk': 'HIGH'}),
  ('score exactly 40',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'walker',
    'iv': False,
    'gait': 'weak',
    'mental': 'oriented'},
   {'score': 40, 'risk': 'MODERATE'}),
  ('overestimates own ability',
   {'last_fall_days': None,
    'secondary_dx': True,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'overestimates'},
   {'score': 30, 'risk': 'MODERATE'}),
  ('score exactly 25',
   {'last_fall_days': 35,
    'secondary_dx': False,
    'aid': 'none',
    'iv': False,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 25, 'risk': 'MODERATE'}),
  ('score exactly 45',
   {'last_fall_days': 10,
    'secondary_dx': False,
    'aid': 'none',
    'iv': True,
    'gait': 'normal',
    'mental': 'oriented'},
   {'score': 45, 'risk': 'HIGH'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Patients who overestimate their own mobility receive no mental status points.

Input {last_fall_days (or null), secondary_dx, aid, iv, gait, mental}. Toy points: a fall within the last 90 days (inclusive) 25; secondary diagnosis 15; aid none/bedrest/nurse 0, crutches/cane/walker 15, furniture 30; IV access 20; gait normal/bedrest/immobile 0, weak 10, impaired 20; mental status "forgets" or "overestimates" (overestimates own ability) 15, "oriented" 0. Risk: 0-24 LOW, 25-44 MODERATE, >= 45 HIGH. Return {score, risk}.

split: open-access