broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values, k):
    return str(Fraction(sum(values[k:len(values)-k]),len(values)-2*k)) if len(values)>2*k else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([100, 1, 2, 3, 4], 1)', solve(*([100, 1, 2, 3, 4], 1)), '3')
check('fixture 2: ([1, 2, 3], 0)', solve(*([1, 2, 3], 0)), '2')
check('fixture 3: ([1, 2], 1)', solve(*([1, 2], 1)), None)
check('fixture 4: ([5, 5, 5, 5], 1)', solve(*([5, 5, 5, 5], 1)), '5')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values, k):
    return str(Fraction(sum(sorted(values)[k:]),len(values)-k)) if len(values)>k else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([100, 1, 2, 3, 4], 1)', solve(*([100, 1, 2, 3, 4], 1)), '3')
check('fixture 2: ([1, 2, 3], 0)', solve(*([1, 2, 3], 0)), '2')
check('fixture 3: ([1, 2], 1)', solve(*([1, 2], 1)), None)
check('fixture 4: ([5, 5, 5, 5], 1)', solve(*([5, 5, 5, 5], 1)), '5')
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:
Trimming arrival order does not remove the extremes.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. k>=0; sort and remove exactly k values from each tail, returning None if no values remain. Exact operational definition: str(Fraction(sum(sorted(values)[k:len(values)-k]),len(values)-2*k)) if len(values)>2*k else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values, k):
    return sorted(values)[k:len(values)-k]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([100, 1, 2, 3, 4], 1)', solve(*([100, 1, 2, 3, 4], 1)), [4, 2, 2, 3, 4])
check('fixture 2: ([1, 2, 3], 0)', solve(*([1, 2, 3], 0)), [1, 2, 3])
check('fixture 3: ([5, 5, 5], 1)', solve(*([5, 5, 5], 1)), [5, 5, 5])
check('fixture 4: ([0, 10, 20, 30, 40], 1)', solve(*([0, 10, 20, 30, 40], 1)), [10, 10, 20, 30, 30])
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values, k):
    return [max(sorted(values)[k],v) for v in values]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([100, 1, 2, 3, 4], 1)', solve(*([100, 1, 2, 3, 4], 1)), [4, 2, 2, 3, 4])
check('fixture 2: ([1, 2, 3], 0)', solve(*([1, 2, 3], 0)), [1, 2, 3])
check('fixture 3: ([5, 5, 5], 1)', solve(*([5, 5, 5], 1)), [5, 5, 5])
check('fixture 4: ([0, 10, 20, 30, 40], 1)', solve(*([0, 10, 20, 30, 40], 1)), [10, 10, 20, 30, 30])
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:
Trimming removes observations instead of replacing extreme values.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. 0<=2*k<len(values); replace extremes by kth and (n-k-1)th sorted observations, preserving input order and length. Exact operational definition: [max(sorted(values)[k],min(sorted(values)[-k-1],v)) for v in values]

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y):
    return str(Fraction(sum(a*b for a,b in zip(x,y)),len(x))) if x else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [2, 4, 6])', solve(*([1, 2, 3], [2, 4, 6])), '4/3')
check('fixture 2: ([2, 2], [1, 3])', solve(*([2, 2], [1, 3])), '0')
check('fixture 3: ([1, 2], [2, 1])', solve(*([1, 2], [2, 1])), '-1/4')
check('fixture 4: ([], [])', solve(*([], [])), None)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y):
    return str((Fraction(sum(a*b for a,b in zip(x,y)),len(x))-Fraction(sum(x)*sum(y),len(x)**2))*len(x)/(len(x)-1)) if len(x)>1 else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [2, 4, 6])', solve(*([1, 2, 3], [2, 4, 6])), '4/3')
check('fixture 2: ([2, 2], [1, 3])', solve(*([2, 2], [1, 3])), '0')
check('fixture 3: ([1, 2], [2, 1])', solve(*([1, 2], [2, 1])), '-1/4')
check('fixture 4: ([], [])', solve(*([], [])), None)
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 cross moment is not centered by both means.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Population covariance rational. Exact operational definition: str(Fraction(sum(a*b for a,b in zip(x,y)),len(x))-Fraction(sum(x)*sum(y),len(x)**2)) if x else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y):
    return str((Fraction(sum(a*b for a,b in zip(x,y)))-Fraction(sum(x)*sum(y),len(x)))/len(x)) if x else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [2, 4, 6])', solve(*([1, 2, 3], [2, 4, 6])), '2')
check('fixture 2: ([2, 2], [1, 3])', solve(*([2, 2], [1, 3])), '0')
check('fixture 3: ([1, 2], [2, 1])', solve(*([1, 2], [2, 1])), '-1/2')
check('fixture 4: ([1], [2])', solve(*([1], [2])), None)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y):
    return str(Fraction(sum(a*b for a,b in zip(x,y)),len(x)-1)) if len(x)>1 else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [2, 4, 6])', solve(*([1, 2, 3], [2, 4, 6])), '2')
check('fixture 2: ([2, 2], [1, 3])', solve(*([2, 2], [1, 3])), '0')
check('fixture 3: ([1, 2], [2, 1])', solve(*([1, 2], [2, 1])), '-1/2')
check('fixture 4: ([1], [2])', solve(*([1], [2])), None)
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 population divisor omits Bessel correction.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Return None for fewer than two paired observations; otherwise normalize centered products by n-1. Exact operational definition: str((Fraction(sum(a*b for a,b in zip(x,y)))-Fraction(sum(x)*sum(y),len(x)))/(len(x)-1)) if len(x)>1 else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y):
    return str(Fraction(sum(y),sum(x))) if sum(x) else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [3, 5, 7])', solve(*([1, 2, 3], [3, 5, 7])), '2')
check('fixture 2: ([1, 2, 3], [3, 2, 1])', solve(*([1, 2, 3], [3, 2, 1])), '-1')
check('fixture 3: ([1, 1], [2, 3])', solve(*([1, 1], [2, 3])), None)
check('fixture 4: ([0, 1], [2, 2])', solve(*([0, 1], [2, 2])), '0')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y):
    return str(Fraction(len(x)*sum(a*b for a,b in zip(x,y))-sum(x)*sum(y),len(x)*sum(b*b for b in y)-sum(y)**2)) if len(x)*sum(b*b for b in y)!=sum(y)**2 else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [3, 5, 7])', solve(*([1, 2, 3], [3, 5, 7])), '2')
check('fixture 2: ([1, 2, 3], [3, 2, 1])', solve(*([1, 2, 3], [3, 2, 1])), '-1')
check('fixture 3: ([1, 1], [2, 3])', solve(*([1, 1], [2, 3])), None)
check('fixture 4: ([0, 1], [2, 2])', solve(*([0, 1], [2, 2])), '0')
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 ratio of means incorrectly forces the fitted line through zero.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Fit y=intercept+slope*x by least squares; return None when x variance is zero, including empty input. Exact operational definition: str(Fraction(len(x)*sum(a*b for a,b in zip(x,y))-sum(x)*sum(y),len(x)*sum(a*a for a in x)-sum(x)**2)) if len(x)*sum(a*a for a in x)!=sum(x)**2 else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y, slope):
    return str(Fraction(sum(y),len(y)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [3, 5, 7], 2)', solve(*([1, 2, 3], [3, 5, 7], 2)), '1')
check('fixture 2: ([0, 1], [2, 2], 0)', solve(*([0, 1], [2, 2], 0)), '2')
check('fixture 3: ([1, 2], [3, 2], -1)', solve(*([1, 2], [3, 2], -1)), '4')
check('fixture 4: ([-1, 1], [-2, 2], 2)', solve(*([-1, 1], [-2, 2], 2)), '0')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y, slope):
    return str(Fraction(sum(y),len(y))+slope*Fraction(sum(x),len(x)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [3, 5, 7], 2)', solve(*([1, 2, 3], [3, 5, 7], 2)), '1')
check('fixture 2: ([0, 1], [2, 2], 0)', solve(*([0, 1], [2, 2], 0)), '2')
check('fixture 3: ([1, 2], [3, 2], -1)', solve(*([1, 2], [3, 2], -1)), '4')
check('fixture 4: ([-1, 1], [-2, 2], 2)', solve(*([-1, 1], [-2, 2], 2)), '0')
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 sample mean is returned without removing the slope contribution.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Nonempty paired samples and an integer slope are provided; return the intercept making the mean residual zero. Exact operational definition: str(Fraction(sum(y),len(y))-slope*Fraction(sum(x),len(x)))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(actual, predicted):
    return str(Fraction(sum((a-p)**2 for a,p in zip(actual,predicted)),sum((Fraction(a)-Fraction(sum(actual),len(actual)))**2 for a in actual)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [1, 2, 3])', solve(*([1, 2, 3], [1, 2, 3])), '1')
check('fixture 2: ([1, 2, 3], [2, 2, 2])', solve(*([1, 2, 3], [2, 2, 2])), '0')
check('fixture 3: ([1, 2, 3], [4, 4, 4])', solve(*([1, 2, 3], [4, 4, 4])), '-6')
check('fixture 4: ([0, 2], [0, 0])', solve(*([0, 2], [0, 0])), '-1')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(actual, predicted):
    return str(max(0,1-Fraction(sum((a-p)**2 for a,p in zip(actual,predicted)),sum((Fraction(a)-Fraction(sum(actual),len(actual)))**2 for a in actual))))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [1, 2, 3])', solve(*([1, 2, 3], [1, 2, 3])), '1')
check('fixture 2: ([1, 2, 3], [2, 2, 2])', solve(*([1, 2, 3], [2, 2, 2])), '0')
check('fixture 3: ([1, 2, 3], [4, 4, 4])', solve(*([1, 2, 3], [4, 4, 4])), '-6')
check('fixture 4: ([0, 2], [0, 0])', solve(*([0, 2], [0, 0])), '-1')
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:
Residual fraction is returned instead of explained fraction.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Nonempty actual observations have positive variance; R squared may be negative and is not clamped. Exact operational definition: str(1-Fraction(sum((a-p)**2 for a,p in zip(actual,predicted)),sum((Fraction(a)-Fraction(sum(actual),len(actual)))**2 for a in actual)))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(actual, predicted):
    return str(abs(Fraction(sum(a-p for a,p in zip(actual,predicted)),len(actual))))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 3], [2, 2])', solve(*([1, 3], [2, 2])), '1')
check('fixture 2: ([0, 0], [2, -2])', solve(*([0, 0], [2, -2])), '2')
check('fixture 3: ([1], [1])', solve(*([1], [1])), '0')
check('fixture 4: ([1, 2, 3], [1, 2, 6])', solve(*([1, 2, 3], [1, 2, 6])), '1')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(actual, predicted):
    return str(Fraction(sum((a-p)**2 for a,p in zip(actual,predicted)),len(actual)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 3], [2, 2])', solve(*([1, 3], [2, 2])), '1')
check('fixture 2: ([0, 0], [2, -2])', solve(*([0, 0], [2, -2])), '2')
check('fixture 3: ([1], [1])', solve(*([1], [1])), '0')
check('fixture 4: ([1, 2, 3], [1, 2, 6])', solve(*([1, 2, 3], [1, 2, 6])), '1')
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:
Opposite errors cancel before absolute value is applied.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Paired arrays are nonempty; average absolute prediction residuals. Exact operational definition: str(Fraction(sum(abs(a-p) for a,p in zip(actual,predicted)),len(actual)))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(actual, predicted):
    return str(Fraction(sum(a-p for a,p in zip(actual,predicted)),len(actual))**2)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 3], [2, 2])', solve(*([1, 3], [2, 2])), '1')
check('fixture 2: ([0, 0], [2, -2])', solve(*([0, 0], [2, -2])), '4')
check('fixture 3: ([1], [1])', solve(*([1], [1])), '0')
check('fixture 4: ([1, 2, 3], [1, 2, 6])', solve(*([1, 2, 3], [1, 2, 6])), '3')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(actual, predicted):
    return str(Fraction(sum(abs(a-p) for a,p in zip(actual,predicted)),len(actual)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 3], [2, 2])', solve(*([1, 3], [2, 2])), '1')
check('fixture 2: ([0, 0], [2, -2])', solve(*([0, 0], [2, -2])), '4')
check('fixture 3: ([1], [1])', solve(*([1], [1])), '0')
check('fixture 4: ([1, 2, 3], [1, 2, 6])', solve(*([1, 2, 3], [1, 2, 6])), '3')
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:
Averaging before squaring permits residual cancellation.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Paired arrays are nonempty; average squared prediction residuals. Exact operational definition: str(Fraction(sum((a-p)**2 for a,p in zip(actual,predicted)),len(actual)))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(tp, fp, fn):
    return str(Fraction(tp,tp+fn)) if tp+fn else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 1, 2)', solve(*(3, 1, 2)), '3/4')
check('fixture 2: (0, 2, 1)', solve(*(0, 2, 1)), '0')
check('fixture 3: (0, 0, 2)', solve(*(0, 0, 2)), None)
check('fixture 4: (5, 0, 1)', solve(*(5, 0, 1)), '1')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(tp, fp, fn):
    return str(Fraction(tp+fp,tp)) if tp else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 1, 2)', solve(*(3, 1, 2)), '3/4')
check('fixture 2: (0, 2, 1)', solve(*(0, 2, 1)), '0')
check('fixture 3: (0, 0, 2)', solve(*(0, 0, 2)), None)
check('fixture 4: (5, 0, 1)', solve(*(5, 0, 1)), '1')
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:
Recall denominator replaces predicted-positive count.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. tp,fp,fn are nonnegative counts; undefined zero-denominator precision returns None. Exact operational definition: str(Fraction(tp,tp+fp)) if tp+fp else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(tp, fp, fn):
    return str(Fraction(tp,tp+fp)) if tp+fp else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 1, 2)', solve(*(3, 1, 2)), '3/5')
check('fixture 2: (0, 2, 1)', solve(*(0, 2, 1)), '0')
check('fixture 3: (0, 2, 0)', solve(*(0, 2, 0)), None)
check('fixture 4: (5, 1, 0)', solve(*(5, 1, 0)), '1')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(tp, fp, fn):
    return str(Fraction(tp,fp+fn)) if fp+fn else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 1, 2)', solve(*(3, 1, 2)), '3/5')
check('fixture 2: (0, 2, 1)', solve(*(0, 2, 1)), '0')
check('fixture 3: (0, 2, 0)', solve(*(0, 2, 0)), None)
check('fixture 4: (5, 1, 0)', solve(*(5, 1, 0)), '1')
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:
Predicted positives replace actual positives.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. tp,fp,fn are nonnegative counts; undefined zero-denominator recall returns None. Exact operational definition: str(Fraction(tp,tp+fn)) if tp+fn else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(tp, fp, fn):
    return str(Fraction(tp,tp+fp+fn)) if tp+fp+fn else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 1, 2)', solve(*(3, 1, 2)), '2/3')
check('fixture 2: (0, 2, 1)', solve(*(0, 2, 1)), '0')
check('fixture 3: (0, 0, 0)', solve(*(0, 0, 0)), None)
check('fixture 4: (5, 0, 0)', solve(*(5, 0, 0)), '1')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(tp, fp, fn):
    return str((Fraction(tp,tp+fp)+Fraction(tp,tp+fn))/2) if tp+fp and tp+fn else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (3, 1, 2)', solve(*(3, 1, 2)), '2/3')
check('fixture 2: (0, 2, 1)', solve(*(0, 2, 1)), '0')
check('fixture 3: (0, 0, 0)', solve(*(0, 0, 0)), None)
check('fixture 4: (5, 0, 0)', solve(*(5, 0, 0)), '1')
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:
Intersection-over-union replaces the F1 overlap normalization.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. tp,fp,fn are nonnegative counts; zero total returns None. Exact operational definition: str(Fraction(2*tp,2*tp+fp+fn)) if 2*tp+fp+fn else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(tn, fp, fn):
    return str(Fraction(tn,tn+fn)) if tn+fn else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (8, 2, 1)', solve(*(8, 2, 1)), '4/5')
check('fixture 2: (0, 2, 1)', solve(*(0, 2, 1)), '0')
check('fixture 3: (0, 0, 2)', solve(*(0, 0, 2)), None)
check('fixture 4: (5, 0, 3)', solve(*(5, 0, 3)), '1')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(tn, fp, fn):
    return str(Fraction(fp,tn+fp)) if tn+fp else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (8, 2, 1)', solve(*(8, 2, 1)), '4/5')
check('fixture 2: (0, 2, 1)', solve(*(0, 2, 1)), '0')
check('fixture 3: (0, 0, 2)', solve(*(0, 0, 2)), None)
check('fixture 4: (5, 0, 3)', solve(*(5, 0, 3)), '1')
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:
False negatives replace false positives in actual-negative count.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. tn,fp,fn are nonnegative counts; zero actual negatives returns None. Exact operational definition: str(Fraction(tn,tn+fp)) if tn+fp else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b):
    return str(Fraction(len(set(a)&set(b)),len(a)+len(b))) if a or b else "1"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2], [2, 3])', solve(*([1, 2], [2, 3])), '1/3')
check('fixture 2: ([1, 1], [1])', solve(*([1, 1], [1])), '1')
check('fixture 3: ([], [])', solve(*([], [])), '1')
check('fixture 4: ([1], [])', solve(*([1], [])), '0')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b):
    return str(Fraction(len(set(a)&set(b)),min(len(set(a)),len(set(b))))) if a and b else "1"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2], [2, 3])', solve(*([1, 2], [2, 3])), '1/3')
check('fixture 2: ([1, 1], [1])', solve(*([1, 1], [1])), '1')
check('fixture 3: ([], [])', solve(*([], [])), '1')
check('fixture 4: ([1], [])', solve(*([1], [])), '0')
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:
Adding input lengths double-counts the intersection and duplicates.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Duplicates do not affect either set. Two empty sets have similarity one; exactly one empty set has zero. Exact operational definition: str(Fraction(len(set(a)&set(b)),len(set(a)|set(b)))) if a or b else "1"

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b):
    return str(Fraction(len(set(a)&set(b)),len(set(a))+len(set(b)))) if a or b else "1"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2], [2, 3])', solve(*([1, 2], [2, 3])), '1/2')
check('fixture 2: ([1, 1], [1])', solve(*([1, 1], [1])), '1')
check('fixture 3: ([], [])', solve(*([], [])), '1')
check('fixture 4: ([1], [])', solve(*([1], [])), '0')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b):
    return str(Fraction(len(set(a)&set(b)),len(set(a)|set(b)))) if a or b else "1"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2], [2, 3])', solve(*([1, 2], [2, 3])), '1/2')
check('fixture 2: ([1, 1], [1])', solve(*([1, 1], [1])), '1')
check('fixture 3: ([], [])', solve(*([], [])), '1')
check('fixture 4: ([1], [])', solve(*([1], [])), '0')
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 intersection is not doubled in Dice normalization.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Duplicates do not affect either set. Two empty sets have similarity one; exactly one empty set has zero. Exact operational definition: str(Fraction(2*len(set(a)&set(b)),len(set(a))+len(set(b)))) if a or b else "1"

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values, x):
    return str(Fraction(sum(v<x for v in values),len(values))) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 1, 2], 1)', solve(*([1, 1, 2], 1)), '2/3')
check('fixture 2: ([1, 2, 3], 0)', solve(*([1, 2, 3], 0)), '0')
check('fixture 3: ([1, 2, 3], 3)', solve(*([1, 2, 3], 3)), '1')
check('fixture 4: ([], 2)', solve(*([], 2)), None)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values, x):
    return str(Fraction(sum(v<=x for v in set(values)),len(set(values)))) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 1, 2], 1)', solve(*([1, 1, 2], 1)), '2/3')
check('fixture 2: ([1, 2, 3], 0)', solve(*([1, 2, 3], 0)), '0')
check('fixture 3: ([1, 2, 3], 3)', solve(*([1, 2, 3], 3)), '1')
check('fixture 4: ([], 2)', solve(*([], 2)), None)
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:
Strict comparison excludes atoms at the query point.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Empirical cdf inclusive. Exact operational definition: str(Fraction(sum(v<=x for v in values),len(values))) if values else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values, x):
    return str(Fraction(sum(v>=x for v in values),len(values))) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 1, 2], 1)', solve(*([1, 1, 2], 1)), '1/3')
check('fixture 2: ([1, 2, 3], 0)', solve(*([1, 2, 3], 0)), '1')
check('fixture 3: ([1, 2, 3], 3)', solve(*([1, 2, 3], 3)), '0')
check('fixture 4: ([], 2)', solve(*([], 2)), None)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values, x):
    return str(Fraction(sum(v<x for v in values),len(values))) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 1, 2], 1)', solve(*([1, 1, 2], 1)), '1/3')
check('fixture 2: ([1, 2, 3], 0)', solve(*([1, 2, 3], 0)), '1')
check('fixture 3: ([1, 2, 3], 3)', solve(*([1, 2, 3], 3)), '0')
check('fixture 4: ([], 2)', solve(*([], 2)), None)
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:
Including equal observations mismatches the strict survival convention.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Survival function strict. Exact operational definition: str(Fraction(sum(v>x for v in values),len(values))) if values else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [str(sorted(values).index(v)+1) for v in values]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([30, 10, 10, 20],)', solve(*([30, 10, 10, 20],)), ['4', '3/2', '3/2', '3'])
check('fixture 2: ([1, 2],)', solve(*([1, 2],)), ['1', '2'])
check('fixture 3: ([5, 5],)', solve(*([5, 5],)), ['3/2', '3/2'])
check('fixture 4: ([],)', solve(*([],)), [])
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [str(i+1) for i in range(len(values))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([30, 10, 10, 20],)', solve(*([30, 10, 10, 20],)), ['4', '3/2', '3/2', '3'])
check('fixture 2: ([1, 2],)', solve(*([1, 2],)), ['1', '2'])
check('fixture 3: ([5, 5],)', solve(*([5, 5],)), ['3/2', '3/2'])
check('fixture 4: ([],)', solve(*([],)), [])
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:
Each tied group receives its first rank rather than average rank.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Ascending ranks start at one and ties receive the mean occupied rank as a Fraction string; preserve original order. Exact operational definition: [str(Fraction(sum(i+1 for i,x in enumerate(sorted(values)) if x==v),values.count(v))) for v in values]

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [sorted(values).index(v)+1 for v in values]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([30, 10, 10, 20],)', solve(*([30, 10, 10, 20],)), [3, 1, 1, 2])
check('fixture 2: ([1, 2],)', solve(*([1, 2],)), [1, 2])
check('fixture 3: ([5, 5],)', solve(*([5, 5],)), [1, 1])
check('fixture 4: ([],)', solve(*([],)), [])
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [i+1 for i in range(len(values))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([30, 10, 10, 20],)', solve(*([30, 10, 10, 20],)), [3, 1, 1, 2])
check('fixture 2: ([1, 2],)', solve(*([1, 2],)), [1, 2])
check('fixture 3: ([5, 5],)', solve(*([5, 5],)), [1, 1])
check('fixture 4: ([],)', solve(*([],)), [])
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:
Competition ranks leave gaps after tied groups.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Ascending ranks start at one; tied values share a rank and the next distinct value increments by one. Exact operational definition: [sorted(set(values)).index(v)+1 for v in values]

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [sorted(set(values)).index(v)+1 for v in values]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([30, 10, 10, 20],)', solve(*([30, 10, 10, 20],)), [4, 1, 1, 3])
check('fixture 2: ([1, 2],)', solve(*([1, 2],)), [1, 2])
check('fixture 3: ([5, 5],)', solve(*([5, 5],)), [1, 1])
check('fixture 4: ([],)', solve(*([],)), [])
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [len(values)-sorted(values).index(v) for v in values]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([30, 10, 10, 20],)', solve(*([30, 10, 10, 20],)), [4, 1, 1, 3])
check('fixture 2: ([1, 2],)', solve(*([1, 2],)), [1, 2])
check('fixture 3: ([5, 5],)', solve(*([5, 5],)), [1, 1])
check('fixture 4: ([],)', solve(*([],)), [])
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:
Dense ranks fail to leave gaps after tied observations.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Ascending ranks start at one; ties receive the first occupied rank and leave gaps after the group. Exact operational definition: [sorted(values).index(v)+1 for v in values]

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return str(Fraction(max(values)-min(values),1)) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3],)', solve(*([1, 2, 3],)), '8/9')
check('fixture 2: ([5, 5],)', solve(*([5, 5],)), '0')
check('fixture 3: ([0, 4],)', solve(*([0, 4],)), '2')
check('fixture 4: ([],)', solve(*([],)), None)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return str(Fraction(sum(abs(a-b) for a in values for b in values),len(values))) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3],)', solve(*([1, 2, 3],)), '8/9')
check('fixture 2: ([5, 5],)', solve(*([5, 5],)), '0')
check('fixture 3: ([0, 4],)', solve(*([0, 4],)), '2')
check('fixture 4: ([],)', solve(*([],)), None)
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 sample range replaces average pairwise distance.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Gini mean difference rational. Exact operational definition: str(Fraction(sum(abs(a-b) for a in values for b in values),len(values)**2)) if values else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(weights):
    return str(len(weights))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 1, 1],)', solve(*([1, 1, 1],)), '3')
check('fixture 2: ([1, 3],)', solve(*([1, 3],)), '8/5')
check('fixture 3: ([2, 2],)', solve(*([2, 2],)), '2')
check('fixture 4: ([0, 0],)', solve(*([0, 0],)), None)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(weights):
    return str(Fraction(sum(weights),sum(w*w for w in weights))) if sum(w*w for w in weights) else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 1, 1],)', solve(*([1, 1, 1],)), '3')
check('fixture 2: ([1, 3],)', solve(*([1, 3],)), '8/5')
check('fixture 3: ([2, 2],)', solve(*([2, 2],)), '2')
check('fixture 4: ([0, 0],)', solve(*([0, 0],)), None)
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:
Nominal record count ignores unequal weight concentration.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Effective sample size weights. Exact operational definition: str(Fraction(sum(weights)**2,sum(w*w for w in weights))) if sum(w*w for w in weights) else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(n1, v1, n2, v2):
    return str(Fraction(v1+v2,2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (2, 1, 4, 3)', solve(*(2, 1, 4, 3)), '5/2')
check('fixture 2: (3, 2, 3, 4)', solve(*(3, 2, 3, 4)), '3')
check('fixture 3: (2, 0, 2, 0)', solve(*(2, 0, 2, 0)), '0')
check('fixture 4: (2, 4, 5, 1)', solve(*(2, 4, 5, 1)), '8/5')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(n1, v1, n2, v2):
    return str(Fraction(n1*v1+n2*v2,n1+n2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (2, 1, 4, 3)', solve(*(2, 1, 4, 3)), '5/2')
check('fixture 2: (3, 2, 3, 4)', solve(*(3, 2, 3, 4)), '3')
check('fixture 3: (2, 0, 2, 0)', solve(*(2, 0, 2, 0)), '0')
check('fixture 4: (2, 4, 5, 1)', solve(*(2, 4, 5, 1)), '8/5')
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:
Equal averaging ignores unequal degrees of freedom.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. n1,n2>=2 and v1,v2 are nonnegative integer unbiased within-group sample variances; pool by degrees of freedom. Exact operational definition: str(Fraction((n1-1)*v1+(n2-1)*v2,n1+n2-2))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(counts):
    return round(-sum((c/sum(counts))*math.log(c/sum(counts)) for c in counts if c),10) if sum(counts) else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 1],)', solve(*([1, 1],)), 1.0)
check('fixture 2: ([1, 1, 1, 1],)', solve(*([1, 1, 1, 1],)), 2.0)
check('fixture 3: ([5, 0],)', solve(*([5, 0],)), 0.0)
check('fixture 4: ([0, 0],)', solve(*([0, 0],)), None)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(counts):
    return round(math.log2(len(counts)),10) if counts else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 1],)', solve(*([1, 1],)), 1.0)
check('fixture 2: ([1, 1, 1, 1],)', solve(*([1, 1, 1, 1],)), 2.0)
check('fixture 3: ([5, 0],)', solve(*([5, 0],)), 0.0)
check('fixture 4: ([0, 0],)', solve(*([0, 0],)), None)
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:
Natural logarithms return nats under a bits contract.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Nonnegative frequency counts; ignore zero-probability terms and return None for zero total. Round base-two Shannon entropy to ten decimal places. Exact operational definition: round(-sum((c/sum(counts))*math.log2(c/sum(counts)) for c in counts if c),10) if sum(counts) else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, overlap):
    return str(Fraction(a)+Fraction(b))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check("fixture 1: ('1/2', '1/2', '1/4')", solve(*('1/2', '1/2', '1/4')), '3/4')
check("fixture 2: ('1/2', '1/2', '1/2')", solve(*('1/2', '1/2', '1/2')), '1/2')
check("fixture 3: ('0', '1/3', '0')", solve(*('0', '1/3', '0')), '1/3')
check("fixture 4: ('1/3', '1/3', '0')", solve(*('1/3', '1/3', '0')), '2/3')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, overlap):
    return str(Fraction(a)+Fraction(b)-Fraction(a)*Fraction(b))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check("fixture 1: ('1/2', '1/2', '1/4')", solve(*('1/2', '1/2', '1/4')), '3/4')
check("fixture 2: ('1/2', '1/2', '1/2')", solve(*('1/2', '1/2', '1/2')), '1/2')
check("fixture 3: ('0', '1/3', '0')", solve(*('0', '1/3', '0')), '1/3')
check("fixture 4: ('1/3', '1/3', '0')", solve(*('1/3', '1/3', '0')), '2/3')
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 overlapping event mass is counted twice.

Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. a,b,overlap are rational strings for valid probabilities with max(0,a+b-1)<=overlap<=min(a,b); do not assume independence. Exact operational definition: str(Fraction(a)+Fraction(b)-Fraction(overlap))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [a-b for a,b in zip(values,values[1:])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 4, 9, 16],)', solve(*([1, 4, 9, 16],)), [3, 5, 7])
check('fixture 2: ([3, 3],)', solve(*([3, 3],)), [0])
check('fixture 3: ([7],)', solve(*([7],)), [])
check('fixture 4: ([],)', solve(*([],)), [])
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [b+a for a,b in zip(values,values[1:])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 4, 9, 16],)', solve(*([1, 4, 9, 16],)), [3, 5, 7])
check('fixture 2: ([3, 3],)', solve(*([3, 3],)), [0])
check('fixture 3: ([7],)', solve(*([7],)), [])
check('fixture 4: ([],)', solve(*([],)), [])
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:
Subtraction order reverses the discrete derivative.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. Forward first difference. Exact operational definition: [b-a for a,b in zip(values,values[1:])]

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [a-b+c for a,b,c in zip(values,values[1:],values[2:])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 4, 9, 16],)', solve(*([1, 4, 9, 16],)), [2, 2])
check('fixture 2: ([3, 3, 3],)', solve(*([3, 3, 3],)), [0])
check('fixture 3: ([1, 2],)', solve(*([1, 2],)), [])
check('fixture 4: ([0, 1, 0],)', solve(*([0, 1, 0],)), [-2])
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [c-a for a,b,c in zip(values,values[1:],values[2:])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 4, 9, 16],)', solve(*([1, 4, 9, 16],)), [2, 2])
check('fixture 2: ([3, 3, 3],)', solve(*([3, 3, 3],)), [0])
check('fixture 3: ([1, 2],)', solve(*([1, 2],)), [])
check('fixture 4: ([0, 1, 0],)', solve(*([0, 1, 0],)), [-2])
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 center sample is not doubled.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. Second central difference. Exact operational definition: [a-2*b+c for a,b,c in zip(values,values[1:],values[2:])]

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [sum(values[:i]) for i in range(len(values))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3],)', solve(*([1, 2, 3],)), [1, 3, 6])
check('fixture 2: ([2, -2, 4],)', solve(*([2, -2, 4],)), [2, 0, 4])
check('fixture 3: ([5],)', solve(*([5],)), [5])
check('fixture 4: ([],)', solve(*([],)), [])
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [sum(values[i:]) for i in range(len(values))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3],)', solve(*([1, 2, 3],)), [1, 3, 6])
check('fixture 2: ([2, -2, 4],)', solve(*([2, -2, 4],)), [2, 0, 4])
check('fixture 3: ([5],)', solve(*([5],)), [5])
check('fixture 4: ([],)', solve(*([],)), [])
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 current sample is excluded from each prefix.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. Prefix sums inclusive. Exact operational definition: list(itertools.accumulate(values))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return list(itertools.accumulate(values))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([2, 3, 4],)', solve(*([2, 3, 4],)), [2, 6, 24])
check('fixture 2: ([2, 0, 5],)', solve(*([2, 0, 5],)), [2, 0, 0])
check('fixture 3: ([5],)', solve(*([5],)), [5])
check('fixture 4: ([],)', solve(*([],)), [])
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return [math.prod(values[:i]) for i in range(len(values))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([2, 3, 4],)', solve(*([2, 3, 4],)), [2, 6, 24])
check('fixture 2: ([2, 0, 5],)', solve(*([2, 0, 5],)), [2, 0, 0])
check('fixture 3: ([5],)', solve(*([5],)), [5])
check('fixture 4: ([],)', solve(*([],)), [])
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:
Addition replaces multiplicative accumulation.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. Prefix products inclusive. Exact operational definition: list(itertools.accumulate(values,lambda a,b:a*b))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return str(sum(values))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([0, 1, 2],)', solve(*([0, 1, 2],)), '2')
check('fixture 2: ([3, 3],)', solve(*([3, 3],)), '3')
check('fixture 3: ([5],)', solve(*([5],)), '0')
check('fixture 4: ([],)', solve(*([],)), '0')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return str(sum(values[:-1]))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([0, 1, 2],)', solve(*([0, 1, 2],)), '2')
check('fixture 2: ([3, 3],)', solve(*([3, 3],)), '3')
check('fixture 3: ([5],)', solve(*([5],)), '0')
check('fixture 4: ([],)', solve(*([],)), '0')
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:
Every sample receives a full interval weight, including both endpoints.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. Trapezoidal integral unit grid. Exact operational definition: str(sum((Fraction(a+b,2) for a,b in zip(values,values[1:])),Fraction()))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y):
    return str(sum((Fraction(u+v,2) for u,v in zip(y,y[1:])),Fraction()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([0, 1, 3], [0, 2, 2])', solve(*([0, 1, 3], [0, 2, 2])), '5')
check('fixture 2: ([0, 2], [1, 3])', solve(*([0, 2], [1, 3])), '4')
check('fixture 3: ([2, 0], [3, 1])', solve(*([2, 0], [3, 1])), '-4')
check('fixture 4: ([1], [4])', solve(*([1], [4])), '0')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(x, y):
    return str(sum((Fraction((b-a)*u) for a,b,u in zip(x,x[1:],y)),Fraction()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([0, 1, 3], [0, 2, 2])', solve(*([0, 1, 3], [0, 2, 2])), '5')
check('fixture 2: ([0, 2], [1, 3])', solve(*([0, 2], [1, 3])), '4')
check('fixture 3: ([2, 0], [3, 1])', solve(*([2, 0], [3, 1])), '-4')
check('fixture 4: ([1], [4])', solve(*([1], [4])), '0')
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:
Interval widths are assumed to be one.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. x has distinct ordered coordinates and matches y; descending x yields negative integral. Exact operational definition: str(sum((Fraction((b-a)*(v+u),2) for a,b,u,v in zip(x,x[1:],y,y[1:])),Fraction()))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(y0, y1, y2, h):
    return str(Fraction(h*(y0+2*y1+y2),2))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0, 1, 4, 1)', solve(*(0, 1, 4, 1)), '8/3')
check('fixture 2: (3, 3, 3, 1)', solve(*(3, 3, 3, 1)), '6')
check('fixture 3: (1, 0, 1, 2)', solve(*(1, 0, 1, 2)), '4/3')
check('fixture 4: (0, 0, 0, 1)', solve(*(0, 0, 0, 1)), '0')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(y0, y1, y2, h):
    return str(Fraction(h*(y0+y1+y2),3))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0, 1, 4, 1)', solve(*(0, 1, 4, 1)), '8/3')
check('fixture 2: (3, 3, 3, 1)', solve(*(3, 3, 3, 1)), '6')
check('fixture 3: (1, 0, 1, 2)', solve(*(1, 0, 1, 2)), '4/3')
check('fixture 4: (0, 0, 0, 1)', solve(*(0, 0, 0, 1)), '0')
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:
Trapezoidal weights replace the quadratic-exact Simpson weights.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. y0,y1,y2 are equally spaced samples separated by h>0; integrate over a span of 2*h. Exact operational definition: str(Fraction(h*(y0+4*y1+y2),3))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(left, right, h):
    return str(Fraction(right-left,h))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1, 9, 1)', solve(*(1, 9, 1)), '4')
check('fixture 2: (3, 3, 2)', solve(*(3, 3, 2)), '0')
check('fixture 3: (9, 1, 2)', solve(*(9, 1, 2)), '-2')
check('fixture 4: (-2, 2, 2)', solve(*(-2, 2, 2)), '1')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(left, right, h):
    return str(Fraction(right+left,2*h))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (1, 9, 1)', solve(*(1, 9, 1)), '4')
check('fixture 2: (3, 3, 2)', solve(*(3, 3, 2)), '0')
check('fixture 3: (9, 1, 2)', solve(*(9, 1, 2)), '-2')
check('fixture 4: (-2, 2, 2)', solve(*(-2, 2, 2)), '1')
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 two-sided distance is treated as one step.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. Central first derivative samples. Exact operational definition: str(Fraction(right-left,2*h))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(left, center, right, h):
    return str(Fraction(left-2*center+right,h))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0, 4, 16, 2)', solve(*(0, 4, 16, 2)), '2')
check('fixture 2: (3, 3, 3, 1)', solve(*(3, 3, 3, 1)), '0')
check('fixture 3: (1, 0, 1, 1)', solve(*(1, 0, 1, 1)), '2')
check('fixture 4: (0, 1, 0, 2)', solve(*(0, 1, 0, 2)), '-1/2')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(left, center, right, h):
    return str(Fraction(left-center+right,h*h))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (0, 4, 16, 2)', solve(*(0, 4, 16, 2)), '2')
check('fixture 2: (3, 3, 3, 1)', solve(*(3, 3, 3, 1)), '0')
check('fixture 3: (1, 0, 1, 1)', solve(*(1, 0, 1, 1)), '2')
check('fixture 4: (0, 1, 0, 2)', solve(*(0, 1, 0, 2)), '-1/2')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A second derivative is divided by one step instead of squared step.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. Central second derivative samples. Exact operational definition: str(Fraction(left-2*center+right,h*h))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, t):
    return str((Fraction(a)+Fraction(b))*Fraction(t))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check("fixture 1: (2, 10, '1/4')", solve(*(2, 10, '1/4')), '4')
check("fixture 2: (3, 7, '0')", solve(*(3, 7, '0')), '3')
check("fixture 3: (3, 7, '1')", solve(*(3, 7, '1')), '7')
check("fixture 4: (2, 2, '1/3')", solve(*(2, 2, '1/3')), '2')
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, t):
    return str(Fraction(a)*Fraction(t)+Fraction(b)*(1-Fraction(t)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check("fixture 1: (2, 10, '1/4')", solve(*(2, 10, '1/4')), '4')
check("fixture 2: (3, 7, '0')", solve(*(3, 7, '0')), '3')
check("fixture 3: (3, 7, '1')", solve(*(3, 7, '1')), '7')
check("fixture 4: (2, 2, '1/3')", solve(*(2, 2, '1/3')), '2')
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 start value is scaled rather than retained as the intercept.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. a,b are integers and t is a rational string; extrapolation outside [0,1] is allowed. Exact operational definition: str(Fraction(a)+(Fraction(b)-Fraction(a))*Fraction(t))

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, x):
    return str(Fraction(x,b)) if b else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (2, 10, 4)', solve(*(2, 10, 4)), '1/4')
check('fixture 2: (3, 7, 3)', solve(*(3, 7, 3)), '0')
check('fixture 3: (3, 7, 7)', solve(*(3, 7, 7)), '1')
check('fixture 4: (2, 2, 2)', solve(*(2, 2, 2)), None)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(a, b, x):
    return str(Fraction(x-a,a-b)) if a!=b else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (2, 10, 4)', solve(*(2, 10, 4)), '1/4')
check('fixture 2: (3, 7, 3)', solve(*(3, 7, 3)), '0')
check('fixture 3: (3, 7, 7)', solve(*(3, 7, 7)), '1')
check('fixture 4: (2, 2, 2)', solve(*(2, 2, 2)), None)
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 interval origin is not removed.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. a,b,x are integers; return None when the endpoint interval has zero span. Exact operational definition: str(Fraction(x-a,b-a)) if a!=b else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return values[-1] if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 3, 5],)', solve(*([1, 3, 5],)), 7)
check('fixture 2: ([5, 3, 1],)', solve(*([5, 3, 1],)), -1)
check('fixture 3: ([4, 4],)', solve(*([4, 4],)), 4)
check('fixture 4: ([2],)', solve(*([2],)), None)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return values[-1]+values[-2] if len(values)>1 else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 3, 5],)', solve(*([1, 3, 5],)), 7)
check('fixture 2: ([5, 3, 1],)', solve(*([5, 3, 1],)), -1)
check('fixture 3: ([4, 4],)', solve(*([4, 4],)), 4)
check('fixture 4: ([2],)', solve(*([2],)), None)
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:
Last-value persistence discards the final slope.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. Linear extrapolation last slope. Exact operational definition: 2*values[-1]-values[-2] if len(values)>1 else None

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return 2*values[-1]-values[-2]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 4, 9],)', solve(*([1, 4, 9],)), 16)
check('fixture 2: ([0, 1, 4],)', solve(*([0, 1, 4],)), 9)
check('fixture 3: ([3, 3, 3],)', solve(*([3, 3, 3],)), 3)
check('fixture 4: ([1, 2, 3],)', solve(*([1, 2, 3],)), 4)
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(values):
    return 3*values[-1]-values[-2]+values[-3]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 4, 9],)', solve(*([1, 4, 9],)), 16)
check('fixture 2: ([0, 1, 4],)', solve(*([0, 1, 4],)), 9)
check('fixture 3: ([3, 3, 3],)', solve(*([3, 3, 3],)), 3)
check('fixture 4: ([1, 2, 3],)', solve(*([1, 2, 3],)), 4)
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:
Linear extrapolation omits second differences.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. At least three values are provided; extrapolate using the final three equally spaced observations. Exact operational definition: 3*values[-1]-3*values[-2]+values[-3]

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(signal, kernel):
    return [sum(signal[i+j]*kernel[j] for j in range(len(kernel))) for i in range(len(signal)-len(kernel)+1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [1, 2])', solve(*([1, 2, 3], [1, 2])), [4, 7])
check('fixture 2: ([1, 0, 1], [1, -1])', solve(*([1, 0, 1], [1, -1])), [-1, 1])
check('fixture 3: ([2], [3])', solve(*([2], [3])), [6])
check('fixture 4: ([1], [1, 2])', solve(*([1], [1, 2])), [])
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
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(signal, kernel):
    return [sum(signal[i+j]+kernel[-1-j] for j in range(len(kernel))) for i in range(len(signal)-len(kernel)+1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [1, 2])', solve(*([1, 2, 3], [1, 2])), [4, 7])
check('fixture 2: ([1, 0, 1], [1, -1])', solve(*([1, 0, 1], [1, -1])), [-1, 1])
check('fixture 3: ([2], [3])', solve(*([2], [3])), [6])
check('fixture 4: ([1], [1, 2])', solve(*([1], [1, 2])), [])
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:
Unreversed kernel computes correlation instead of convolution.

Integer sample values and compatible sample-array lengths. Rational results are reduced Fraction strings; spacing is positive unless explicitly stated otherwise. kernel is nonempty; return only full-overlap windows, or [] if the signal is shorter. Exact operational definition: [sum(signal[i+j]*kernel[-1-j] for j in range(len(kernel))) for i in range(len(signal)-len(kernel)+1)]

split: open-access