broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    items = [('appearance', ['normal', 'thirsty_restless', 'drowsy_limp']), ('eyes', ['normal', 'slightly_sunken', 'very_sunken']),
             ('mucous', ['moist', 'sticky', 'dry']), ('tears', ['present', 'decreased', 'absent'])]
    s = sum(opts.index(x[k]) for k, opts in items)
    cat = 'NONE' if s == 0 else 'SOME' if s < 4 else 'MODERATE_SEVERE'
    w = x['weight_loss_pct']
    if w is not None:
        w = Fraction(str(w))
        if w >= 10:
            cat = 'MODERATE_SEVERE'
        elif w >= 3 and cat == 'NONE':
            cat = 'SOME'
    return {'score': s, 'category': cat}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '11'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.1'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.1'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '12'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.2'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.2'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '0'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '13'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.3'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.3'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '14'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.4'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.4'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '15'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.5'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.5'},
   {'score': 0, 'category': 'SOME'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    items = [('appearance', ['normal', 'thirsty_restless', 'drowsy_limp']), ('eyes', ['normal', 'slightly_sunken', 'very_sunken']),
             ('mucous', ['moist', 'sticky', 'dry']), ('tears', ['present', 'decreased', 'absent'])]
    s = sum(opts.index(x[k]) for k, opts in items)
    cat = 'NONE' if s == 0 else 'SOME' if s <= 5 else 'MODERATE_SEVERE'
    w = x['weight_loss_pct']
    if w is not None:
        w = Fraction(str(w))
        if w >= 10:
            cat = 'MODERATE_SEVERE'
        elif w >= 3 and cat == 'NONE':
            cat = 'SOME'
    return {'score': s, 'category': cat}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '11'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.1'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.1'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '12'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.2'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.2'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '0'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '13'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.3'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.3'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '14'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.4'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.4'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '15'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.5'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.5'},
   {'score': 0, 'category': 'SOME'})]]
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 exactly 4 is reported as moderate-severe.

Input {appearance (normal|thirsty_restless|drowsy_limp), eyes (normal|slightly_sunken|very_sunken), mucous (moist|sticky|dry), tears (present|decreased|absent), weight_loss_pct (or null)}. Items score 0/1/2 in the listed order. Category: 0 NONE, 1-4 SOME, 5-8 MODERATE_SEVERE. A measured weight loss >= 10% forces MODERATE_SEVERE; >= 3% raises NONE to SOME but never lowers a category. Return {score, category}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    items = [('appearance', ['normal', 'thirsty_restless', 'drowsy_limp']), ('eyes', ['normal', 'slightly_sunken', 'very_sunken']),
             ('mucous', ['moist', 'sticky', 'dry']), ('tears', ['present', 'decreased', 'absent'])]
    s = sum(opts.index(x[k]) for k, opts in items)
    cat = 'NONE' if s == 0 else 'SOME' if s <= 4 else 'MODERATE_SEVERE'
    w = x['weight_loss_pct']
    if w is not None:
        w = Fraction(str(w))
        if w > 10:
            cat = 'MODERATE_SEVERE'
        elif w >= 3 and cat == 'NONE':
            cat = 'SOME'
    return {'score': s, 'category': cat}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '11'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.1'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.1'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '12'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.2'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.2'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '0'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '13'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.3'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.3'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '14'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.4'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.4'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '15'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.5'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.5'},
   {'score': 0, 'category': 'SOME'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    items = [('appearance', ['normal', 'thirsty_restless', 'drowsy_limp']), ('eyes', ['normal', 'slightly_sunken', 'very_sunken']),
             ('mucous', ['moist', 'sticky', 'dry']), ('tears', ['present', 'decreased', 'absent'])]
    s = sum(opts.index(x[k]) for k, opts in items)
    cat = 'NONE' if s == 0 else 'SOME' if s <= 4 else 'MODERATE_SEVERE'
    w = x['weight_loss_pct']
    if w is not None:
        w = Fraction(str(w))
        if w >= 10 and s >= 1:
            cat = 'MODERATE_SEVERE'
        elif w >= 3 and cat == 'NONE':
            cat = 'SOME'
    return {'score': s, 'category': cat}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '11'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.1'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.1'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '12'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.2'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.2'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '0'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '13'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.3'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.3'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '14'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.4'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.4'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '15'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.5'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.5'},
   {'score': 0, 'category': 'SOME'})]]
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 measured 10% weight loss does not force the severe category.

Input {appearance (normal|thirsty_restless|drowsy_limp), eyes (normal|slightly_sunken|very_sunken), mucous (moist|sticky|dry), tears (present|decreased|absent), weight_loss_pct (or null)}. Items score 0/1/2 in the listed order. Category: 0 NONE, 1-4 SOME, 5-8 MODERATE_SEVERE. A measured weight loss >= 10% forces MODERATE_SEVERE; >= 3% raises NONE to SOME but never lowers a category. Return {score, category}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    items = [('appearance', ['normal', 'thirsty_restless', 'drowsy_limp']), ('eyes', ['normal', 'slightly_sunken', 'very_sunken']),
             ('mucous', ['moist', 'sticky', 'dry']), ('tears', ['present', 'decreased', 'absent'])]
    s = sum(opts.index(x[k]) for k, opts in items)
    cat = 'NONE' if s == 0 else 'SOME' if s <= 4 else 'MODERATE_SEVERE'
    w = x['weight_loss_pct']
    if w is not None:
        w = Fraction(str(w))
        if w >= 10:
            cat = 'MODERATE_SEVERE'
        elif w >= 3:
            cat = 'SOME'
    return {'score': s, 'category': cat}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '11'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.1'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.1'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '12'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.2'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.2'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '0'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '13'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.3'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.3'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '14'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.4'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.4'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '15'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.5'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.5'},
   {'score': 0, 'category': 'SOME'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    items = [('appearance', ['normal', 'thirsty_restless', 'drowsy_limp']), ('eyes', ['normal', 'slightly_sunken', 'very_sunken']),
             ('mucous', ['moist', 'sticky', 'dry']), ('tears', ['present', 'decreased', 'absent'])]
    s = sum(opts.index(x[k]) for k, opts in items)
    cat = 'NONE' if s == 0 else 'SOME' if s <= 4 else 'MODERATE_SEVERE'
    w = x['weight_loss_pct']
    if w is not None:
        w = Fraction(str(w))
        if w >= 10:
            cat = 'MODERATE_SEVERE'
        elif w >= 3 and cat != 'MODERATE_SEVERE' and s > 0:
            cat = 'SOME'
    return {'score': s, 'category': cat}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '11'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.1'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.1'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '12'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.2'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.2'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '0'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '13'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.3'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.3'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '14'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.4'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.4'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '15'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.5'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.5'},
   {'score': 0, 'category': 'SOME'})]]
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 severely dehydrated child with 4% weight loss is downgraded to SOME.

Input {appearance (normal|thirsty_restless|drowsy_limp), eyes (normal|slightly_sunken|very_sunken), mucous (moist|sticky|dry), tears (present|decreased|absent), weight_loss_pct (or null)}. Items score 0/1/2 in the listed order. Category: 0 NONE, 1-4 SOME, 5-8 MODERATE_SEVERE. A measured weight loss >= 10% forces MODERATE_SEVERE; >= 3% raises NONE to SOME but never lowers a category. Return {score, category}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    items = [('appearance', ['normal', 'thirsty_restless', 'drowsy_limp']), ('eyes', ['normal', 'slightly_sunken', 'very_sunken']),
             ('mucous', ['moist', 'sticky', 'dry']), ('tears', ['present', 'absent', 'decreased'])]
    s = sum(opts.index(x[k]) for k, opts in items)
    cat = 'NONE' if s == 0 else 'SOME' if s <= 4 else 'MODERATE_SEVERE'
    w = x['weight_loss_pct']
    if w is not None:
        w = Fraction(str(w))
        if w >= 10:
            cat = 'MODERATE_SEVERE'
        elif w >= 3 and cat == 'NONE':
            cat = 'SOME'
    return {'score': s, 'category': cat}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '11'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.1'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.1'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '12'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.2'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.2'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '0'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '13'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.3'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.3'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '14'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.4'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.4'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '15'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.5'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.5'},
   {'score': 0, 'category': 'SOME'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    items = [('appearance', ['normal', 'thirsty_restless', 'drowsy_limp']), ('eyes', ['normal', 'slightly_sunken', 'very_sunken']),
             ('mucous', ['moist', 'sticky', 'dry']), ('tears', ['absent', 'decreased', 'present'])]
    s = sum(opts.index(x[k]) for k, opts in items)
    cat = 'NONE' if s == 0 else 'SOME' if s <= 4 else 'MODERATE_SEVERE'
    w = x['weight_loss_pct']
    if w is not None:
        w = Fraction(str(w))
        if w >= 10:
            cat = 'MODERATE_SEVERE'
        elif w >= 3 and cat == 'NONE':
            cat = 'SOME'
    return {'score': s, 'category': cat}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '11'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.1'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.1'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '12'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.2'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.2'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '0'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '13'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.3'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.3'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '1'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 1, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '14'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.4'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.4'},
   {'score': 0, 'category': 'SOME'})],
 [('well child',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '2'},
   {'score': 0, 'category': 'NONE'}),
  ('score exactly 4',
   {'appearance': 'thirsty_restless',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 4, 'category': 'SOME'}),
  ('score exactly 5',
   {'appearance': 'drowsy_limp',
    'eyes': 'slightly_sunken',
    'mucous': 'sticky',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 5, 'category': 'MODERATE_SEVERE'}),
  ('tears absent only',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'sticky', 'tears': 'absent', 'weight_loss_pct': None},
   {'score': 3, 'category': 'SOME'}),
  ('tears decreased only',
   {'appearance': 'normal',
    'eyes': 'slightly_sunken',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': None},
   {'score': 2, 'category': 'SOME'}),
  ('weight loss exactly 10 percent',
   {'appearance': 'thirsty_restless',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'decreased',
    'weight_loss_pct': '10'},
   {'score': 2, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 10 percent no signs',
   {'appearance': 'normal', 'eyes': 'normal', 'mucous': 'moist', 'tears': 'present', 'weight_loss_pct': '15'},
   {'score': 0, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 4 percent with severe signs',
   {'appearance': 'drowsy_limp',
    'eyes': 'very_sunken',
    'mucous': 'dry',
    'tears': 'absent',
    'weight_loss_pct': '4.5'},
   {'score': 8, 'category': 'MODERATE_SEVERE'}),
  ('weight loss 3 percent without signs',
   {'appearance': 'normal',
    'eyes': 'normal',
    'mucous': 'moist',
    'tears': 'present',
    'weight_loss_pct': '3.5'},
   {'score': 0, 'category': 'SOME'})]]
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:
Absent tears score 1 and decreased tears score 2.

Input {appearance (normal|thirsty_restless|drowsy_limp), eyes (normal|slightly_sunken|very_sunken), mucous (moist|sticky|dry), tears (present|decreased|absent), weight_loss_pct (or null)}. Items score 0/1/2 in the listed order. Category: 0 NONE, 1-4 SOME, 5-8 MODERATE_SEVERE. A measured weight loss >= 10% forces MODERATE_SEVERE; >= 3% raises NONE to SOME but never lowers a category. Return {score, category}.

split: open-access