FA-84661 / Betting odds conversion / Open access
Deduction taken from the stake as well as the winnings · case 01
Winning bets lose part of their stake to the deduction.
ROOT CAUSE
The deduction is applied to the whole return.
THE FAILURE
The deduction is applied to the whole return.
Unsuccessful approach: Charging the deduction per pound of stake still reduces the returned stake.
Case contract
Non-runner deduction for a winning bet. Each withdrawn runner's decimal price maps to pence-in-the-pound from the first band whose limit it does not exceed: [('1.30', 75), ('1.40', 70), ('1.53', 65), ('1.62', 60), ('1.80', 55), ('1.95', 50), ('2.20', 45), ('2.50', 40), ('2.75', 35), ('3.25', 30), ('4.00', 25), ('5.00', 20), ('6.50', 15), ('10.00', 10), ('15.00', 5)]; above 15.00 it is 0. Deductions from several withdrawals are summed and capped at 75. The deduction applies to winnings only: return = stake + floor(stake * (price - 1) * (100 - deduction) / 100). Return [deduction, return cents].
Why this case matters
Racing settlement reduces winnings when a runner is withdrawn after prices were struck.
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(stake_cents, price, withdrawn):
TABLE = [('1.30', 75), ('1.40', 70), ('1.53', 65), ('1.62', 60), ('1.80', 55), ('1.95', 50), ('2.20', 45), ('2.50', 40), ('2.75', 35), ('3.25', 30), ('4.00', 25), ('5.00', 20), ('6.50', 15), ('10.00', 10), ('15.00', 5)]
def ded(p):
p = Fraction(p)
for limit, pence in TABLE:
if p <= Fraction(limit):
return pence
return 0
total = min(75, sum(ded(w) for w in withdrawn))
profit = stake_cents * (Fraction(price) - 1)
return [total, math.floor((stake_cents + profit) * (100 - total) / 100)]
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 no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (1000, '10.45', ['1.62', '2.75', '16.11']), [75, 3362]),
('variant scenario 1', (250, '5.08', []), [0, 1270]),
('variant scenario 2', (250, '10.79', []), [0, 2697])],
[('control no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (250, '8.73', ['10.40', '2.50', '1.40']), [75, 733]),
('variant scenario 1', (500, '1.61', ['4.18']), [20, 744]),
('variant scenario 2', (1000, '8.66', []), [0, 8660])],
[('control no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (500, '3.28', ['17.50', '17.84', '5.27']), [15, 1469]),
('variant scenario 1', (500, '6.94', ['5.00', '6.50', '19.18']), [35, 2430]),
('variant scenario 2', (500, '7.47', ['14.89', '3.00', '1.30']), [75, 1308])],
[('control no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (1000, '7.16', ['16.19', '5.05', '2.50']), [55, 3772]),
('variant scenario 1', (250, '11.49', ['2.75', '1.40', '12.13']), [75, 905]),
('variant scenario 2', (1000, '5.49', []), [0, 5490])],
[('control no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (250, '11.85', ['6.50']), [15, 2555]),
('variant scenario 1', (500, '7.88', ['15.89']), [0, 3940]),
('variant scenario 2', (500, '10.66', ['1.80', '1.48', '2.50']), [75, 1707])]]
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 no withdrawal | [0, 5000] | [0, 5000] | Passed |
| boundary price on band limit | [40, 3000] | [40, 3400] | Failed |
| control long-shot withdrawal | [0, 5000] | [0, 5000] | Passed |
| boundary cap at 75 | [75, 750] | [75, 1500] | Failed |
| control two withdrawals | [40, 1800] | [40, 2200] | Failed |
| regression: deduction base | [75, 2612] | [75, 3362] | Failed |
| variant scenario 1 | [0, 1270] | [0, 1270] | Passed |
| variant scenario 2 | [0, 2697] | [0, 2697] | Passed |
SHA-256 / be304468d8ddbda59edead5db844756f1a1b32b726917803d333240ac8eb7851
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(stake_cents, price, withdrawn):
TABLE = [('1.30', 75), ('1.40', 70), ('1.53', 65), ('1.62', 60), ('1.80', 55), ('1.95', 50), ('2.20', 45), ('2.50', 40), ('2.75', 35), ('3.25', 30), ('4.00', 25), ('5.00', 20), ('6.50', 15), ('10.00', 10), ('15.00', 5)]
def ded(p):
p = Fraction(p)
for limit, pence in TABLE:
if p <= Fraction(limit):
return pence
return 0
total = min(75, sum(ded(w) for w in withdrawn))
profit = stake_cents * (Fraction(price) - 1)
return [total, stake_cents + math.floor(profit - stake_cents * total / Fraction(100))]
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 no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (1000, '10.45', ['1.62', '2.75', '16.11']), [75, 3362]),
('variant scenario 1', (250, '5.08', []), [0, 1270]),
('variant scenario 2', (250, '10.79', []), [0, 2697])],
[('control no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (250, '8.73', ['10.40', '2.50', '1.40']), [75, 733]),
('variant scenario 1', (500, '1.61', ['4.18']), [20, 744]),
('variant scenario 2', (1000, '8.66', []), [0, 8660])],
[('control no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (500, '3.28', ['17.50', '17.84', '5.27']), [15, 1469]),
('variant scenario 1', (500, '6.94', ['5.00', '6.50', '19.18']), [35, 2430]),
('variant scenario 2', (500, '7.47', ['14.89', '3.00', '1.30']), [75, 1308])],
[('control no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (1000, '7.16', ['16.19', '5.05', '2.50']), [55, 3772]),
('variant scenario 1', (250, '11.49', ['2.75', '1.40', '12.13']), [75, 905]),
('variant scenario 2', (1000, '5.49', []), [0, 5490])],
[('control no withdrawal', (1000, '5.00', []), [0, 5000]),
('boundary price on band limit', (1000, '5.00', ['2.50']), [40, 3400]),
('control long-shot withdrawal', (1000, '5.00', ['21.00']), [0, 5000]),
('boundary cap at 75', (1000, '3.00', ['1.50', '1.50']), [75, 1500]),
('control two withdrawals', (1000, '3.00', ['4.00', '6.00']), [40, 2200]),
('regression: deduction base', (250, '11.85', ['6.50']), [15, 2555]),
('variant scenario 1', (500, '7.88', ['15.89']), [0, 3940]),
('variant scenario 2', (500, '10.66', ['1.80', '1.48', '2.50']), [75, 1707])]]
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 no withdrawal | [0, 5000] | [0, 5000] | Passed |
| boundary price on band limit | [40, 4600] | [40, 3400] | Failed |
| control long-shot withdrawal | [0, 5000] | [0, 5000] | Passed |
| boundary cap at 75 | [75, 2250] | [75, 1500] | Failed |
| control two withdrawals | [40, 2600] | [40, 2200] | Failed |
| regression: deduction base | [75, 9700] | [75, 3362] | Failed |
| variant scenario 1 | [0, 1270] | [0, 1270] | Passed |
| variant scenario 2 | [0, 2697] | [0, 2697] | Passed |
SHA-256 / 8eb7143fb13eed5c5aadaa6c2c550881b3264427e4c8f445eab3964d0216aa3a
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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:33.163989+00:00.
Case digest / b5956e3683f454304a9d014341fe51d4525c5763c338729cf5f0390e998acffb