broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e <= h * m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (a * (e - h * m))
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + a * h * ns)
    hump = (k - 1 / (a * h)) / 2 if h > 0 else -1.0
    if ns >= hump:
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None)],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('control: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]])]]
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
N = 1
observations = []
def solve(r, k, a, h, e, m):
    if min(r, k, a, e, m) <= 0 or h < 0:
        return None
    if e <= h * m:
        return ['predator-extinct', [float(k), 0.0]]
    ns = m / (a * (e - h * m))
    if ns >= k:
        return ['predator-extinct', [float(k), 0.0]]
    ps = r / a * (1 - ns / k) * (1 + a * h * ns)
    hump = (k - 1 / (a * h)) / 2 if h > 0 else -1.0
    if round(ns, 1) > round(hump, 1):
        kind = 'stable'
    elif ns == hump:
        kind = 'hopf'
    else:
        kind = 'cycles'
    return [kind, [round(ns, 6), round(ps, 6)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None)],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]]),
  ('control: type I predator', (0.8, 30.0, 0.2, 0.0, 0.5, 0.4), ['stable', [4.0, 3.466667]]),
  ('control: invalid rate', (0.0, 10.0, 1.0, 0.5, 1.5, 2.0), None),
  ('control: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: lynx hare like', (1.2, 60.0, 0.05, 0.2, 0.6, 0.3), ['stable', [11.111111, 21.728395]]),
  ('control: borderline conversion', (1.0, 20.0, 0.5, 0.5, 0.9, 1.6), ['predator-extinct', [20.0, 0.0]])],
 [('regression: exact hopf point', (1.0, 10.0, 1.0, 0.5, 1.5, 2.0), ['hopf', [4.0, 1.8]]),
  ('control: enriched cycles', (1.0, 40.0, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 2.7]]),
  ('control: poor habitat stable', (1.0, 8.0, 1.0, 0.5, 1.5, 2.0), ['stable', [4.0, 1.5]]),
  ('control: just above hump', (1.0, 10.06, 1.0, 0.5, 1.5, 2.0), ['cycles', [4.0, 1.807157]]),
  ('regression: just below enrichment threshold',
   (1.0, 9.94, 1.0, 0.5, 1.5, 2.0),
   ['stable', [4.0, 1.792757]]),
  ('control: inefficient predator', (1.0, 50.0, 1.0, 0.5, 1.0, 2.0), ['predator-extinct', [50.0, 0.0]]),
  ('control: predator cannot persist capacity',
   (1.0, 3.0, 1.0, 0.5, 1.5, 2.0),
   ['predator-extinct', [3.0, 0.0]])]]
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:
The exact Hopf bifurcation point is labelled stable.

Type II predator-prey: N* = m/(a(e-hm)) requires e>hm and N*<K else ['predator-extinct', [K, 0]]; P* = (r/a)(1-N*/K)(1+ahN*); hump = (K-1/(ah))/2 for h>0 else -1; stable if N*>hump, 'hopf' if equal, else 'cycles'; values rounded 6; None for invalid parameters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [math.log(counts[t + 1] / counts[t]) for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / q
    d = math.log(counts[-1] / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = math.sqrt(var * horizon)
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(-2 * mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [math.log(counts[t + 1] / counts[t]) for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / (q + 1)
    d = math.log(counts[-1] / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = math.sqrt(var * horizon)
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(-2 * mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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:
Environmental variance is underestimated, understating extinction risk.

Log growth increments ln(N[t+1]/N[t]); mu = mean, sigma^2 = sample variance (q-1); d = ln(N_last/threshold); d<=0 gives probability 1.0; zero variance gives 1.0 if mu*T <= -d else 0.0; otherwise P = Phi((-d-muT)/(s sqrtT)) + exp(-2 mu d/s^2) Phi((-d+muT)/(s sqrtT)) capped at 1; return [mu, var, P] rounded 6; None with fewer than three counts, non-positive counts or threshold.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [math.log(counts[t] / counts[t + 1]) for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / (q - 1)
    d = math.log(counts[-1] / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = math.sqrt(var * horizon)
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(-2 * mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('regression: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('regression: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('regression: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [(counts[t + 1] - counts[t]) / counts[t] for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / (q - 1)
    d = math.log(counts[-1] / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = math.sqrt(var * horizon)
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(-2 * mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('regression: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('regression: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('regression: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('regression: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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:
Declining populations appear to grow.

Log growth increments ln(N[t+1]/N[t]); mu = mean, sigma^2 = sample variance (q-1); d = ln(N_last/threshold); d<=0 gives probability 1.0; zero variance gives 1.0 if mu*T <= -d else 0.0; otherwise P = Phi((-d-muT)/(s sqrtT)) + exp(-2 mu d/s^2) Phi((-d+muT)/(s sqrtT)) capped at 1; return [mu, var, P] rounded 6; None with fewer than three counts, non-positive counts or threshold.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [math.log(counts[t + 1] / counts[t]) for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / (q - 1)
    d = math.log(counts[0] / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = math.sqrt(var * horizon)
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(-2 * mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [math.log(counts[t + 1] / counts[t]) for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / (q - 1)
    d = math.log(max(counts) / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = math.sqrt(var * horizon)
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(-2 * mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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:
Risk is computed from the first census rather than the current population.

Log growth increments ln(N[t+1]/N[t]); mu = mean, sigma^2 = sample variance (q-1); d = ln(N_last/threshold); d<=0 gives probability 1.0; zero variance gives 1.0 if mu*T <= -d else 0.0; otherwise P = Phi((-d-muT)/(s sqrtT)) + exp(-2 mu d/s^2) Phi((-d+muT)/(s sqrtT)) capped at 1; return [mu, var, P] rounded 6; None with fewer than three counts, non-positive counts or threshold.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [math.log(counts[t + 1] / counts[t]) for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / (q - 1)
    d = math.log(counts[-1] / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = math.sqrt(var * horizon)
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(2 * mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [math.log(counts[t + 1] / counts[t]) for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / (q - 1)
    d = math.log(counts[-1] / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = math.sqrt(var * horizon)
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(-mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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:
Growing populations receive inflated extinction probabilities.

Log growth increments ln(N[t+1]/N[t]); mu = mean, sigma^2 = sample variance (q-1); d = ln(N_last/threshold); d<=0 gives probability 1.0; zero variance gives 1.0 if mu*T <= -d else 0.0; otherwise P = Phi((-d-muT)/(s sqrtT)) + exp(-2 mu d/s^2) Phi((-d+muT)/(s sqrtT)) capped at 1; return [mu, var, P] rounded 6; None with fewer than three counts, non-positive counts or threshold.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [math.log(counts[t + 1] / counts[t]) for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / (q - 1)
    d = math.log(counts[-1] / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = math.sqrt(var) * horizon
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(-2 * mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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
N = 1
observations = []
def solve(counts, threshold, horizon):
    if len(counts) < 3 or min(counts) <= 0 or threshold <= 0:
        return None
    logs = [math.log(counts[t + 1] / counts[t]) for t in range(len(counts) - 1)]
    q = len(logs)
    mu = sum(logs) / q
    var = sum((x - mu) ** 2 for x in logs) / (q - 1)
    d = math.log(counts[-1] / threshold)
    if d <= 0:
        return [round(mu, 6), round(var, 6), 1.0]
    if var == 0:
        return [round(mu, 6), 0.0, 1.0 if mu * horizon <= -d else 0.0]
    sd = var * horizon
    phi = lambda z: 0.5 * (1 + math.erf(z / math.sqrt(2)))
    prob = phi((-d - mu * horizon) / sd) + math.exp(-2 * mu * d / var) * phi((-d + mu * horizon) / sd)
    return [round(mu, 6), round(var, 6), round(min(prob, 1.0), 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('regression: growing', ([30, 36, 40, 50, 55, 66], 10, 30), [0.157691, 0.003032, 0.0]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])],
 [('regression: grizzly census decline',
   ([45, 42, 44, 38, 36, 35, 31], 10, 20),
   [-0.062113, 0.004743, 0.688257]),
  ('regression: fluctuating stable', ([100, 120, 90, 110, 95, 105], 20, 50), [0.009758, 0.046826, 0.191687]),
  ('control: already below threshold', ([30, 20, 8], 10, 10), [-0.660878, 0.130471, 1.0]),
  ('control: constant decline', ([80, 40, 20], 5, 5), [-0.693147, 0.0, 1.0]),
  ('control: too short', ([10, 9], 5, 5), None),
  ('regression: high variance', ([200, 100, 260, 90, 300, 120], 30, 25), [-0.102165, 1.188964, 0.882919]),
  ('regression: peak then decline', ([60, 120, 80, 70, 65], 15, 40), [0.020011, 0.222192, 0.539603])]]
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:
Uncertainty grows linearly instead of with the square root of time.

Log growth increments ln(N[t+1]/N[t]); mu = mean, sigma^2 = sample variance (q-1); d = ln(N_last/threshold); d<=0 gives probability 1.0; zero variance gives 1.0 if mu*T <= -d else 0.0; otherwise P = Phi((-d-muT)/(s sqrtT)) + exp(-2 mu d/s^2) Phi((-d+muT)/(s sqrtT)) capped at 1; return [mu, var, P] rounded 6; None with fewer than three counts, non-positive counts or threshold.

split: open-access


prompt:
Loaded CG sits far forward of any realistic value while total weight looks right.

Input {'empty':[lb,in],'items':[[name,lb,in]],'fuel_gal','fuel_arm','fuel_type'}; fuel density 6.0 lb/gal for 100LL and 6.7 for JETA, other grades return 'ERR_FUEL_TYPE'; negative item weights are removals at that arm; return [total lb, total lb-in, CG in] rounded 1/1/2.

split: open-access


prompt:
Fuel weight is overstated for avgas aircraft and understated for diesel-converted aircraft.

Input {'empty':[lb,in],'items':[[name,lb,in]],'fuel_gal','fuel_arm','fuel_type'}; fuel density 6.0 lb/gal for 100LL and 6.7 for JETA, other grades return 'ERR_FUEL_TYPE'; negative item weights are removals at that arm; return [total lb, total lb-in, CG in] rounded 1/1/2.

split: open-access


prompt:
Adding fuel moves the computed CG forward even though the tanks are aft of the loaded CG.

Input {'empty':[lb,in],'items':[[name,lb,in]],'fuel_gal','fuel_arm','fuel_type'}; fuel density 6.0 lb/gal for 100LL and 6.7 for JETA, other grades return 'ERR_FUEL_TYPE'; negative item weights are removals at that arm; return [total lb, total lb-in, CG in] rounded 1/1/2.

split: open-access


prompt:
Aircraft with a removed seat or fairing report the as-equipped weight and CG.

Input {'empty':[lb,in],'items':[[name,lb,in]],'fuel_gal','fuel_arm','fuel_type'}; fuel density 6.0 lb/gal for 100LL and 6.7 for JETA, other grades return 'ERR_FUEL_TYPE'; negative item weights are removals at that arm; return [total lb, total lb-in, CG in] rounded 1/1/2.

split: open-access


prompt:
The reported CG is a hundredth of an inch forward of the computed value for many loads.

Input {'empty':[lb,in],'items':[[name,lb,in]],'fuel_gal','fuel_arm','fuel_type'}; fuel density 6.0 lb/gal for 100LL and 6.7 for JETA, other grades return 'ERR_FUEL_TYPE'; negative item weights are removals at that arm; return [total lb, total lb-in, CG in] rounded 1/1/2.

split: open-access


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

N = 1
observations = []
def solve(x):
    w, cg, cat = x
    if w < 1500: return 'ERR_BELOW_EMPTY'
    maxw = 2550 if cat == 'normal' else 2200
    if w > maxw: return 'OVERWEIGHT'
    if w <= 1950:
        fwd = 35.0
    else:
        fwd = 35.0 + (w - 1950) * (41.0 - 35.0) / (2550 - 1950)
    aft = 47.3 if cat == 'normal' else 40.5
    if cg <= fwd: return 'FWD'
    if cg > aft + 1e-9: return 'AFT'
    return 'IN'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mid-envelope normal', [2110, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2301, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.1, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.1, 'utility'], 'AFT'], ['below empty weight', [1499, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2415, 48.96, 'normal'], 'AFT'], ['sampled case 2', [2550, 34.9, 'normal'], 'FWD'], ['sampled case 3', [1950, 42.86, 'utility'], 'AFT'], ['regression: forward limit comparison', [2200, 37.88, 'normal'], 'IN']], [['mid-envelope normal', [2120, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2302, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.2, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.2, 'utility'], 'AFT'], ['below empty weight', [1498, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 37.89, 'utility'], 'IN'], ['sampled case 2', [2561, 48.01, 'normal'], 'OVERWEIGHT'], ['sampled case 3', [2550, 45.7, 'normal'], 'IN'], ['regression: forward limit comparison', [2200, 37.87, 'utility'], 'IN']], [['mid-envelope normal', [2130, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2303, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.3, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.3, 'utility'], 'AFT'], ['below empty weight', [1497, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 34.67, 'utility'], 'FWD'], ['sampled case 2', [1500, 42.58, 'utility'], 'AFT'], ['sampled case 3', [2200, 48.0, 'utility'], 'AFT'], ['regression: forward limit comparison', [2200, 37.5, 'utility'], 'IN']], [['mid-envelope normal', [2140, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2304, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.4, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.4, 'utility'], 'AFT'], ['below empty weight', [1496, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2200, 42.7, 'normal'], 'IN'], ['sampled case 2', [1969, 47.53, 'normal'], 'AFT'], ['sampled case 3', [1500, 48.2, 'normal'], 'AFT'], ['regression: forward limit comparison', [2200, 37.64, 'normal'], 'IN']], [['mid-envelope normal', [2150, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2305, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.5, 'normal'], 'IN'], ['aft of utility limit', [2100, 41.5, 'utility'], 'AFT'], ['below empty weight', [1495, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 45.06, 'normal'], 'IN'], ['sampled case 2', [2200, 43.63, 'utility'], 'AFT'], ['sampled case 3', [2200, 41.43, 'normal'], 'IN']]]
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):
    w, cg, cat = x
    if w < 1500: return 'ERR_BELOW_EMPTY'
    maxw = 2550 if cat == 'normal' else 2200
    if w > maxw: return 'OVERWEIGHT'
    if w <= 1950:
        fwd = 35.0
    else:
        fwd = 35.0 + (w - 1950) * (41.0 - 35.0) / (2550 - 1950)
    aft = 47.3 if cat == 'normal' else 40.5
    if cg < round(fwd): return 'FWD'
    if cg > aft + 1e-9: return 'AFT'
    return 'IN'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mid-envelope normal', [2110, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2301, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.1, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.1, 'utility'], 'AFT'], ['below empty weight', [1499, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2415, 48.96, 'normal'], 'AFT'], ['sampled case 2', [2550, 34.9, 'normal'], 'FWD'], ['sampled case 3', [1950, 42.86, 'utility'], 'AFT'], ['regression: forward limit comparison', [2200, 37.88, 'normal'], 'IN']], [['mid-envelope normal', [2120, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2302, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.2, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.2, 'utility'], 'AFT'], ['below empty weight', [1498, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 37.89, 'utility'], 'IN'], ['sampled case 2', [2561, 48.01, 'normal'], 'OVERWEIGHT'], ['sampled case 3', [2550, 45.7, 'normal'], 'IN'], ['regression: forward limit comparison', [2200, 37.87, 'utility'], 'IN']], [['mid-envelope normal', [2130, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2303, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.3, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.3, 'utility'], 'AFT'], ['below empty weight', [1497, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 34.67, 'utility'], 'FWD'], ['sampled case 2', [1500, 42.58, 'utility'], 'AFT'], ['sampled case 3', [2200, 48.0, 'utility'], 'AFT'], ['regression: forward limit comparison', [2200, 37.5, 'utility'], 'IN']], [['mid-envelope normal', [2140, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2304, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.4, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.4, 'utility'], 'AFT'], ['below empty weight', [1496, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2200, 42.7, 'normal'], 'IN'], ['sampled case 2', [1969, 47.53, 'normal'], 'AFT'], ['sampled case 3', [1500, 48.2, 'normal'], 'AFT'], ['regression: forward limit comparison', [2200, 37.64, 'normal'], 'IN']], [['mid-envelope normal', [2150, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2305, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.5, 'normal'], 'IN'], ['aft of utility limit', [2100, 41.5, 'utility'], 'AFT'], ['below empty weight', [1495, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 45.06, 'normal'], 'IN'], ['sampled case 2', [2200, 43.63, 'utility'], 'AFT'], ['sampled case 3', [2200, 41.43, 'normal'], 'IN']]]
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:
Loads placed precisely on the sloped forward boundary are reported FWD.

Input [weight lb, CG in, 'normal'|'utility']. Below 1500 lb -> 'ERR_BELOW_EMPTY'. Max weight 2550 normal / 2200 utility -> 'OVERWEIGHT' first. Forward limit 35.0 in up to 1950 lb then linear to 41.0 in at 2550 lb; aft limit 47.3 normal / 40.5 utility. Limits inclusive; else 'FWD','AFT','IN'.

split: open-access


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

N = 1
observations = []
def solve(x):
    w, cg, cat = x
    if w < 1500: return 'ERR_BELOW_EMPTY'
    maxw = 2550 if cat in ('normal', 'utility') else 2200
    if w > maxw: return 'OVERWEIGHT'
    if w <= 1950:
        fwd = 35.0
    else:
        fwd = 35.0 + (w - 1950) * (41.0 - 35.0) / (2550 - 1950)
    aft = 47.3 if cat == 'normal' else 40.5
    if cg < fwd - 1e-9: return 'FWD'
    if cg > aft + 1e-9: return 'AFT'
    return 'IN'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mid-envelope normal', [2110, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2301, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.1, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.1, 'utility'], 'AFT'], ['below empty weight', [1499, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2415, 48.96, 'normal'], 'AFT'], ['sampled case 2', [2550, 34.9, 'normal'], 'FWD'], ['sampled case 3', [1950, 42.86, 'utility'], 'AFT']], [['mid-envelope normal', [2120, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2302, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.2, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.2, 'utility'], 'AFT'], ['below empty weight', [1498, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 37.89, 'utility'], 'IN'], ['sampled case 2', [2561, 48.01, 'normal'], 'OVERWEIGHT'], ['sampled case 3', [2550, 45.7, 'normal'], 'IN']], [['mid-envelope normal', [2130, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2303, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.3, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.3, 'utility'], 'AFT'], ['below empty weight', [1497, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 34.67, 'utility'], 'FWD'], ['sampled case 2', [1500, 42.58, 'utility'], 'AFT'], ['sampled case 3', [2200, 48.0, 'utility'], 'AFT']], [['mid-envelope normal', [2140, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2304, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.4, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.4, 'utility'], 'AFT'], ['below empty weight', [1496, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2200, 42.7, 'normal'], 'IN'], ['sampled case 2', [1969, 47.53, 'normal'], 'AFT'], ['sampled case 3', [1500, 48.2, 'normal'], 'AFT']], [['mid-envelope normal', [2150, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2305, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.5, 'normal'], 'IN'], ['aft of utility limit', [2100, 41.5, 'utility'], 'AFT'], ['below empty weight', [1495, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 45.06, 'normal'], 'IN'], ['sampled case 2', [2200, 43.63, 'utility'], 'AFT'], ['sampled case 3', [2200, 41.43, 'normal'], 'IN']]]
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):
    w, cg, cat = x
    if w < 1500: return 'ERR_BELOW_EMPTY'
    maxw = 2550 if cat == 'normal' else 2200
    if w >= maxw: return 'OVERWEIGHT'
    if w <= 1950:
        fwd = 35.0
    else:
        fwd = 35.0 + (w - 1950) * (41.0 - 35.0) / (2550 - 1950)
    aft = 47.3 if cat == 'normal' else 40.5
    if cg < fwd - 1e-9: return 'FWD'
    if cg > aft + 1e-9: return 'AFT'
    return 'IN'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mid-envelope normal', [2110, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2301, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.1, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.1, 'utility'], 'AFT'], ['below empty weight', [1499, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2415, 48.96, 'normal'], 'AFT'], ['sampled case 2', [2550, 34.9, 'normal'], 'FWD'], ['sampled case 3', [1950, 42.86, 'utility'], 'AFT']], [['mid-envelope normal', [2120, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2302, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.2, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.2, 'utility'], 'AFT'], ['below empty weight', [1498, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 37.89, 'utility'], 'IN'], ['sampled case 2', [2561, 48.01, 'normal'], 'OVERWEIGHT'], ['sampled case 3', [2550, 45.7, 'normal'], 'IN']], [['mid-envelope normal', [2130, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2303, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.3, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.3, 'utility'], 'AFT'], ['below empty weight', [1497, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 34.67, 'utility'], 'FWD'], ['sampled case 2', [1500, 42.58, 'utility'], 'AFT'], ['sampled case 3', [2200, 48.0, 'utility'], 'AFT']], [['mid-envelope normal', [2140, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2304, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.4, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.4, 'utility'], 'AFT'], ['below empty weight', [1496, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2200, 42.7, 'normal'], 'IN'], ['sampled case 2', [1969, 47.53, 'normal'], 'AFT'], ['sampled case 3', [1500, 48.2, 'normal'], 'AFT']], [['mid-envelope normal', [2150, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2305, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.5, 'normal'], 'IN'], ['aft of utility limit', [2100, 41.5, 'utility'], 'AFT'], ['below empty weight', [1495, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 45.06, 'normal'], 'IN'], ['sampled case 2', [2200, 43.63, 'utility'], 'AFT'], ['sampled case 3', [2200, 41.43, 'normal'], 'IN']]]
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:
Utility-category flights between 2200 and 2550 lb are accepted and evaluated for CG.

Input [weight lb, CG in, 'normal'|'utility']. Below 1500 lb -> 'ERR_BELOW_EMPTY'. Max weight 2550 normal / 2200 utility -> 'OVERWEIGHT' first. Forward limit 35.0 in up to 1950 lb then linear to 41.0 in at 2550 lb; aft limit 47.3 normal / 40.5 utility. Limits inclusive; else 'FWD','AFT','IN'.

split: open-access


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

N = 1
observations = []
def solve(x):
    w, cg, cat = x
    if w < 1500: return 'ERR_BELOW_EMPTY'
    maxw = 2550 if cat == 'normal' else 2200
    if w > maxw: return 'OVERWEIGHT'
    if w <= 1950:
        fwd = 35.0
    else:
        fwd = 35.0 + (2550 - w) * (41.0 - 35.0) / (2550 - 1950)
    aft = 47.3 if cat == 'normal' else 40.5
    if cg < fwd - 1e-9: return 'FWD'
    if cg > aft + 1e-9: return 'AFT'
    return 'IN'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mid-envelope normal', [2110, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2301, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.1, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.1, 'utility'], 'AFT'], ['below empty weight', [1499, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2415, 48.96, 'normal'], 'AFT'], ['sampled case 2', [2550, 34.9, 'normal'], 'FWD'], ['sampled case 3', [1950, 42.86, 'utility'], 'AFT']], [['mid-envelope normal', [2120, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2302, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.2, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.2, 'utility'], 'AFT'], ['below empty weight', [1498, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 37.89, 'utility'], 'IN'], ['sampled case 2', [2561, 48.01, 'normal'], 'OVERWEIGHT'], ['sampled case 3', [2550, 45.7, 'normal'], 'IN']], [['mid-envelope normal', [2130, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2303, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.3, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.3, 'utility'], 'AFT'], ['below empty weight', [1497, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 34.67, 'utility'], 'FWD'], ['sampled case 2', [1500, 42.58, 'utility'], 'AFT'], ['sampled case 3', [2200, 48.0, 'utility'], 'AFT']], [['mid-envelope normal', [2140, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2304, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.4, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.4, 'utility'], 'AFT'], ['below empty weight', [1496, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2200, 42.7, 'normal'], 'IN'], ['sampled case 2', [1969, 47.53, 'normal'], 'AFT'], ['sampled case 3', [1500, 48.2, 'normal'], 'AFT']], [['mid-envelope normal', [2150, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2305, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.5, 'normal'], 'IN'], ['aft of utility limit', [2100, 41.5, 'utility'], 'AFT'], ['below empty weight', [1495, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 45.06, 'normal'], 'IN'], ['sampled case 2', [2200, 43.63, 'utility'], 'AFT'], ['sampled case 3', [2200, 41.43, 'normal'], 'IN'], ['regression: forward limit interpolation', [2200, 37.9, 'utility'], 'IN']]]
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):
    w, cg, cat = x
    if w < 1500: return 'ERR_BELOW_EMPTY'
    maxw = 2550 if cat == 'normal' else 2200
    if w > maxw: return 'OVERWEIGHT'
    if w <= 1950:
        fwd = 35.0
    else:
        fwd = 35.0 + (w - 1500) * (41.0 - 35.0) / (2550 - 1950)
    aft = 47.3 if cat == 'normal' else 40.5
    if cg < fwd - 1e-9: return 'FWD'
    if cg > aft + 1e-9: return 'AFT'
    return 'IN'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mid-envelope normal', [2110, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2301, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.1, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.1, 'utility'], 'AFT'], ['below empty weight', [1499, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2415, 48.96, 'normal'], 'AFT'], ['sampled case 2', [2550, 34.9, 'normal'], 'FWD'], ['sampled case 3', [1950, 42.86, 'utility'], 'AFT']], [['mid-envelope normal', [2120, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2302, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.2, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.2, 'utility'], 'AFT'], ['below empty weight', [1498, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 37.89, 'utility'], 'IN'], ['sampled case 2', [2561, 48.01, 'normal'], 'OVERWEIGHT'], ['sampled case 3', [2550, 45.7, 'normal'], 'IN']], [['mid-envelope normal', [2130, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2303, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.3, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.3, 'utility'], 'AFT'], ['below empty weight', [1497, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 34.67, 'utility'], 'FWD'], ['sampled case 2', [1500, 42.58, 'utility'], 'AFT'], ['sampled case 3', [2200, 48.0, 'utility'], 'AFT']], [['mid-envelope normal', [2140, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2304, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.4, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.4, 'utility'], 'AFT'], ['below empty weight', [1496, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2200, 42.7, 'normal'], 'IN'], ['sampled case 2', [1969, 47.53, 'normal'], 'AFT'], ['sampled case 3', [1500, 48.2, 'normal'], 'AFT']], [['mid-envelope normal', [2150, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2305, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.5, 'normal'], 'IN'], ['aft of utility limit', [2100, 41.5, 'utility'], 'AFT'], ['below empty weight', [1495, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 45.06, 'normal'], 'IN'], ['sampled case 2', [2200, 43.63, 'utility'], 'AFT'], ['sampled case 3', [2200, 41.43, 'normal'], 'IN'], ['regression: forward limit interpolation', [2200, 37.9, 'utility'], 'IN']]]
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:
Heavy aircraft get a forward limit near 35 in and light aircraft near 41 in on the sloped segment.

Input [weight lb, CG in, 'normal'|'utility']. Below 1500 lb -> 'ERR_BELOW_EMPTY'. Max weight 2550 normal / 2200 utility -> 'OVERWEIGHT' first. Forward limit 35.0 in up to 1950 lb then linear to 41.0 in at 2550 lb; aft limit 47.3 normal / 40.5 utility. Limits inclusive; else 'FWD','AFT','IN'.

split: open-access


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

N = 1
observations = []
def solve(x):
    w, cg, cat = x
    if w < 1500: return 'ERR_BELOW_EMPTY'
    maxw = 2550 if cat == 'normal' else 2200
    if w > maxw: return 'OVERWEIGHT'
    if w <= 1950:
        fwd = 35.0
    else:
        fwd = 35.0 + (w - 1950) * (41.0 - 35.0) / (2550 - 1950)
    aft = 47.3
    if cg < fwd - 1e-9: return 'FWD'
    if cg > aft + 1e-9: return 'AFT'
    return 'IN'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mid-envelope normal', [2110, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2301, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.1, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.1, 'utility'], 'AFT'], ['below empty weight', [1499, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2415, 48.96, 'normal'], 'AFT'], ['sampled case 2', [2550, 34.9, 'normal'], 'FWD'], ['sampled case 3', [1950, 42.86, 'utility'], 'AFT']], [['mid-envelope normal', [2120, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2302, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.2, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.2, 'utility'], 'AFT'], ['below empty weight', [1498, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 37.89, 'utility'], 'IN'], ['sampled case 2', [2561, 48.01, 'normal'], 'OVERWEIGHT'], ['sampled case 3', [2550, 45.7, 'normal'], 'IN']], [['mid-envelope normal', [2130, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2303, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.3, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.3, 'utility'], 'AFT'], ['below empty weight', [1497, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 34.67, 'utility'], 'FWD'], ['sampled case 2', [1500, 42.58, 'utility'], 'AFT'], ['sampled case 3', [2200, 48.0, 'utility'], 'AFT']], [['mid-envelope normal', [2140, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2304, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.4, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.4, 'utility'], 'AFT'], ['below empty weight', [1496, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2200, 42.7, 'normal'], 'IN'], ['sampled case 2', [1969, 47.53, 'normal'], 'AFT'], ['sampled case 3', [1500, 48.2, 'normal'], 'AFT']], [['mid-envelope normal', [2150, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2305, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.5, 'normal'], 'IN'], ['aft of utility limit', [2100, 41.5, 'utility'], 'AFT'], ['below empty weight', [1495, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 45.06, 'normal'], 'IN'], ['sampled case 2', [2200, 43.63, 'utility'], 'AFT'], ['sampled case 3', [2200, 41.43, 'normal'], 'IN']]]
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):
    w, cg, cat = x
    if w < 1500: return 'ERR_BELOW_EMPTY'
    maxw = 2550 if cat == 'normal' else 2200
    if w > maxw: return 'OVERWEIGHT'
    if w <= 1950:
        fwd = 35.0
    else:
        fwd = 35.0 + (w - 1950) * (41.0 - 35.0) / (2550 - 1950)
    aft = 40.5 if w <= 2200 else 47.3
    if cg < fwd - 1e-9: return 'FWD'
    if cg > aft + 1e-9: return 'AFT'
    return 'IN'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['mid-envelope normal', [2110, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2301, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.1, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.1, 'utility'], 'AFT'], ['below empty weight', [1499, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2415, 48.96, 'normal'], 'AFT'], ['sampled case 2', [2550, 34.9, 'normal'], 'FWD'], ['sampled case 3', [1950, 42.86, 'utility'], 'AFT']], [['mid-envelope normal', [2120, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2302, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.2, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.2, 'utility'], 'AFT'], ['below empty weight', [1498, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 37.89, 'utility'], 'IN'], ['sampled case 2', [2561, 48.01, 'normal'], 'OVERWEIGHT'], ['sampled case 3', [2550, 45.7, 'normal'], 'IN']], [['mid-envelope normal', [2130, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2303, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.3, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.3, 'utility'], 'AFT'], ['below empty weight', [1497, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 34.67, 'utility'], 'FWD'], ['sampled case 2', [1500, 42.58, 'utility'], 'AFT'], ['sampled case 3', [2200, 48.0, 'utility'], 'AFT']], [['mid-envelope normal', [2140, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2304, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.4, 'normal'], 'FWD'], ['aft of utility limit', [2100, 41.4, 'utility'], 'AFT'], ['below empty weight', [1496, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [2200, 42.7, 'normal'], 'IN'], ['sampled case 2', [1969, 47.53, 'normal'], 'AFT'], ['sampled case 3', [1500, 48.2, 'normal'], 'AFT']], [['mid-envelope normal', [2150, 42.0, 'normal'], 'IN'], ['on sloped forward line', [2250, 38.0, 'normal'], 'IN'], ['on aft limit utility', [2000, 40.5, 'utility'], 'IN'], ['utility overweight but normal legal', [2305, 42.0, 'utility'], 'OVERWEIGHT'], ['exactly max gross normal', [2550, 41.0, 'normal'], 'IN'], ['forward of sloped line', [2400, 39.5, 'normal'], 'IN'], ['aft of utility limit', [2100, 41.5, 'utility'], 'AFT'], ['below empty weight', [1495, 40.0, 'normal'], 'ERR_BELOW_EMPTY'], ['exactly empty weight', [1500, 36.0, 'utility'], 'IN'], ['sampled case 1', [1950, 45.06, 'normal'], 'IN'], ['sampled case 2', [2200, 43.63, 'utility'], 'AFT'], ['sampled case 3', [2200, 41.43, 'normal'], 'IN']]]
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:
Utility-category loads well aft of 40.5 in are reported IN.

Input [weight lb, CG in, 'normal'|'utility']. Below 1500 lb -> 'ERR_BELOW_EMPTY'. Max weight 2550 normal / 2200 utility -> 'OVERWEIGHT' first. Forward limit 35.0 in up to 1950 lb then linear to 41.0 in at 2550 lb; aft limit 47.3 normal / 40.5 utility. Limits inclusive; else 'FWD','AFT','IN'.

split: open-access