broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(decimal):
    d = float(decimal)
    if d <= 1:
        return 'invalid'
    if d >= 2:
        v = (d - 1) * 100
        sign = '+'
    else:
        v = 100 / (d - 1)
        sign = '-'
    n = math.floor(v + Fraction(1, 2))
    return sign + str(n)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('6.99',), '+599'),
  ('variant scenario 2', ('2.75',), '+175')],
 [('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('3.125',), '+213'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('2.951',), '+195'),
  ('variant scenario 2', ('6.21',), '+521')],
 [('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('14.74',), '+1374'),
  ('variant scenario 2', ('1.00',), 'invalid')],
 [('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('3.125',), '+213'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('13.57',), '+1257'),
  ('variant scenario 2', ('10.35',), '+935')],
 [('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('2.125',), '+113'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('5.20',), '+420'),
  ('variant scenario 2', ('8.76',), '+776')]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(decimal):
    d = round(float(decimal), 2)
    if d <= 1:
        return 'invalid'
    if d >= 2:
        v = (d - 1) * 100
        sign = '+'
    else:
        v = 100 / (d - 1)
        sign = '-'
    n = math.floor(v + Fraction(1, 2))
    return sign + str(n)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('6.99',), '+599'),
  ('variant scenario 2', ('2.75',), '+175')],
 [('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('3.125',), '+213'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('2.951',), '+195'),
  ('variant scenario 2', ('6.21',), '+521')],
 [('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('14.74',), '+1374'),
  ('variant scenario 2', ('1.00',), 'invalid')],
 [('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('3.125',), '+213'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('13.57',), '+1257'),
  ('variant scenario 2', ('10.35',), '+935')],
 [('control underdog', ('2.50',), '+150'),
  ('control favourite', ('1.50',), '-200'),
  ('boundary evens', ('2.00',), '+100'),
  ('boundary half-cent rounds up', ('2.005',), '+101'),
  ('boundary no-profit price', ('1.00',), 'invalid'),
  ('control short favourite', ('1.08',), '-1250'),
  ('regression: binary float parse', ('2.125',), '+113'),
  ('regression: binary float parse', ('2.005',), '+101'),
  ('variant scenario 1', ('5.20',), '+420'),
  ('variant scenario 2', ('8.76',), '+776')]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Prices exactly on a half-dollar boundary round the wrong way.

Convert a decimal price string to an American moneyline string. Prices at or below 1 return "invalid". For d >= 2 the line is "+" followed by 100 * (d - 1); for d < 2 it is "-" followed by 100 / (d - 1). The magnitude is computed exactly from the decimal text and rounded half up to an integer. Evens (2.00) is "+100".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n < 100:
        return 'invalid'
    profit = Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q + Fraction(1, 2))
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(n, n + 100) * 100 if neg else Fraction(100, n + 100) * 100
    return [fmt(dec, 2), '%d/%d' % (profit.numerator, profit.denominator), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-105',), ['1.95', '20/21', '51.2']),
  ('variant scenario 1', ('162',), ['2.62', '81/50', '38.2']),
  ('variant scenario 2', ('-277',), ['1.36', '100/277', '73.5'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-474',), ['1.21', '50/237', '82.6']),
  ('variant scenario 1', ('+1140',), ['12.40', '57/5', '8.1']),
  ('variant scenario 2', ('+1195',), ['12.95', '239/20', '7.7'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-1020',), ['1.10', '5/51', '91.1']),
  ('variant scenario 1', ('110',), ['2.10', '11/10', '47.6']),
  ('variant scenario 2', ('-225',), ['1.44', '4/9', '69.2'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-397',), ['1.25', '100/397', '79.9']),
  ('variant scenario 1', ('+355',), ['4.55', '71/20', '22.0']),
  ('variant scenario 2', ('-179',), ['1.56', '100/179', '64.2'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-363',), ['1.28', '100/363', '78.4']),
  ('variant scenario 1', ('267',), ['3.67', '267/100', '27.2']),
  ('variant scenario 2', ('+486',), ['5.86', '243/50', '17.1'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n < 100:
        return 'invalid'
    profit = Fraction(100, n + 100) if neg else Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q + Fraction(1, 2))
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(n, n + 100) * 100 if neg else Fraction(100, n + 100) * 100
    return [fmt(dec, 2), '%d/%d' % (profit.numerator, profit.denominator), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-105',), ['1.95', '20/21', '51.2']),
  ('variant scenario 1', ('162',), ['2.62', '81/50', '38.2']),
  ('variant scenario 2', ('-277',), ['1.36', '100/277', '73.5'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-474',), ['1.21', '50/237', '82.6']),
  ('variant scenario 1', ('+1140',), ['12.40', '57/5', '8.1']),
  ('variant scenario 2', ('+1195',), ['12.95', '239/20', '7.7'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-1020',), ['1.10', '5/51', '91.1']),
  ('variant scenario 1', ('110',), ['2.10', '11/10', '47.6']),
  ('variant scenario 2', ('-225',), ['1.44', '4/9', '69.2'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-397',), ['1.25', '100/397', '79.9']),
  ('variant scenario 1', ('+355',), ['4.55', '71/20', '22.0']),
  ('variant scenario 2', ('-179',), ['1.56', '100/179', '64.2'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: favourite profit', ('-363',), ['1.28', '100/363', '78.4']),
  ('variant scenario 1', ('267',), ['3.67', '267/100', '27.2']),
  ('variant scenario 2', ('+486',), ['5.86', '243/50', '17.1'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A -200 favourite is expanded as a 3.00 decimal price.

Expand an American moneyline ("+150", "150" or "-200"; magnitude at least 100, otherwise "invalid"). Profit per unit is N/100 for positive or unsigned lines and 100/N for negative lines. Return [decimal price with two decimals, reduced fractional profit "a/b", implied probability percent with one decimal], all computed exactly and rounded half up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n <= 0:
        return 'invalid'
    profit = Fraction(100, n) if neg else Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q + Fraction(1, 2))
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(n, n + 100) * 100 if neg else Fraction(100, n + 100) * 100
    return [fmt(dec, 2), '%d/%d' % (profit.numerator, profit.denominator), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('+50',), 'invalid'),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('110',), ['2.10', '11/10', '47.6']),
  ('variant scenario 2', ('+1135',), ['12.35', '227/20', '8.1'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('-175',), ['1.57', '4/7', '63.6']),
  ('variant scenario 2', ('846',), ['9.46', '423/50', '10.6'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('+655',), ['7.55', '131/20', '13.2']),
  ('variant scenario 2', ('+800',), ['9.00', '8/1', '11.1'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('+50',), 'invalid'),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('+1106',), ['12.06', '553/50', '8.3']),
  ('variant scenario 2', ('-772',), ['1.13', '25/193', '88.5'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('+50',), 'invalid'),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('-115',), ['1.87', '20/23', '53.5']),
  ('variant scenario 2', ('100',), ['2.00', '1/1', '50.0'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n < 100 and not neg:
        return 'invalid'
    profit = Fraction(100, n) if neg else Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q + Fraction(1, 2))
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(n, n + 100) * 100 if neg else Fraction(100, n + 100) * 100
    return [fmt(dec, 2), '%d/%d' % (profit.numerator, profit.denominator), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('+50',), 'invalid'),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('110',), ['2.10', '11/10', '47.6']),
  ('variant scenario 2', ('+1135',), ['12.35', '227/20', '8.1'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('-175',), ['1.57', '4/7', '63.6']),
  ('variant scenario 2', ('846',), ['9.46', '423/50', '10.6'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('+655',), ['7.55', '131/20', '13.2']),
  ('variant scenario 2', ('+800',), ['9.00', '8/1', '11.1'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('+50',), 'invalid'),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('+1106',), ['12.06', '553/50', '8.3']),
  ('variant scenario 2', ('-772',), ['1.13', '25/193', '88.5'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: magnitude minimum', ('+50',), 'invalid'),
  ('regression: magnitude minimum', ('-99',), 'invalid'),
  ('variant scenario 1', ('-115',), ['1.87', '20/23', '53.5']),
  ('variant scenario 2', ('100',), ['2.00', '1/1', '50.0'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A "+50" or "-99" line is expanded instead of rejected.

Expand an American moneyline ("+150", "150" or "-200"; magnitude at least 100, otherwise "invalid"). Profit per unit is N/100 for positive or unsigned lines and 100/N for negative lines. Return [decimal price with two decimals, reduced fractional profit "a/b", implied probability percent with one decimal], all computed exactly and rounded half up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n < 100:
        return 'invalid'
    profit = Fraction(100, n) if neg else Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q + Fraction(1, 2))
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(n, n + 100) * 100 if neg else Fraction(100, n + 100) * 100
    return [fmt(dec, 2), ('100/%d' % n if neg else '%d/100' % n), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('175',), ['2.75', '7/4', '36.4']),
  ('regression: fraction rendering', ('800',), ['9.00', '8/1', '11.1']),
  ('variant scenario 1', ('-283',), ['1.35', '100/283', '73.9']),
  ('variant scenario 2', ('+660',), ['7.60', '33/5', '13.2'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('120',), ['2.20', '6/5', '45.5']),
  ('regression: fraction rendering', ('+100',), ['2.00', '1/1', '50.0']),
  ('variant scenario 1', ('756',), ['8.56', '189/25', '11.7']),
  ('variant scenario 2', ('295',), ['3.95', '59/20', '25.3'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('168',), ['2.68', '42/25', '37.3']),
  ('regression: fraction rendering', ('+200',), ['3.00', '2/1', '33.3']),
  ('variant scenario 1', ('-125',), ['1.80', '4/5', '55.6']),
  ('variant scenario 2', ('+225',), ['3.25', '9/4', '30.8'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('+1016',), ['11.16', '254/25', '9.0']),
  ('regression: fraction rendering', ('+200',), ['3.00', '2/1', '33.3']),
  ('variant scenario 1', ('845',), ['9.45', '169/20', '10.6']),
  ('variant scenario 2', ('+1181',), ['12.81', '1181/100', '7.8'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('-225',), ['1.44', '4/9', '69.2']),
  ('regression: fraction rendering', ('-100',), ['2.00', '1/1', '50.0']),
  ('variant scenario 1', ('-249',), ['1.40', '100/249', '71.3']),
  ('variant scenario 2', ('+175',), ['2.75', '7/4', '36.4'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n < 100:
        return 'invalid'
    profit = Fraction(100, n) if neg else Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q + Fraction(1, 2))
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(n, n + 100) * 100 if neg else Fraction(100, n + 100) * 100
    return [fmt(dec, 2), str(profit), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('175',), ['2.75', '7/4', '36.4']),
  ('regression: fraction rendering', ('800',), ['9.00', '8/1', '11.1']),
  ('variant scenario 1', ('-283',), ['1.35', '100/283', '73.9']),
  ('variant scenario 2', ('+660',), ['7.60', '33/5', '13.2'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('120',), ['2.20', '6/5', '45.5']),
  ('regression: fraction rendering', ('+100',), ['2.00', '1/1', '50.0']),
  ('variant scenario 1', ('756',), ['8.56', '189/25', '11.7']),
  ('variant scenario 2', ('295',), ['3.95', '59/20', '25.3'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('168',), ['2.68', '42/25', '37.3']),
  ('regression: fraction rendering', ('+200',), ['3.00', '2/1', '33.3']),
  ('variant scenario 1', ('-125',), ['1.80', '4/5', '55.6']),
  ('variant scenario 2', ('+225',), ['3.25', '9/4', '30.8'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('+1016',), ['11.16', '254/25', '9.0']),
  ('regression: fraction rendering', ('+200',), ['3.00', '2/1', '33.3']),
  ('variant scenario 1', ('845',), ['9.45', '169/20', '10.6']),
  ('variant scenario 2', ('+1181',), ['12.81', '1181/100', '7.8'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: fraction rendering', ('-225',), ['1.44', '4/9', '69.2']),
  ('regression: fraction rendering', ('-100',), ['2.00', '1/1', '50.0']),
  ('variant scenario 1', ('-249',), ['1.40', '100/249', '71.3']),
  ('variant scenario 2', ('+175',), ['2.75', '7/4', '36.4'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Even money shows "1" instead of "1/1" and unreduced forms leak through.

Expand an American moneyline ("+150", "150" or "-200"; magnitude at least 100, otherwise "invalid"). Profit per unit is N/100 for positive or unsigned lines and 100/N for negative lines. Return [decimal price with two decimals, reduced fractional profit "a/b", implied probability percent with one decimal], all computed exactly and rounded half up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n < 100:
        return 'invalid'
    profit = Fraction(100, n) if neg else Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q + Fraction(1, 2))
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(n, n + 100) * 100 if neg else Fraction(100, n + 100) * 100
    return ['%.2f' % float(dec), '%d/%d' % (profit.numerator, profit.denominator), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('-331',), ['1.30', '100/331', '76.8']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('-100',), ['2.00', '1/1', '50.0']),
  ('variant scenario 2', ('+208',), ['3.08', '52/25', '32.5'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('895',), ['9.95', '179/20', '10.1']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('-120',), ['1.83', '5/6', '54.5']),
  ('variant scenario 2', ('+210',), ['3.10', '21/10', '32.3'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('-1004',), ['1.10', '25/251', '90.9']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('+168',), ['2.68', '42/25', '37.3']),
  ('variant scenario 2', ('217',), ['3.17', '217/100', '31.5'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('-674',), ['1.15', '50/337', '87.1']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('+50',), 'invalid'),
  ('variant scenario 2', ('149',), ['2.49', '149/100', '40.2'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('-624',), ['1.16', '25/156', '86.2']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('+125',), ['2.25', '5/4', '44.4']),
  ('variant scenario 2', ('+119',), ['2.19', '119/100', '45.7'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n < 100:
        return 'invalid'
    profit = Fraction(100, n) if neg else Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q)
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(n, n + 100) * 100 if neg else Fraction(100, n + 100) * 100
    return [fmt(dec, 2), '%d/%d' % (profit.numerator, profit.denominator), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('-331',), ['1.30', '100/331', '76.8']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('-100',), ['2.00', '1/1', '50.0']),
  ('variant scenario 2', ('+208',), ['3.08', '52/25', '32.5'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('895',), ['9.95', '179/20', '10.1']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('-120',), ['1.83', '5/6', '54.5']),
  ('variant scenario 2', ('+210',), ['3.10', '21/10', '32.3'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('-1004',), ['1.10', '25/251', '90.9']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('+168',), ['2.68', '42/25', '37.3']),
  ('variant scenario 2', ('217',), ['3.17', '217/100', '31.5'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('-674',), ['1.15', '50/337', '87.1']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('+50',), 'invalid'),
  ('variant scenario 2', ('149',), ['2.49', '149/100', '40.2'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: decimal rounding', ('-624',), ['1.16', '25/156', '86.2']),
  ('regression: decimal rounding', ('-800',), ['1.13', '1/8', '88.9']),
  ('variant scenario 1', ('+125',), ['2.25', '5/4', '44.4']),
  ('variant scenario 2', ('+119',), ['2.19', '119/100', '45.7'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A -800 line shows 1.12 instead of 1.13.

Expand an American moneyline ("+150", "150" or "-200"; magnitude at least 100, otherwise "invalid"). Profit per unit is N/100 for positive or unsigned lines and 100/N for negative lines. Return [decimal price with two decimals, reduced fractional profit "a/b", implied probability percent with one decimal], all computed exactly and rounded half up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n < 100:
        return 'invalid'
    profit = Fraction(100, n) if neg else Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q + Fraction(1, 2))
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(n, n + 100) * 100
    return [fmt(dec, 2), '%d/%d' % (profit.numerator, profit.denominator), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('-247',), ['1.40', '100/247', '71.2']),
  ('regression: implied probability sign', ('491',), ['5.91', '491/100', '16.9']),
  ('variant scenario 1', ('-446',), ['1.22', '50/223', '81.7']),
  ('variant scenario 2', ('-636',), ['1.16', '25/159', '86.4'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('602',), ['7.02', '301/50', '14.2']),
  ('regression: implied probability sign', ('-310',), ['1.32', '10/31', '75.6']),
  ('variant scenario 1', ('+328',), ['4.28', '82/25', '23.4']),
  ('variant scenario 2', ('+732',), ['8.32', '183/25', '12.0'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('-283',), ['1.35', '100/283', '73.9']),
  ('regression: implied probability sign', ('+757',), ['8.57', '757/100', '11.7']),
  ('variant scenario 1', ('-466',), ['1.21', '50/233', '82.3']),
  ('variant scenario 2', ('100',), ['2.00', '1/1', '50.0'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('+284',), ['3.84', '71/25', '26.0']),
  ('variant scenario 1', ('+448',), ['5.48', '112/25', '18.2']),
  ('variant scenario 2', ('-131',), ['1.76', '100/131', '56.7'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('+234',), ['3.34', '117/50', '29.9']),
  ('regression: implied probability sign', ('-110',), ['1.91', '10/11', '52.4']),
  ('variant scenario 1', ('430',), ['5.30', '43/10', '18.9']),
  ('variant scenario 2', ('+115',), ['2.15', '23/20', '46.5'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(american):
    s = american.strip()
    neg = s.startswith('-')
    n = int(s.lstrip('+-'))
    if n < 100:
        return 'invalid'
    profit = Fraction(100, n) if neg else Fraction(n, 100)
    dec = 1 + profit
    def fmt(x, places):
        q = 10 ** places
        v = math.floor(x * q + Fraction(1, 2))
        return '%d.%0*d' % (v // q, places, v % q)
    prob = Fraction(100, n + 100) * 100
    return [fmt(dec, 2), '%d/%d' % (profit.numerator, profit.denominator), fmt(prob, 1)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('-247',), ['1.40', '100/247', '71.2']),
  ('regression: implied probability sign', ('491',), ['5.91', '491/100', '16.9']),
  ('variant scenario 1', ('-446',), ['1.22', '50/223', '81.7']),
  ('variant scenario 2', ('-636',), ['1.16', '25/159', '86.4'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('602',), ['7.02', '301/50', '14.2']),
  ('regression: implied probability sign', ('-310',), ['1.32', '10/31', '75.6']),
  ('variant scenario 1', ('+328',), ['4.28', '82/25', '23.4']),
  ('variant scenario 2', ('+732',), ['8.32', '183/25', '12.0'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('-283',), ['1.35', '100/283', '73.9']),
  ('regression: implied probability sign', ('+757',), ['8.57', '757/100', '11.7']),
  ('variant scenario 1', ('-466',), ['1.21', '50/233', '82.3']),
  ('variant scenario 2', ('100',), ['2.00', '1/1', '50.0'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('+284',), ['3.84', '71/25', '26.0']),
  ('variant scenario 1', ('+448',), ['5.48', '112/25', '18.2']),
  ('variant scenario 2', ('-131',), ['1.76', '100/131', '56.7'])],
 [('control underdog', ('+150',), ['2.50', '3/2', '40.0']),
  ('control favourite', ('-200',), ['1.50', '1/2', '66.7']),
  ('boundary even money', ('+100',), ['2.00', '1/1', '50.0']),
  ('boundary unsigned line', ('250',), ['3.50', '5/2', '28.6']),
  ('boundary below minimum', ('+50',), 'invalid'),
  ('control half-up decimal', ('-800',), ['1.13', '1/8', '88.9']),
  ('regression: implied probability sign', ('+234',), ['3.34', '117/50', '29.9']),
  ('regression: implied probability sign', ('-110',), ['1.91', '10/11', '52.4']),
  ('variant scenario 1', ('430',), ['5.30', '43/10', '18.9']),
  ('variant scenario 2', ('+115',), ['2.15', '23/20', '46.5'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Underdog probabilities come out above 50 percent.

Expand an American moneyline ("+150", "150" or "-200"; magnitude at least 100, otherwise "invalid"). Profit per unit is N/100 for positive or unsigned lines and 100/N for negative lines. Return [decimal price with two decimals, reduced fractional profit "a/b", implied probability percent with one decimal], all computed exactly and rounded half up.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(text):
    t = text.strip().lower()
    on = t.endswith(' on')
    if on:
        t = t[:-3].strip()
    if t in ('evens', 'evs', 'even'):
        frac = Fraction(1)
    else:
        for sep in ('/', '-'):
            if sep in t:
                a, _, b = t.partition(sep)
                break
        else:
            return 'invalid'
        if not a.isdigit() or not b.isdigit() or int(b) == 0 or int(a) == 0:
            return 'invalid'
        frac = Fraction(int(a), int(b))
    dec = 1 + frac
    cents = math.floor(dec * 100 + Fraction(1, 2))
    return ['%d.%02d' % (cents // 100, cents % 100), '%d/%d' % (frac.numerator, frac.denominator)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('3/6 on',), ['3.00', '2/1']),
  ('variant scenario 1', ('evens',), ['2.00', '1/1']),
  ('variant scenario 2', ('12/5',), ['3.40', '12/5'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('15/13 ON',), ['1.87', '13/15']),
  ('variant scenario 1', ('evens',), ['2.00', '1/1']),
  ('variant scenario 2', ('10/8',), ['2.25', '5/4'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('4/1 ON',), ['1.25', '1/4']),
  ('variant scenario 1', ('1/8',), ['1.13', '1/8']),
  ('variant scenario 2', ('3-3',), ['2.00', '1/1'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('11/8 ON',), ['1.73', '8/11']),
  ('variant scenario 1', ('4/3',), ['2.33', '4/3']),
  ('variant scenario 2', ('2/3',), ['1.67', '2/3'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('3-6 ON',), ['3.00', '2/1']),
  ('variant scenario 1', ('2/10',), ['1.20', '1/5']),
  ('variant scenario 2', ('5/4',), ['2.25', '5/4'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(text):
    t = text.strip().lower()
    on = t.endswith(' on')
    if on:
        t = t[:-3].strip()
    if t in ('evens', 'evs', 'even'):
        frac = Fraction(1)
    else:
        for sep in ('/', '-'):
            if sep in t:
                a, _, b = t.partition(sep)
                break
        else:
            return 'invalid'
        if not a.isdigit() or not b.isdigit() or int(b) == 0 or int(a) == 0:
            return 'invalid'
        frac = Fraction(int(a), int(b))
    dec = 1 + frac
    if on:
        dec = 1 / dec
    cents = math.floor(dec * 100 + Fraction(1, 2))
    return ['%d.%02d' % (cents // 100, cents % 100), '%d/%d' % (frac.numerator, frac.denominator)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('3/6 on',), ['3.00', '2/1']),
  ('variant scenario 1', ('evens',), ['2.00', '1/1']),
  ('variant scenario 2', ('12/5',), ['3.40', '12/5'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('15/13 ON',), ['1.87', '13/15']),
  ('variant scenario 1', ('evens',), ['2.00', '1/1']),
  ('variant scenario 2', ('10/8',), ['2.25', '5/4'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('4/1 ON',), ['1.25', '1/4']),
  ('variant scenario 1', ('1/8',), ['1.13', '1/8']),
  ('variant scenario 2', ('3-3',), ['2.00', '1/1'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('11/8 ON',), ['1.73', '8/11']),
  ('variant scenario 1', ('4/3',), ['2.33', '4/3']),
  ('variant scenario 2', ('2/3',), ['1.67', '2/3'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: odds on inversion', ('3-6 ON',), ['3.00', '2/1']),
  ('variant scenario 1', ('2/10',), ['1.20', '1/5']),
  ('variant scenario 2', ('5/4',), ['2.25', '5/4'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
"2/1 on" is priced as 3.00 instead of 1.50.

Parse traditional fractional odds text, case-insensitively: "a/b" or "a-b" with positive integers, "evens"/"evs"/"even" for 1/1, and an optional trailing " on" meaning odds-on (the fraction is inverted, "2/1 on" = 1/2). Zero parts or anything else return "invalid". Return [decimal price rounded half up to two decimals, reduced profit fraction "a/b"].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(text):
    t = text.strip()
    on = t.endswith(' on')
    if on:
        t = t[:-3].strip()
    if t in ('evens', 'evs', 'even'):
        frac = Fraction(1)
    else:
        for sep in ('/', '-'):
            if sep in t:
                a, _, b = t.partition(sep)
                break
        else:
            return 'invalid'
        if not a.isdigit() or not b.isdigit() or int(b) == 0 or int(a) == 0:
            return 'invalid'
        frac = Fraction(int(a), int(b))
    if on:
        frac = 1 / frac
    dec = 1 + frac
    cents = math.floor(dec * 100 + Fraction(1, 2))
    return ['%d.%02d' % (cents // 100, cents % 100), '%d/%d' % (frac.numerator, frac.denominator)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('EVS',), ['2.00', '1/1']),
  ('regression: case normalization', ('12/11 ON',), ['1.92', '11/12']),
  ('variant scenario 1', ('11/13',), ['1.85', '11/13']),
  ('variant scenario 2', ('18/1',), ['19.00', '18/1'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('Evens',), ['2.00', '1/1']),
  ('regression: case normalization', ('9/1 ON',), ['1.11', '1/9']),
  ('variant scenario 1', ('5/10',), ['1.50', '1/2']),
  ('variant scenario 2', ('16-5',), ['4.20', '16/5'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('Evens',), ['2.00', '1/1']),
  ('regression: case normalization', ('2/13 ON',), ['7.50', '13/2']),
  ('variant scenario 1', ('5/13 on',), ['3.60', '13/5']),
  ('variant scenario 2', ('13/4',), ['4.25', '13/4'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('16/10 ON',), ['1.63', '5/8']),
  ('variant scenario 1', ('2-1',), ['3.00', '2/1']),
  ('variant scenario 2', ('2/3',), ['1.67', '2/3'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('Evens',), ['2.00', '1/1']),
  ('regression: case normalization', ('7-2 ON',), ['1.29', '2/7']),
  ('variant scenario 1', ('13/2 on',), ['1.15', '2/13']),
  ('variant scenario 2', ('11/3',), ['4.67', '11/3'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(text):
    on = text.strip().endswith(' on')
    t = text.strip().lower()
    if on:
        t = t[:-3].strip()
    if t in ('evens', 'evs', 'even'):
        frac = Fraction(1)
    else:
        for sep in ('/', '-'):
            if sep in t:
                a, _, b = t.partition(sep)
                break
        else:
            return 'invalid'
        if not a.isdigit() or not b.isdigit() or int(b) == 0 or int(a) == 0:
            return 'invalid'
        frac = Fraction(int(a), int(b))
    if on:
        frac = 1 / frac
    dec = 1 + frac
    cents = math.floor(dec * 100 + Fraction(1, 2))
    return ['%d.%02d' % (cents // 100, cents % 100), '%d/%d' % (frac.numerator, frac.denominator)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('EVS',), ['2.00', '1/1']),
  ('regression: case normalization', ('12/11 ON',), ['1.92', '11/12']),
  ('variant scenario 1', ('11/13',), ['1.85', '11/13']),
  ('variant scenario 2', ('18/1',), ['19.00', '18/1'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('Evens',), ['2.00', '1/1']),
  ('regression: case normalization', ('9/1 ON',), ['1.11', '1/9']),
  ('variant scenario 1', ('5/10',), ['1.50', '1/2']),
  ('variant scenario 2', ('16-5',), ['4.20', '16/5'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('Evens',), ['2.00', '1/1']),
  ('regression: case normalization', ('2/13 ON',), ['7.50', '13/2']),
  ('variant scenario 1', ('5/13 on',), ['3.60', '13/5']),
  ('variant scenario 2', ('13/4',), ['4.25', '13/4'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('16/10 ON',), ['1.63', '5/8']),
  ('variant scenario 1', ('2-1',), ['3.00', '2/1']),
  ('variant scenario 2', ('2/3',), ['1.67', '2/3'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: case normalization', ('Evens',), ['2.00', '1/1']),
  ('regression: case normalization', ('7-2 ON',), ['1.29', '2/7']),
  ('variant scenario 1', ('13/2 on',), ['1.15', '2/13']),
  ('variant scenario 2', ('11/3',), ['4.67', '11/3'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
"EVS" and "2/1 ON" are rejected or mispriced.

Parse traditional fractional odds text, case-insensitively: "a/b" or "a-b" with positive integers, "evens"/"evs"/"even" for 1/1, and an optional trailing " on" meaning odds-on (the fraction is inverted, "2/1 on" = 1/2). Zero parts or anything else return "invalid". Return [decimal price rounded half up to two decimals, reduced profit fraction "a/b"].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(text):
    t = text.strip().lower()
    on = t.endswith(' on')
    if on:
        t = t[:-3].strip()
    if t in ('evens', 'evs', 'even'):
        frac = Fraction(1)
    else:
        for sep in ('/', '-'):
            if sep in t:
                a, _, b = t.partition(sep)
                break
        else:
            return 'invalid'
        if not a.isdigit() or not b.isdigit():
            return 'invalid'
        frac = Fraction(int(a), int(b))
    if on:
        frac = 1 / frac
    dec = 1 + frac
    cents = math.floor(dec * 100 + Fraction(1, 2))
    return ['%d.%02d' % (cents // 100, cents % 100), '%d/%d' % (frac.numerator, frac.denominator)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('5/0',), 'invalid'),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('9-11',), ['1.82', '9/11']),
  ('variant scenario 2', ('18/4',), ['5.50', '9/2'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('evens',), ['2.00', '1/1']),
  ('variant scenario 2', ('2/1 on',), ['1.50', '1/2'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('5/0',), 'invalid'),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('12/6',), ['3.00', '2/1']),
  ('variant scenario 2', ('12-1',), ['13.00', '12/1'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('evens',), ['2.00', '1/1']),
  ('variant scenario 2', ('3-2',), ['2.50', '3/2'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('5/0',), 'invalid'),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('6/3',), ['3.00', '2/1']),
  ('variant scenario 2', ('13/5',), ['3.60', '13/5'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(text):
    t = text.strip().lower()
    on = t.endswith(' on')
    if on:
        t = t[:-3].strip()
    if t in ('evens', 'evs', 'even'):
        frac = Fraction(1)
    else:
        for sep in ('/', '-'):
            if sep in t:
                a, _, b = t.partition(sep)
                break
        else:
            return 'invalid'
        if not a.isdigit() or not b.isdigit() or int(b) == 0:
            return 'invalid'
        frac = Fraction(int(a), int(b))
    if on:
        frac = 1 / frac
    dec = 1 + frac
    cents = math.floor(dec * 100 + Fraction(1, 2))
    return ['%d.%02d' % (cents // 100, cents % 100), '%d/%d' % (frac.numerator, frac.denominator)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('5/0',), 'invalid'),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('9-11',), ['1.82', '9/11']),
  ('variant scenario 2', ('18/4',), ['5.50', '9/2'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('evens',), ['2.00', '1/1']),
  ('variant scenario 2', ('2/1 on',), ['1.50', '1/2'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('5/0',), 'invalid'),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('12/6',), ['3.00', '2/1']),
  ('variant scenario 2', ('12-1',), ['13.00', '12/1'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('evens',), ['2.00', '1/1']),
  ('variant scenario 2', ('3-2',), ['2.50', '3/2'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: zero part guard', ('5/0',), 'invalid'),
  ('regression: zero part guard', ('0/1',), 'invalid'),
  ('variant scenario 1', ('6/3',), ['3.00', '2/1']),
  ('variant scenario 2', ('13/5',), ['3.60', '13/5'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
"5/0" raises a division error and "0/1" is priced at 1.00.

Parse traditional fractional odds text, case-insensitively: "a/b" or "a-b" with positive integers, "evens"/"evs"/"even" for 1/1, and an optional trailing " on" meaning odds-on (the fraction is inverted, "2/1 on" = 1/2). Zero parts or anything else return "invalid". Return [decimal price rounded half up to two decimals, reduced profit fraction "a/b"].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(text):
    t = text.strip().lower()
    on = t.endswith(' on')
    if on:
        t = t[:-3].strip()
    if t in ('evens', 'evs', 'even'):
        frac = Fraction(1)
    else:
        for sep in ('/', '-'):
            if sep in t:
                a, _, b = t.partition(sep)
                break
        else:
            return 'invalid'
        if not a.isdigit() or not b.isdigit() or int(b) == 0 or int(a) == 0:
            return 'invalid'
        frac = Fraction(int(a), int(b))
    if on:
        frac = 1 / frac
    dec = 1 + frac
    cents = math.floor(dec * 100 + Fraction(1, 2))
    return ['%.2f' % float(dec), '%d/%d' % (frac.numerator, frac.denominator)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('14/13',), ['2.08', '14/13']),
  ('regression: decimal half up', ('1/8',), ['1.13', '1/8']),
  ('variant scenario 1', ('4-1',), ['5.00', '4/1']),
  ('variant scenario 2', ('11/2',), ['6.50', '11/2'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('7/13',), ['1.54', '7/13']),
  ('regression: decimal half up', ('9/8',), ['2.13', '9/8']),
  ('variant scenario 1', ('15-4',), ['4.75', '15/4']),
  ('variant scenario 2', ('4-8 on',), ['3.00', '2/1'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('18/11',), ['2.64', '18/11']),
  ('regression: decimal half up', ('1/8',), ['1.13', '1/8']),
  ('variant scenario 1', ('19/13',), ['2.46', '19/13']),
  ('variant scenario 2', ('6/10',), ['1.60', '3/5'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('7/13',), ['1.54', '7/13']),
  ('regression: decimal half up', ('8/13 on',), ['2.63', '13/8']),
  ('variant scenario 1', ('5-2',), ['3.50', '5/2']),
  ('variant scenario 2', ('12-10',), ['2.20', '6/5'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('10-13',), ['1.77', '10/13']),
  ('regression: decimal half up', ('13-8',), ['2.63', '13/8']),
  ('variant scenario 1', ('EVS',), ['2.00', '1/1']),
  ('variant scenario 2', ('8/2',), ['5.00', '4/1'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(text):
    t = text.strip().lower()
    on = t.endswith(' on')
    if on:
        t = t[:-3].strip()
    if t in ('evens', 'evs', 'even'):
        frac = Fraction(1)
    else:
        for sep in ('/', '-'):
            if sep in t:
                a, _, b = t.partition(sep)
                break
        else:
            return 'invalid'
        if not a.isdigit() or not b.isdigit() or int(b) == 0 or int(a) == 0:
            return 'invalid'
        frac = Fraction(int(a), int(b))
    if on:
        frac = 1 / frac
    dec = 1 + frac
    cents = math.floor(dec * 100)
    return ['%d.%02d' % (cents // 100, cents % 100), '%d/%d' % (frac.numerator, frac.denominator)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
def run(args):
    try:
        return solve(*args)
    except Exception as exc:
        return 'raised ' + type(exc).__name__
cases = [[('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('14/13',), ['2.08', '14/13']),
  ('regression: decimal half up', ('1/8',), ['1.13', '1/8']),
  ('variant scenario 1', ('4-1',), ['5.00', '4/1']),
  ('variant scenario 2', ('11/2',), ['6.50', '11/2'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('7/13',), ['1.54', '7/13']),
  ('regression: decimal half up', ('9/8',), ['2.13', '9/8']),
  ('variant scenario 1', ('15-4',), ['4.75', '15/4']),
  ('variant scenario 2', ('4-8 on',), ['3.00', '2/1'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('18/11',), ['2.64', '18/11']),
  ('regression: decimal half up', ('1/8',), ['1.13', '1/8']),
  ('variant scenario 1', ('19/13',), ['2.46', '19/13']),
  ('variant scenario 2', ('6/10',), ['1.60', '3/5'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('7/13',), ['1.54', '7/13']),
  ('regression: decimal half up', ('8/13 on',), ['2.63', '13/8']),
  ('variant scenario 1', ('5-2',), ['3.50', '5/2']),
  ('variant scenario 2', ('12-10',), ['2.20', '6/5'])],
 [('control five to two', ('5/2',), ['3.50', '5/2']),
  ('control hyphen separator', ('11-4',), ['3.75', '11/4']),
  ('boundary evens alias', ('EVS',), ['2.00', '1/1']),
  ('boundary odds-on suffix', ('2/1 on',), ['1.50', '1/2']),
  ('boundary unreduced input', ('4/6',), ['1.67', '2/3']),
  ('boundary zero denominator', ('5/0',), 'invalid'),
  ('control half-up rounding', ('1/8',), ['1.13', '1/8']),
  ('regression: decimal half up', ('10-13',), ['1.77', '10/13']),
  ('regression: decimal half up', ('13-8',), ['2.63', '13/8']),
  ('variant scenario 1', ('EVS',), ['2.00', '1/1']),
  ('variant scenario 2', ('8/2',), ['5.00', '4/1'])]]
for label, args, expected in cases[N - 1]:
    check(label, run(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
"1/8" is shown as 1.12 instead of 1.13.

Parse traditional fractional odds text, case-insensitively: "a/b" or "a-b" with positive integers, "evens"/"evs"/"even" for 1/1, and an optional trailing " on" meaning odds-on (the fraction is inverted, "2/1 on" = 1/2). Zero parts or anything else return "invalid". Return [decimal price rounded half up to two decimals, reduced profit fraction "a/b"].

split: open-access


prompt:
The margin column repeats the overround (4.71 instead of 4.50 for 1.91/1.91).

Market book analysis for decimal prices (strings, each > 1, else "invalid"). Implied probability is 1/d; book = sum of implied probabilities. Return [overround percent (book - 1) * 100, bookmaker margin percent (1 - 1/book) * 100, fair prices d * book for proportional margin removal], every number rounded half up to two decimals (negative values are rounded toward +infinity at the half) and formatted with two decimals.

split: open-access


prompt:
No-vig prices come out shorter than the quoted prices.

Market book analysis for decimal prices (strings, each > 1, else "invalid"). Implied probability is 1/d; book = sum of implied probabilities. Return [overround percent (book - 1) * 100, bookmaker margin percent (1 - 1/book) * 100, fair prices d * book for proportional margin removal], every number rounded half up to two decimals (negative values are rounded toward +infinity at the half) and formatted with two decimals.

split: open-access


prompt:
Book totals drift because prices are rounded to one decimal before inverting.

Market book analysis for decimal prices (strings, each > 1, else "invalid"). Implied probability is 1/d; book = sum of implied probabilities. Return [overround percent (book - 1) * 100, bookmaker margin percent (1 - 1/book) * 100, fair prices d * book for proportional margin removal], every number rounded half up to two decimals (negative values are rounded toward +infinity at the half) and formatted with two decimals.

split: open-access


prompt:
An under-round book shows "-1.99" style garbage instead of "-0.01".

Market book analysis for decimal prices (strings, each > 1, else "invalid"). Implied probability is 1/d; book = sum of implied probabilities. Return [overround percent (book - 1) * 100, bookmaker margin percent (1 - 1/book) * 100, fair prices d * book for proportional margin removal], every number rounded half up to two decimals (negative values are rounded toward +infinity at the half) and formatted with two decimals.

split: open-access