FA-84401 / Betting odds conversion / Open access
Zero numerator or denominator accepted · case 01
"5/0" raises a division error and "0/1" is priced at 1.00.
ROOT CAUSE
The parser does not reject zero parts.
VERIFIED REPAIR
Reject zero numerators and denominators.
Unsuccessful approach: Guarding only the denominator still accepts a zero-profit "0/1" price.
Case contract
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"].
Why this case matters
Racing feeds and manual price entry use traditional fractional notation with odds-on suffixes.
1 / The failure
Exit 1"""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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control five to two | ['3.50', '5/2'] | ['3.50', '5/2'] | Passed |
| control hyphen separator | ['3.75', '11/4'] | ['3.75', '11/4'] | Passed |
| boundary evens alias | ['2.00', '1/1'] | ['2.00', '1/1'] | Passed |
| boundary odds-on suffix | ['1.50', '1/2'] | ['1.50', '1/2'] | Passed |
| boundary unreduced input | ['1.67', '2/3'] | ['1.67', '2/3'] | Passed |
| boundary zero denominator | raised ZeroDivisionError | invalid | Failed |
| control half-up rounding | ['1.13', '1/8'] | ['1.13', '1/8'] | Passed |
| regression: zero part guard | raised ZeroDivisionError | invalid | Failed |
| regression: zero part guard | ['1.00', '0/1'] | invalid | Failed |
| variant scenario 1 | ['1.82', '9/11'] | ['1.82', '9/11'] | Passed |
| variant scenario 2 | ['5.50', '9/2'] | ['5.50', '9/2'] | Passed |
SHA-256 / 0ef8c3a33a0a527ec008e51f766b574eb4e7a143c544a8aad9218e4eed13239a
2 / The unsuccessful fix
Exit 1"""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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control five to two | ['3.50', '5/2'] | ['3.50', '5/2'] | Passed |
| control hyphen separator | ['3.75', '11/4'] | ['3.75', '11/4'] | Passed |
| boundary evens alias | ['2.00', '1/1'] | ['2.00', '1/1'] | Passed |
| boundary odds-on suffix | ['1.50', '1/2'] | ['1.50', '1/2'] | Passed |
| boundary unreduced input | ['1.67', '2/3'] | ['1.67', '2/3'] | Passed |
| boundary zero denominator | invalid | invalid | Passed |
| control half-up rounding | ['1.13', '1/8'] | ['1.13', '1/8'] | Passed |
| regression: zero part guard | invalid | invalid | Passed |
| regression: zero part guard | ['1.00', '0/1'] | invalid | Failed |
| variant scenario 1 | ['1.82', '9/11'] | ['1.82', '9/11'] | Passed |
| variant scenario 2 | ['5.50', '9/2'] | ['5.50', '9/2'] | Passed |
SHA-256 / 2b7019834c475bc88e1d4cdd3033d1682de6f32bae984ab11a73aec9d3afa9a0
3 / The verified repair
Exit 0"""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 ['%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)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| control five to two | ['3.50', '5/2'] | ['3.50', '5/2'] | Passed |
| control hyphen separator | ['3.75', '11/4'] | ['3.75', '11/4'] | Passed |
| boundary evens alias | ['2.00', '1/1'] | ['2.00', '1/1'] | Passed |
| boundary odds-on suffix | ['1.50', '1/2'] | ['1.50', '1/2'] | Passed |
| boundary unreduced input | ['1.67', '2/3'] | ['1.67', '2/3'] | Passed |
| boundary zero denominator | invalid | invalid | Passed |
| control half-up rounding | ['1.13', '1/8'] | ['1.13', '1/8'] | Passed |
| regression: zero part guard | invalid | invalid | Passed |
| regression: zero part guard | invalid | invalid | Passed |
| variant scenario 1 | ['1.82', '9/11'] | ['1.82', '9/11'] | Passed |
| variant scenario 2 | ['5.50', '9/2'] | ['5.50', '9/2'] | Passed |
SHA-256 / d77132b3aa21cae9e4ab73d680c5a5c94f92266c2142854edf14f4669901a9af
Verification & scope
Stipulated, bounded toy contract stated in the contract field; not a claim of conformance with any operator, exchange or regulator rule set. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:50:30.524581+00:00.
Case digest / a6c74f4a94a85344750dbb688a37ba92f2176ba06527e0349945b52058fe7fe9