FA-84526 / Betting odds conversion / Open access
Off-grid handicap lines accepted or quarter lines rejected · case 01
A -0.3 line is settled, or a legitimate -0.25 line is rejected.
ROOT CAUSE
There is no check that the line is a multiple of 0.25.
VERIFIED REPAIR
Reject lines whose quadruple is not an integer.
Unsuccessful approach: Checking for multiples of 0.5 rejects every quarter line.
Case contract
Asian handicap bet on the home side. line is a multiple of 0.25 (else "invalid line"). Whole and half lines are a single bet; quarter lines split the stake equally between line - 0.25 and line + 0.25. Each part: margin = home_goals - away_goals + part_line; positive wins stake_part * price, zero refunds stake_part, negative loses. Return [total return in cents rounded down, label] where the label is win, half-win, push, half-lose or lose from the summed part outcomes.
Why this case matters
Asian handicap settlement with split quarter lines is a common source of payout disputes.
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(line, home_goals, away_goals, stake_cents, price):
L = Fraction(line)
if (L * 2).denominator == 1:
parts = [L]
else:
parts = [L - Fraction(1, 4), L + Fraction(1, 4)]
d = Fraction(price)
share = Fraction(stake_cents, len(parts))
ret = Fraction(0)
res = []
for p in parts:
m = home_goals - away_goals + p
if m > 0:
ret += share * d
res.append(1)
elif m == 0:
ret += share
res.append(0)
else:
res.append(-1)
score = sum(res) * 2 // len(parts)
label = {2: 'win', 1: 'half-win', 0: 'push', -1: 'half-lose', -2: 'lose'}[score]
return [math.floor(ret), label]
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 half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-0.75', 1, 0, 999, '2.00'), [1498, 'half-win']),
('regression: quarter grid guard', ('-0.3', 3, 0, 500, '2.00'), 'invalid line'),
('variant scenario 1', ('+2', 3, 0, 1000, '2.00'), [2000, 'win']),
('variant scenario 2', ('0', 4, 4, 500, '1.90'), [500, 'push'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-1.75', 1, 2, 250, '2.05'), [0, 'lose']),
('regression: quarter grid guard', ('-0.3', 2, 4, 999, '1.90'), 'invalid line'),
('variant scenario 1', ('+2', 2, 4, 500, '2.00'), [500, 'push']),
('variant scenario 2', ('+2', 2, 2, 500, '1.90'), [950, 'win'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-0.25', 0, 4, 250, '2.00'), [0, 'lose']),
('regression: quarter grid guard', ('-0.3', 0, 2, 500, '1.90'), 'invalid line'),
('variant scenario 1', ('0', 4, 3, 999, '1.85'), [1848, 'win']),
('variant scenario 2', ('-0.75', 1, 2, 500, '1.90'), [0, 'lose'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('+0.25', 3, 2, 1000, '1.85'), [1850, 'win']),
('regression: quarter grid guard', ('-0.3', 2, 1, 500, '2.00'), 'invalid line'),
('variant scenario 1', ('0', 3, 4, 999, '2.00'), [0, 'lose']),
('variant scenario 2', ('-1.75', 3, 4, 999, '2.05'), [0, 'lose'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-1.75', 1, 3, 1000, '1.85'), [0, 'lose']),
('regression: quarter grid guard', ('-0.3', 0, 2, 500, '2.00'), 'invalid line'),
('variant scenario 1', ('+2', 2, 4, 250, '2.00'), [250, 'push']),
('variant scenario 2', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win'])]]
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 half line win | [1900, 'win'] | [1900, 'win'] | Passed |
| boundary whole line push | [1000, 'push'] | [1000, 'push'] | Passed |
| boundary quarter half-lose | [500, 'half-lose'] | [500, 'half-lose'] | Passed |
| boundary quarter half-win | [1500, 'half-win'] | [1500, 'half-win'] | Passed |
| control lose | [0, 'lose'] | [0, 'lose'] | Passed |
| boundary off-grid line | [1900, 'win'] | invalid line | Failed |
| regression: quarter grid guard | [1498, 'half-win'] | [1498, 'half-win'] | Passed |
| regression: quarter grid guard | [1000, 'win'] | invalid line | Failed |
| variant scenario 1 | [2000, 'win'] | [2000, 'win'] | Passed |
| variant scenario 2 | [500, 'push'] | [500, 'push'] | Passed |
SHA-256 / 37ba98369d4813dc76736694549be08e95c2da7c02b03522eb20d64632f75b20
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(line, home_goals, away_goals, stake_cents, price):
L = Fraction(line)
if (L * 2).denominator != 1:
return 'invalid line'
if (L * 2).denominator == 1:
parts = [L]
else:
parts = [L - Fraction(1, 4), L + Fraction(1, 4)]
d = Fraction(price)
share = Fraction(stake_cents, len(parts))
ret = Fraction(0)
res = []
for p in parts:
m = home_goals - away_goals + p
if m > 0:
ret += share * d
res.append(1)
elif m == 0:
ret += share
res.append(0)
else:
res.append(-1)
score = sum(res) * 2 // len(parts)
label = {2: 'win', 1: 'half-win', 0: 'push', -1: 'half-lose', -2: 'lose'}[score]
return [math.floor(ret), label]
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 half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-0.75', 1, 0, 999, '2.00'), [1498, 'half-win']),
('regression: quarter grid guard', ('-0.3', 3, 0, 500, '2.00'), 'invalid line'),
('variant scenario 1', ('+2', 3, 0, 1000, '2.00'), [2000, 'win']),
('variant scenario 2', ('0', 4, 4, 500, '1.90'), [500, 'push'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-1.75', 1, 2, 250, '2.05'), [0, 'lose']),
('regression: quarter grid guard', ('-0.3', 2, 4, 999, '1.90'), 'invalid line'),
('variant scenario 1', ('+2', 2, 4, 500, '2.00'), [500, 'push']),
('variant scenario 2', ('+2', 2, 2, 500, '1.90'), [950, 'win'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-0.25', 0, 4, 250, '2.00'), [0, 'lose']),
('regression: quarter grid guard', ('-0.3', 0, 2, 500, '1.90'), 'invalid line'),
('variant scenario 1', ('0', 4, 3, 999, '1.85'), [1848, 'win']),
('variant scenario 2', ('-0.75', 1, 2, 500, '1.90'), [0, 'lose'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('+0.25', 3, 2, 1000, '1.85'), [1850, 'win']),
('regression: quarter grid guard', ('-0.3', 2, 1, 500, '2.00'), 'invalid line'),
('variant scenario 1', ('0', 3, 4, 999, '2.00'), [0, 'lose']),
('variant scenario 2', ('-1.75', 3, 4, 999, '2.05'), [0, 'lose'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-1.75', 1, 3, 1000, '1.85'), [0, 'lose']),
('regression: quarter grid guard', ('-0.3', 0, 2, 500, '2.00'), 'invalid line'),
('variant scenario 1', ('+2', 2, 4, 250, '2.00'), [250, 'push']),
('variant scenario 2', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win'])]]
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 half line win | [1900, 'win'] | [1900, 'win'] | Passed |
| boundary whole line push | [1000, 'push'] | [1000, 'push'] | Passed |
| boundary quarter half-lose | invalid line | [500, 'half-lose'] | Failed |
| boundary quarter half-win | invalid line | [1500, 'half-win'] | Failed |
| control lose | [0, 'lose'] | [0, 'lose'] | Passed |
| boundary off-grid line | invalid line | invalid line | Passed |
| regression: quarter grid guard | invalid line | [1498, 'half-win'] | Failed |
| regression: quarter grid guard | invalid line | invalid line | Passed |
| variant scenario 1 | [2000, 'win'] | [2000, 'win'] | Passed |
| variant scenario 2 | [500, 'push'] | [500, 'push'] | Passed |
SHA-256 / 80376f303dac83491c991e6a9db48c5b4375831015547f78b46d601f7fd45080
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(line, home_goals, away_goals, stake_cents, price):
L = Fraction(line)
if (L * 4).denominator != 1:
return 'invalid line'
if (L * 2).denominator == 1:
parts = [L]
else:
parts = [L - Fraction(1, 4), L + Fraction(1, 4)]
d = Fraction(price)
share = Fraction(stake_cents, len(parts))
ret = Fraction(0)
res = []
for p in parts:
m = home_goals - away_goals + p
if m > 0:
ret += share * d
res.append(1)
elif m == 0:
ret += share
res.append(0)
else:
res.append(-1)
score = sum(res) * 2 // len(parts)
label = {2: 'win', 1: 'half-win', 0: 'push', -1: 'half-lose', -2: 'lose'}[score]
return [math.floor(ret), label]
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 half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-0.75', 1, 0, 999, '2.00'), [1498, 'half-win']),
('regression: quarter grid guard', ('-0.3', 3, 0, 500, '2.00'), 'invalid line'),
('variant scenario 1', ('+2', 3, 0, 1000, '2.00'), [2000, 'win']),
('variant scenario 2', ('0', 4, 4, 500, '1.90'), [500, 'push'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-1.75', 1, 2, 250, '2.05'), [0, 'lose']),
('regression: quarter grid guard', ('-0.3', 2, 4, 999, '1.90'), 'invalid line'),
('variant scenario 1', ('+2', 2, 4, 500, '2.00'), [500, 'push']),
('variant scenario 2', ('+2', 2, 2, 500, '1.90'), [950, 'win'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-0.25', 0, 4, 250, '2.00'), [0, 'lose']),
('regression: quarter grid guard', ('-0.3', 0, 2, 500, '1.90'), 'invalid line'),
('variant scenario 1', ('0', 4, 3, 999, '1.85'), [1848, 'win']),
('variant scenario 2', ('-0.75', 1, 2, 500, '1.90'), [0, 'lose'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('+0.25', 3, 2, 1000, '1.85'), [1850, 'win']),
('regression: quarter grid guard', ('-0.3', 2, 1, 500, '2.00'), 'invalid line'),
('variant scenario 1', ('0', 3, 4, 999, '2.00'), [0, 'lose']),
('variant scenario 2', ('-1.75', 3, 4, 999, '2.05'), [0, 'lose'])],
[('control half line win', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win']),
('boundary whole line push', ('-1', 2, 1, 1000, '1.90'), [1000, 'push']),
('boundary quarter half-lose', ('-0.25', 1, 1, 1000, '1.90'), [500, 'half-lose']),
('boundary quarter half-win', ('-0.75', 1, 0, 1000, '2.00'), [1500, 'half-win']),
('control lose', ('+0.5', 0, 2, 1000, '1.90'), [0, 'lose']),
('boundary off-grid line', ('-0.3', 1, 0, 1000, '1.90'), 'invalid line'),
('regression: quarter grid guard', ('-1.75', 1, 3, 1000, '1.85'), [0, 'lose']),
('regression: quarter grid guard', ('-0.3', 0, 2, 500, '2.00'), 'invalid line'),
('variant scenario 1', ('+2', 2, 4, 250, '2.00'), [250, 'push']),
('variant scenario 2', ('-0.5', 1, 0, 1000, '1.90'), [1900, 'win'])]]
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 half line win | [1900, 'win'] | [1900, 'win'] | Passed |
| boundary whole line push | [1000, 'push'] | [1000, 'push'] | Passed |
| boundary quarter half-lose | [500, 'half-lose'] | [500, 'half-lose'] | Passed |
| boundary quarter half-win | [1500, 'half-win'] | [1500, 'half-win'] | Passed |
| control lose | [0, 'lose'] | [0, 'lose'] | Passed |
| boundary off-grid line | invalid line | invalid line | Passed |
| regression: quarter grid guard | [1498, 'half-win'] | [1498, 'half-win'] | Passed |
| regression: quarter grid guard | invalid line | invalid line | Passed |
| variant scenario 1 | [2000, 'win'] | [2000, 'win'] | Passed |
| variant scenario 2 | [500, 'push'] | [500, 'push'] | Passed |
SHA-256 / 570e8e8d1017ddc0cfeb493b11872fc4c2bd60e447d9740830829602ed1f3df5
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:31.763307+00:00.
Case digest / c56d43ec24d1ec61c1221c19b0ab4c3e10687c88f38d72b10c4b4b5e7a5cfa22