FA-84046 / Sports scoring and tiebreakers / Open access
Losing bonus margin off by one · case 01
A seven-point defeat earns no losing bonus.
ROOT CAUSE
The losing bonus uses a strict margin below seven.
VERIFIED REPAIR
Award the losing bonus for a defeat by 7 or fewer points.
Unsuccessful approach: Using the older five-point window still denies bonuses for six- and seven-point defeats.
Case contract
Rugby union league points. results rows are [team, tries, score, opponent, opp_tries, opp_score]. Win 4 points, draw 2, loss 0. A try bonus point is earned by any team scoring 4 or more tries, and a losing bonus point by a team that loses by 7 points or fewer (both can apply to a loser). Rank by points, then wins, then points difference, then name. Return [team, points, wins, points difference] rows for teams that appear.
Why this case matters
Bonus-point tables are tight; each threshold changes qualification.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(results):
table = {}
for t1, tr1, s1, t2, tr2, s2 in results:
for team, tries, s, o in ((t1, tr1, s1, s2), (t2, tr2, s2, s1)):
row = table.setdefault(team, [0, 0, 0])
if s > o:
row[0] += 4
row[1] += 1
elif s == o:
row[0] += 2
if tries >= 4:
row[0] += 1
if s < o and o - s < 7:
row[0] += 1
row[2] += s - o
order = sorted(table, key=lambda t: (-table[t][0], -table[t][1], -table[t][2], t))
return [[t] + table[t] for t in order]
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 plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Sale', 5, 22, 'Leeds', 4, 15], ['Bath', 3, 20, 'Leeds', 5, 15]],),
[['Sale', 5, 1, 7], ['Bath', 4, 1, 5], ['Leeds', 4, 0, -12]]),
('variant scenario 1',
([['Leeds', 4, 30, 'Sale', 6, 24],
['Bath', 6, 22, 'Leeds', 5, 5],
['Bath', 3, 12, 'Leeds', 0, 20]],),
[['Leeds', 10, 2, -3], ['Bath', 5, 1, 9], ['Sale', 2, 0, -6]]),
('variant scenario 2',
([['Leeds', 4, 33, 'Sale', 1, 7], ['Wasps', 5, 20, 'Sale', 5, 12]],),
[['Leeds', 5, 1, 26], ['Wasps', 5, 1, 8], ['Sale', 1, 0, -34]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Wasps', 4, 24, 'Leeds', 4, 15],
['Wasps', 4, 5, 'Bath', 6, 24],
['Leeds', 2, 12, 'Wasps', 2, 5],
['Wasps', 5, 30, 'Leeds', 1, 30],
['Leeds', 1, 3, 'Sale', 0, 24]],),
[['Wasps', 10, 1, -17], ['Leeds', 7, 1, -23], ['Bath', 5, 1, 19], ['Sale', 4, 1, 21]]),
('variant scenario 1',
([['Wasps', 5, 22, 'Sale', 0, 27], ['Sale', 1, 33, 'Bath', 5, 24]],),
[['Sale', 8, 2, 14], ['Wasps', 2, 0, -5], ['Bath', 1, 0, -9]]),
('variant scenario 2',
([['Leeds', 1, 20, 'Bath', 5, 17], ['Leeds', 0, 30, 'Wasps', 4, 24]],),
[['Leeds', 8, 2, 9], ['Bath', 2, 0, -3], ['Wasps', 2, 0, -6]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Sale', 6, 22, 'Leeds', 4, 7],
['Sale', 1, 5, 'Leeds', 2, 22],
['Sale', 5, 17, 'Wasps', 6, 24],
['Wasps', 1, 15, 'Sale', 3, 30],
['Wasps', 4, 7, 'Sale', 4, 27]],),
[['Sale', 16, 3, 26], ['Wasps', 6, 1, -28], ['Leeds', 5, 1, 2]]),
('variant scenario 1',
([['Bath', 0, 22, 'Wasps', 5, 3], ['Wasps', 4, 12, 'Sale', 6, 15]],),
[['Sale', 5, 1, 3], ['Bath', 4, 1, 19], ['Wasps', 3, 0, -22]]),
('variant scenario 2',
([['Sale', 1, 3, 'Bath', 0, 22], ['Wasps', 0, 22, 'Leeds', 6, 5]],),
[['Bath', 4, 1, 19], ['Wasps', 4, 1, 17], ['Leeds', 1, 0, -17], ['Sale', 0, 0, -19]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Leeds', 1, 22, 'Wasps', 4, 27],
['Leeds', 4, 5, 'Sale', 4, 22],
['Leeds', 6, 7, 'Wasps', 2, 20],
['Wasps', 3, 10, 'Sale', 4, 17],
['Leeds', 4, 5, 'Sale', 2, 30],
['Wasps', 5, 15, 'Sale', 4, 5],
['Leeds', 5, 20, 'Sale', 0, 17],
['Bath', 5, 12, 'Leeds', 3, 7]],),
[['Sale', 16, 3, 36], ['Wasps', 15, 3, 21], ['Leeds', 10, 1, -62], ['Bath', 5, 1, 5]]),
('variant scenario 1',
([['Bath', 1, 15, 'Leeds', 4, 5],
['Sale', 0, 27, 'Leeds', 1, 15],
['Sale', 4, 20, 'Leeds', 2, 20]],),
[['Sale', 7, 1, 12], ['Bath', 4, 1, 10], ['Leeds', 3, 0, -22]]),
('variant scenario 2',
([['Leeds', 6, 12, 'Wasps', 4, 22],
['Bath', 5, 17, 'Wasps', 0, 3],
['Wasps', 4, 17, 'Leeds', 3, 3]],),
[['Wasps', 10, 2, 10], ['Bath', 5, 1, 14], ['Leeds', 1, 0, -24]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Leeds', 3, 22, 'Bath', 2, 15],
['Bath', 1, 27, 'Sale', 1, 7],
['Sale', 2, 15, 'Leeds', 0, 15],
['Leeds', 3, 3, 'Bath', 0, 24],
['Bath', 3, 33, 'Leeds', 6, 10]],),
[['Bath', 13, 3, 57], ['Leeds', 7, 1, -37], ['Sale', 2, 0, -20]]),
('variant scenario 1',
([['Leeds', 1, 3, 'Sale', 2, 30],
['Bath', 3, 17, 'Wasps', 6, 5],
['Bath', 6, 27, 'Wasps', 5, 3],
['Leeds', 5, 3, 'Wasps', 3, 10],
['Bath', 4, 5, 'Wasps', 0, 22]],),
[['Bath', 10, 2, 19], ['Wasps', 10, 2, -12], ['Sale', 4, 1, 27], ['Leeds', 2, 0, -34]]),
('variant scenario 2',
([['Sale', 6, 27, 'Wasps', 3, 12],
['Leeds', 6, 17, 'Sale', 5, 27],
['Sale', 5, 22, 'Leeds', 3, 10],
['Sale', 5, 22, 'Leeds', 5, 17],
['Bath', 6, 17, 'Leeds', 0, 24],
['Bath', 0, 22, 'Leeds', 0, 20],
['Wasps', 0, 3, 'Sale', 1, 15]],),
[['Sale', 24, 5, 54], ['Leeds', 8, 1, -22], ['Bath', 6, 1, -5], ['Wasps', 0, 0, -27]])]]
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 plain win | [['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]] | [['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]] | Passed |
| boundary losing by seven | [['Bath', 4, 1, 7], ['Leeds', 0, 0, -7]] | [['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]] | Failed |
| boundary four tries in defeat | [['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]] | [['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]] | Passed |
| control draw | [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]] | [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]] | Passed |
| boundary losing by eight | [['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]] | [['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]] | Passed |
| regression: losing bonus margin | [['Sale', 5, 1, 7], ['Bath', 4, 1, 5], ['Leeds', 3, 0, -12]] | [['Sale', 5, 1, 7], ['Bath', 4, 1, 5], ['Leeds', 4, 0, -12]] | Failed |
| variant scenario 1 | [['Leeds', 10, 2, -3], ['Bath', 5, 1, 9], ['Sale', 2, 0, -6]] | [['Leeds', 10, 2, -3], ['Bath', 5, 1, 9], ['Sale', 2, 0, -6]] | Passed |
| variant scenario 2 | [['Leeds', 5, 1, 26], ['Wasps', 5, 1, 8], ['Sale', 1, 0, -34]] | [['Leeds', 5, 1, 26], ['Wasps', 5, 1, 8], ['Sale', 1, 0, -34]] | Passed |
SHA-256 / e64e1314407bd599137dcf80bebae74191c177f04dcbc739681e630e8fb06dce
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(results):
table = {}
for t1, tr1, s1, t2, tr2, s2 in results:
for team, tries, s, o in ((t1, tr1, s1, s2), (t2, tr2, s2, s1)):
row = table.setdefault(team, [0, 0, 0])
if s > o:
row[0] += 4
row[1] += 1
elif s == o:
row[0] += 2
if tries >= 4:
row[0] += 1
if s < o and o - s <= 5:
row[0] += 1
row[2] += s - o
order = sorted(table, key=lambda t: (-table[t][0], -table[t][1], -table[t][2], t))
return [[t] + table[t] for t in order]
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 plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Sale', 5, 22, 'Leeds', 4, 15], ['Bath', 3, 20, 'Leeds', 5, 15]],),
[['Sale', 5, 1, 7], ['Bath', 4, 1, 5], ['Leeds', 4, 0, -12]]),
('variant scenario 1',
([['Leeds', 4, 30, 'Sale', 6, 24],
['Bath', 6, 22, 'Leeds', 5, 5],
['Bath', 3, 12, 'Leeds', 0, 20]],),
[['Leeds', 10, 2, -3], ['Bath', 5, 1, 9], ['Sale', 2, 0, -6]]),
('variant scenario 2',
([['Leeds', 4, 33, 'Sale', 1, 7], ['Wasps', 5, 20, 'Sale', 5, 12]],),
[['Leeds', 5, 1, 26], ['Wasps', 5, 1, 8], ['Sale', 1, 0, -34]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Wasps', 4, 24, 'Leeds', 4, 15],
['Wasps', 4, 5, 'Bath', 6, 24],
['Leeds', 2, 12, 'Wasps', 2, 5],
['Wasps', 5, 30, 'Leeds', 1, 30],
['Leeds', 1, 3, 'Sale', 0, 24]],),
[['Wasps', 10, 1, -17], ['Leeds', 7, 1, -23], ['Bath', 5, 1, 19], ['Sale', 4, 1, 21]]),
('variant scenario 1',
([['Wasps', 5, 22, 'Sale', 0, 27], ['Sale', 1, 33, 'Bath', 5, 24]],),
[['Sale', 8, 2, 14], ['Wasps', 2, 0, -5], ['Bath', 1, 0, -9]]),
('variant scenario 2',
([['Leeds', 1, 20, 'Bath', 5, 17], ['Leeds', 0, 30, 'Wasps', 4, 24]],),
[['Leeds', 8, 2, 9], ['Bath', 2, 0, -3], ['Wasps', 2, 0, -6]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Sale', 6, 22, 'Leeds', 4, 7],
['Sale', 1, 5, 'Leeds', 2, 22],
['Sale', 5, 17, 'Wasps', 6, 24],
['Wasps', 1, 15, 'Sale', 3, 30],
['Wasps', 4, 7, 'Sale', 4, 27]],),
[['Sale', 16, 3, 26], ['Wasps', 6, 1, -28], ['Leeds', 5, 1, 2]]),
('variant scenario 1',
([['Bath', 0, 22, 'Wasps', 5, 3], ['Wasps', 4, 12, 'Sale', 6, 15]],),
[['Sale', 5, 1, 3], ['Bath', 4, 1, 19], ['Wasps', 3, 0, -22]]),
('variant scenario 2',
([['Sale', 1, 3, 'Bath', 0, 22], ['Wasps', 0, 22, 'Leeds', 6, 5]],),
[['Bath', 4, 1, 19], ['Wasps', 4, 1, 17], ['Leeds', 1, 0, -17], ['Sale', 0, 0, -19]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Leeds', 1, 22, 'Wasps', 4, 27],
['Leeds', 4, 5, 'Sale', 4, 22],
['Leeds', 6, 7, 'Wasps', 2, 20],
['Wasps', 3, 10, 'Sale', 4, 17],
['Leeds', 4, 5, 'Sale', 2, 30],
['Wasps', 5, 15, 'Sale', 4, 5],
['Leeds', 5, 20, 'Sale', 0, 17],
['Bath', 5, 12, 'Leeds', 3, 7]],),
[['Sale', 16, 3, 36], ['Wasps', 15, 3, 21], ['Leeds', 10, 1, -62], ['Bath', 5, 1, 5]]),
('variant scenario 1',
([['Bath', 1, 15, 'Leeds', 4, 5],
['Sale', 0, 27, 'Leeds', 1, 15],
['Sale', 4, 20, 'Leeds', 2, 20]],),
[['Sale', 7, 1, 12], ['Bath', 4, 1, 10], ['Leeds', 3, 0, -22]]),
('variant scenario 2',
([['Leeds', 6, 12, 'Wasps', 4, 22],
['Bath', 5, 17, 'Wasps', 0, 3],
['Wasps', 4, 17, 'Leeds', 3, 3]],),
[['Wasps', 10, 2, 10], ['Bath', 5, 1, 14], ['Leeds', 1, 0, -24]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Leeds', 3, 22, 'Bath', 2, 15],
['Bath', 1, 27, 'Sale', 1, 7],
['Sale', 2, 15, 'Leeds', 0, 15],
['Leeds', 3, 3, 'Bath', 0, 24],
['Bath', 3, 33, 'Leeds', 6, 10]],),
[['Bath', 13, 3, 57], ['Leeds', 7, 1, -37], ['Sale', 2, 0, -20]]),
('variant scenario 1',
([['Leeds', 1, 3, 'Sale', 2, 30],
['Bath', 3, 17, 'Wasps', 6, 5],
['Bath', 6, 27, 'Wasps', 5, 3],
['Leeds', 5, 3, 'Wasps', 3, 10],
['Bath', 4, 5, 'Wasps', 0, 22]],),
[['Bath', 10, 2, 19], ['Wasps', 10, 2, -12], ['Sale', 4, 1, 27], ['Leeds', 2, 0, -34]]),
('variant scenario 2',
([['Sale', 6, 27, 'Wasps', 3, 12],
['Leeds', 6, 17, 'Sale', 5, 27],
['Sale', 5, 22, 'Leeds', 3, 10],
['Sale', 5, 22, 'Leeds', 5, 17],
['Bath', 6, 17, 'Leeds', 0, 24],
['Bath', 0, 22, 'Leeds', 0, 20],
['Wasps', 0, 3, 'Sale', 1, 15]],),
[['Sale', 24, 5, 54], ['Leeds', 8, 1, -22], ['Bath', 6, 1, -5], ['Wasps', 0, 0, -27]])]]
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 plain win | [['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]] | [['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]] | Passed |
| boundary losing by seven | [['Bath', 4, 1, 7], ['Leeds', 0, 0, -7]] | [['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]] | Failed |
| boundary four tries in defeat | [['Bath', 4, 1, 6], ['Leeds', 1, 0, -6]] | [['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]] | Failed |
| control draw | [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]] | [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]] | Passed |
| boundary losing by eight | [['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]] | [['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]] | Passed |
| regression: losing bonus margin | [['Sale', 5, 1, 7], ['Bath', 4, 1, 5], ['Leeds', 3, 0, -12]] | [['Sale', 5, 1, 7], ['Bath', 4, 1, 5], ['Leeds', 4, 0, -12]] | Failed |
| variant scenario 1 | [['Leeds', 10, 2, -3], ['Bath', 5, 1, 9], ['Sale', 1, 0, -6]] | [['Leeds', 10, 2, -3], ['Bath', 5, 1, 9], ['Sale', 2, 0, -6]] | Failed |
| variant scenario 2 | [['Leeds', 5, 1, 26], ['Wasps', 5, 1, 8], ['Sale', 1, 0, -34]] | [['Leeds', 5, 1, 26], ['Wasps', 5, 1, 8], ['Sale', 1, 0, -34]] | Passed |
SHA-256 / a3d1e53bdc84f924b6da0858c14a62ea1bcb00e37875076b2ed64ff0d6dcd2dd
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(results):
table = {}
for t1, tr1, s1, t2, tr2, s2 in results:
for team, tries, s, o in ((t1, tr1, s1, s2), (t2, tr2, s2, s1)):
row = table.setdefault(team, [0, 0, 0])
if s > o:
row[0] += 4
row[1] += 1
elif s == o:
row[0] += 2
if tries >= 4:
row[0] += 1
if s < o and o - s <= 7:
row[0] += 1
row[2] += s - o
order = sorted(table, key=lambda t: (-table[t][0], -table[t][1], -table[t][2], t))
return [[t] + table[t] for t in order]
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 plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Sale', 5, 22, 'Leeds', 4, 15], ['Bath', 3, 20, 'Leeds', 5, 15]],),
[['Sale', 5, 1, 7], ['Bath', 4, 1, 5], ['Leeds', 4, 0, -12]]),
('variant scenario 1',
([['Leeds', 4, 30, 'Sale', 6, 24],
['Bath', 6, 22, 'Leeds', 5, 5],
['Bath', 3, 12, 'Leeds', 0, 20]],),
[['Leeds', 10, 2, -3], ['Bath', 5, 1, 9], ['Sale', 2, 0, -6]]),
('variant scenario 2',
([['Leeds', 4, 33, 'Sale', 1, 7], ['Wasps', 5, 20, 'Sale', 5, 12]],),
[['Leeds', 5, 1, 26], ['Wasps', 5, 1, 8], ['Sale', 1, 0, -34]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Wasps', 4, 24, 'Leeds', 4, 15],
['Wasps', 4, 5, 'Bath', 6, 24],
['Leeds', 2, 12, 'Wasps', 2, 5],
['Wasps', 5, 30, 'Leeds', 1, 30],
['Leeds', 1, 3, 'Sale', 0, 24]],),
[['Wasps', 10, 1, -17], ['Leeds', 7, 1, -23], ['Bath', 5, 1, 19], ['Sale', 4, 1, 21]]),
('variant scenario 1',
([['Wasps', 5, 22, 'Sale', 0, 27], ['Sale', 1, 33, 'Bath', 5, 24]],),
[['Sale', 8, 2, 14], ['Wasps', 2, 0, -5], ['Bath', 1, 0, -9]]),
('variant scenario 2',
([['Leeds', 1, 20, 'Bath', 5, 17], ['Leeds', 0, 30, 'Wasps', 4, 24]],),
[['Leeds', 8, 2, 9], ['Bath', 2, 0, -3], ['Wasps', 2, 0, -6]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Sale', 6, 22, 'Leeds', 4, 7],
['Sale', 1, 5, 'Leeds', 2, 22],
['Sale', 5, 17, 'Wasps', 6, 24],
['Wasps', 1, 15, 'Sale', 3, 30],
['Wasps', 4, 7, 'Sale', 4, 27]],),
[['Sale', 16, 3, 26], ['Wasps', 6, 1, -28], ['Leeds', 5, 1, 2]]),
('variant scenario 1',
([['Bath', 0, 22, 'Wasps', 5, 3], ['Wasps', 4, 12, 'Sale', 6, 15]],),
[['Sale', 5, 1, 3], ['Bath', 4, 1, 19], ['Wasps', 3, 0, -22]]),
('variant scenario 2',
([['Sale', 1, 3, 'Bath', 0, 22], ['Wasps', 0, 22, 'Leeds', 6, 5]],),
[['Bath', 4, 1, 19], ['Wasps', 4, 1, 17], ['Leeds', 1, 0, -17], ['Sale', 0, 0, -19]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Leeds', 1, 22, 'Wasps', 4, 27],
['Leeds', 4, 5, 'Sale', 4, 22],
['Leeds', 6, 7, 'Wasps', 2, 20],
['Wasps', 3, 10, 'Sale', 4, 17],
['Leeds', 4, 5, 'Sale', 2, 30],
['Wasps', 5, 15, 'Sale', 4, 5],
['Leeds', 5, 20, 'Sale', 0, 17],
['Bath', 5, 12, 'Leeds', 3, 7]],),
[['Sale', 16, 3, 36], ['Wasps', 15, 3, 21], ['Leeds', 10, 1, -62], ['Bath', 5, 1, 5]]),
('variant scenario 1',
([['Bath', 1, 15, 'Leeds', 4, 5],
['Sale', 0, 27, 'Leeds', 1, 15],
['Sale', 4, 20, 'Leeds', 2, 20]],),
[['Sale', 7, 1, 12], ['Bath', 4, 1, 10], ['Leeds', 3, 0, -22]]),
('variant scenario 2',
([['Leeds', 6, 12, 'Wasps', 4, 22],
['Bath', 5, 17, 'Wasps', 0, 3],
['Wasps', 4, 17, 'Leeds', 3, 3]],),
[['Wasps', 10, 2, 10], ['Bath', 5, 1, 14], ['Leeds', 1, 0, -24]])],
[('control plain win',
([['Bath', 2, 20, 'Leeds', 1, 10]],),
[['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]]),
('boundary losing by seven',
([['Bath', 1, 17, 'Leeds', 2, 10]],),
[['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]]),
('boundary four tries in defeat',
([['Bath', 3, 30, 'Leeds', 4, 24]],),
[['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]]),
('control draw', ([['Bath', 1, 10, 'Leeds', 1, 10]],), [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]]),
('boundary losing by eight',
([['Sale', 2, 18, 'Wasps', 1, 10]],),
[['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]]),
('regression: losing bonus margin',
([['Leeds', 3, 22, 'Bath', 2, 15],
['Bath', 1, 27, 'Sale', 1, 7],
['Sale', 2, 15, 'Leeds', 0, 15],
['Leeds', 3, 3, 'Bath', 0, 24],
['Bath', 3, 33, 'Leeds', 6, 10]],),
[['Bath', 13, 3, 57], ['Leeds', 7, 1, -37], ['Sale', 2, 0, -20]]),
('variant scenario 1',
([['Leeds', 1, 3, 'Sale', 2, 30],
['Bath', 3, 17, 'Wasps', 6, 5],
['Bath', 6, 27, 'Wasps', 5, 3],
['Leeds', 5, 3, 'Wasps', 3, 10],
['Bath', 4, 5, 'Wasps', 0, 22]],),
[['Bath', 10, 2, 19], ['Wasps', 10, 2, -12], ['Sale', 4, 1, 27], ['Leeds', 2, 0, -34]]),
('variant scenario 2',
([['Sale', 6, 27, 'Wasps', 3, 12],
['Leeds', 6, 17, 'Sale', 5, 27],
['Sale', 5, 22, 'Leeds', 3, 10],
['Sale', 5, 22, 'Leeds', 5, 17],
['Bath', 6, 17, 'Leeds', 0, 24],
['Bath', 0, 22, 'Leeds', 0, 20],
['Wasps', 0, 3, 'Sale', 1, 15]],),
[['Sale', 24, 5, 54], ['Leeds', 8, 1, -22], ['Bath', 6, 1, -5], ['Wasps', 0, 0, -27]])]]
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 plain win | [['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]] | [['Bath', 4, 1, 10], ['Leeds', 0, 0, -10]] | Passed |
| boundary losing by seven | [['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]] | [['Bath', 4, 1, 7], ['Leeds', 1, 0, -7]] | Passed |
| boundary four tries in defeat | [['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]] | [['Bath', 4, 1, 6], ['Leeds', 2, 0, -6]] | Passed |
| control draw | [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]] | [['Bath', 2, 0, 0], ['Leeds', 2, 0, 0]] | Passed |
| boundary losing by eight | [['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]] | [['Sale', 4, 1, 8], ['Wasps', 0, 0, -8]] | Passed |
| regression: losing bonus margin | [['Sale', 5, 1, 7], ['Bath', 4, 1, 5], ['Leeds', 4, 0, -12]] | [['Sale', 5, 1, 7], ['Bath', 4, 1, 5], ['Leeds', 4, 0, -12]] | Passed |
| variant scenario 1 | [['Leeds', 10, 2, -3], ['Bath', 5, 1, 9], ['Sale', 2, 0, -6]] | [['Leeds', 10, 2, -3], ['Bath', 5, 1, 9], ['Sale', 2, 0, -6]] | Passed |
| variant scenario 2 | [['Leeds', 5, 1, 26], ['Wasps', 5, 1, 8], ['Sale', 1, 0, -34]] | [['Leeds', 5, 1, 26], ['Wasps', 5, 1, 8], ['Sale', 1, 0, -34]] | Passed |
SHA-256 / 32573c1913463646c178fe248c0776e37fb2a46edb54cfa29a2833f944c623d7
Verification & scope
Stipulated, bounded toy contract stated in the contract field; not a claim of conformance with any governing body rulebook or operator house rules. 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:27.215205+00:00.
Case digest / d8d26f9b5d97680de1cbefcbef4e74ff81bf9b43248d2a6f267e426280951bda