FA-84041 / Sports scoring and tiebreakers / Open access
Try bonus requires five tries · case 01
Teams scoring exactly four tries are denied the bonus point.
ROOT CAUSE
The try bonus uses tries > 4.
VERIFIED REPAIR
Award the try bonus for 4 or more tries.
Unsuccessful approach: Switching to a three-tries-more-than-opponent rule is a different competition regulation.
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: try bonus threshold',
([['Wasps', 0, 15, 'Sale', 6, 15],
['Wasps', 4, 22, 'Leeds', 6, 27],
['Wasps', 2, 27, 'Bath', 6, 22]],),
[['Wasps', 8, 1, 0], ['Leeds', 5, 1, 5], ['Sale', 3, 0, 0], ['Bath', 2, 0, -5]]),
('variant scenario 1',
([['Bath', 2, 27, 'Leeds', 0, 20], ['Sale', 0, 27, 'Wasps', 6, 5]],),
[['Sale', 4, 1, 22], ['Bath', 4, 1, 7], ['Leeds', 1, 0, -7], ['Wasps', 1, 0, -22]]),
('variant scenario 2',
([['Leeds', 5, 7, 'Sale', 3, 20],
['Leeds', 1, 7, 'Bath', 3, 22],
['Sale', 0, 15, 'Leeds', 3, 15]],),
[['Sale', 6, 1, 13], ['Bath', 4, 1, 15], ['Leeds', 3, 0, -28]])],
[('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: try bonus threshold',
([['Wasps', 3, 24, 'Sale', 3, 12],
['Leeds', 2, 5, 'Wasps', 2, 3],
['Sale', 5, 20, 'Wasps', 5, 10],
['Wasps', 3, 10, 'Leeds', 5, 10],
['Leeds', 5, 27, 'Sale', 5, 10]],),
[['Leeds', 12, 2, 19], ['Wasps', 8, 1, 0], ['Sale', 6, 1, -19]]),
('regression: try bonus threshold',
([['Wasps', 0, 22, 'Sale', 5, 30], ['Leeds', 0, 17, 'Sale', 4, 30]],),
[['Sale', 10, 2, 21], ['Wasps', 0, 0, -8], ['Leeds', 0, 0, -13]]),
('variant scenario 1',
([['Wasps', 4, 12, 'Sale', 3, 30],
['Sale', 5, 30, 'Bath', 2, 27],
['Leeds', 1, 3, 'Sale', 4, 17],
['Sale', 1, 5, 'Bath', 2, 3],
['Bath', 2, 30, 'Sale', 6, 17],
['Sale', 4, 27, 'Wasps', 1, 20]],),
[['Sale', 24, 5, 31], ['Bath', 6, 1, 8], ['Wasps', 2, 0, -25], ['Leeds', 0, 0, -14]]),
('variant scenario 2',
([['Bath', 6, 5, 'Sale', 2, 10],
['Leeds', 2, 3, 'Bath', 5, 12],
['Bath', 0, 22, 'Wasps', 4, 22],
['Leeds', 2, 5, 'Sale', 6, 12]],),
[['Sale', 9, 2, 12], ['Bath', 9, 1, 4], ['Wasps', 3, 0, 0], ['Leeds', 1, 0, -16]])],
[('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: try bonus threshold',
([['Bath', 1, 5, 'Leeds', 5, 3],
['Sale', 3, 33, 'Wasps', 4, 30],
['Sale', 2, 12, 'Bath', 0, 5],
['Wasps', 1, 12, 'Bath', 5, 5]],),
[['Sale', 8, 2, 10], ['Bath', 7, 1, -12], ['Wasps', 6, 1, 4], ['Leeds', 2, 0, -2]]),
('variant scenario 1',
([['Wasps', 1, 17, 'Bath', 4, 12],
['Sale', 3, 27, 'Leeds', 6, 30],
['Sale', 2, 27, 'Bath', 3, 10],
['Bath', 1, 10, 'Leeds', 4, 30],
['Leeds', 2, 22, 'Sale', 2, 22],
['Leeds', 2, 3, 'Bath', 0, 5],
['Sale', 1, 20, 'Bath', 2, 10]],),
[['Leeds', 13, 2, 21], ['Sale', 11, 2, 24], ['Bath', 6, 1, -50], ['Wasps', 4, 1, 5]]),
('variant scenario 2',
([['Sale', 3, 33, 'Bath', 2, 12],
['Wasps', 3, 27, 'Bath', 3, 22],
['Sale', 0, 5, 'Wasps', 2, 3],
['Wasps', 4, 10, 'Leeds', 2, 30],
['Sale', 3, 7, 'Leeds', 5, 24],
['Bath', 0, 15, 'Leeds', 5, 22]],),
[['Leeds', 14, 3, 44], ['Sale', 8, 2, 6], ['Wasps', 6, 1, -17], ['Bath', 2, 0, -33]])],
[('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: try bonus threshold',
([['Sale', 1, 27, 'Leeds', 3, 15],
['Bath', 5, 33, 'Leeds', 4, 3],
['Bath', 0, 20, 'Sale', 4, 3],
['Wasps', 2, 24, 'Bath', 2, 17],
['Bath', 5, 24, 'Leeds', 4, 20]],),
[['Bath', 15, 3, 44], ['Sale', 5, 1, -5], ['Wasps', 4, 1, 7], ['Leeds', 3, 0, -46]]),
('variant scenario 1',
([['Wasps', 5, 5, 'Bath', 1, 10],
['Wasps', 3, 10, 'Sale', 4, 20],
['Sale', 1, 10, 'Leeds', 3, 5],
['Wasps', 6, 30, 'Sale', 6, 3],
['Wasps', 3, 20, 'Leeds', 1, 3],
['Leeds', 3, 12, 'Sale', 3, 30],
['Sale', 2, 20, 'Wasps', 6, 7],
['Sale', 2, 5, 'Wasps', 2, 5]],),
[['Sale', 20, 4, 19], ['Wasps', 14, 2, 16], ['Bath', 4, 1, 5], ['Leeds', 1, 0, -40]]),
('variant scenario 2',
([['Wasps', 4, 17, 'Sale', 3, 5],
['Bath', 3, 3, 'Wasps', 2, 10],
['Wasps', 3, 17, 'Leeds', 5, 15],
['Leeds', 1, 30, 'Sale', 2, 24],
['Sale', 3, 24, 'Bath', 3, 3],
['Sale', 4, 5, 'Wasps', 2, 15],
['Leeds', 4, 27, 'Wasps', 6, 24]],),
[['Wasps', 19, 4, 28], ['Leeds', 11, 2, 7], ['Sale', 6, 1, -7], ['Bath', 1, 0, -28]])],
[('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: try bonus threshold',
([['Sale', 2, 17, 'Leeds', 1, 20],
['Leeds', 1, 17, 'Wasps', 1, 30],
['Wasps', 4, 17, 'Bath', 6, 22],
['Sale', 0, 27, 'Leeds', 6, 3],
['Bath', 1, 7, 'Sale', 4, 20],
['Bath', 1, 20, 'Wasps', 1, 17],
['Sale', 4, 33, 'Bath', 2, 17],
['Leeds', 0, 15, 'Sale', 4, 20]],),
[['Sale', 20, 4, 55], ['Bath', 9, 2, -21], ['Wasps', 7, 1, 5], ['Leeds', 6, 1, -39]]),
('variant scenario 1',
([['Sale', 5, 24, 'Wasps', 2, 30],
['Bath', 6, 20, 'Wasps', 5, 24],
['Bath', 1, 27, 'Sale', 3, 30],
['Leeds', 2, 15, 'Sale', 6, 30],
['Wasps', 0, 30, 'Leeds', 4, 24],
['Bath', 5, 10, 'Leeds', 3, 30]],),
[['Wasps', 13, 3, 16], ['Sale', 11, 2, 12], ['Leeds', 6, 1, -1], ['Bath', 4, 0, -27]]),
('variant scenario 2',
([['Bath', 3, 5, 'Sale', 0, 30],
['Leeds', 3, 10, 'Wasps', 0, 5],
['Bath', 6, 7, 'Sale', 2, 30],
['Leeds', 0, 33, 'Sale', 2, 5],
['Leeds', 1, 17, 'Wasps', 0, 5]],),
[['Leeds', 12, 3, 45], ['Sale', 8, 2, 20], ['Wasps', 1, 0, -17], ['Bath', 1, 0, -48]])]]
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', 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: try bonus threshold | [['Wasps', 7, 1, 0], ['Leeds', 5, 1, 5], ['Sale', 3, 0, 0], ['Bath', 2, 0, -5]] | [['Wasps', 8, 1, 0], ['Leeds', 5, 1, 5], ['Sale', 3, 0, 0], ['Bath', 2, 0, -5]] | Failed |
| variant scenario 1 | [['Sale', 4, 1, 22], ['Bath', 4, 1, 7], ['Leeds', 1, 0, -7], ['Wasps', 1, 0, -22]] | [['Sale', 4, 1, 22], ['Bath', 4, 1, 7], ['Leeds', 1, 0, -7], ['Wasps', 1, 0, -22]] | Passed |
| variant scenario 2 | [['Sale', 6, 1, 13], ['Bath', 4, 1, 15], ['Leeds', 3, 0, -28]] | [['Sale', 6, 1, 13], ['Bath', 4, 1, 15], ['Leeds', 3, 0, -28]] | Passed |
SHA-256 / 95e673b8233bbbde697e10cf755a732a9f9f6fb8743ad3eca5c5c0b70a04bd60
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 - (tr2 if team == t1 else tr1) >= 3:
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: try bonus threshold',
([['Wasps', 0, 15, 'Sale', 6, 15],
['Wasps', 4, 22, 'Leeds', 6, 27],
['Wasps', 2, 27, 'Bath', 6, 22]],),
[['Wasps', 8, 1, 0], ['Leeds', 5, 1, 5], ['Sale', 3, 0, 0], ['Bath', 2, 0, -5]]),
('variant scenario 1',
([['Bath', 2, 27, 'Leeds', 0, 20], ['Sale', 0, 27, 'Wasps', 6, 5]],),
[['Sale', 4, 1, 22], ['Bath', 4, 1, 7], ['Leeds', 1, 0, -7], ['Wasps', 1, 0, -22]]),
('variant scenario 2',
([['Leeds', 5, 7, 'Sale', 3, 20],
['Leeds', 1, 7, 'Bath', 3, 22],
['Sale', 0, 15, 'Leeds', 3, 15]],),
[['Sale', 6, 1, 13], ['Bath', 4, 1, 15], ['Leeds', 3, 0, -28]])],
[('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: try bonus threshold',
([['Wasps', 3, 24, 'Sale', 3, 12],
['Leeds', 2, 5, 'Wasps', 2, 3],
['Sale', 5, 20, 'Wasps', 5, 10],
['Wasps', 3, 10, 'Leeds', 5, 10],
['Leeds', 5, 27, 'Sale', 5, 10]],),
[['Leeds', 12, 2, 19], ['Wasps', 8, 1, 0], ['Sale', 6, 1, -19]]),
('regression: try bonus threshold',
([['Wasps', 0, 22, 'Sale', 5, 30], ['Leeds', 0, 17, 'Sale', 4, 30]],),
[['Sale', 10, 2, 21], ['Wasps', 0, 0, -8], ['Leeds', 0, 0, -13]]),
('variant scenario 1',
([['Wasps', 4, 12, 'Sale', 3, 30],
['Sale', 5, 30, 'Bath', 2, 27],
['Leeds', 1, 3, 'Sale', 4, 17],
['Sale', 1, 5, 'Bath', 2, 3],
['Bath', 2, 30, 'Sale', 6, 17],
['Sale', 4, 27, 'Wasps', 1, 20]],),
[['Sale', 24, 5, 31], ['Bath', 6, 1, 8], ['Wasps', 2, 0, -25], ['Leeds', 0, 0, -14]]),
('variant scenario 2',
([['Bath', 6, 5, 'Sale', 2, 10],
['Leeds', 2, 3, 'Bath', 5, 12],
['Bath', 0, 22, 'Wasps', 4, 22],
['Leeds', 2, 5, 'Sale', 6, 12]],),
[['Sale', 9, 2, 12], ['Bath', 9, 1, 4], ['Wasps', 3, 0, 0], ['Leeds', 1, 0, -16]])],
[('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: try bonus threshold',
([['Bath', 1, 5, 'Leeds', 5, 3],
['Sale', 3, 33, 'Wasps', 4, 30],
['Sale', 2, 12, 'Bath', 0, 5],
['Wasps', 1, 12, 'Bath', 5, 5]],),
[['Sale', 8, 2, 10], ['Bath', 7, 1, -12], ['Wasps', 6, 1, 4], ['Leeds', 2, 0, -2]]),
('variant scenario 1',
([['Wasps', 1, 17, 'Bath', 4, 12],
['Sale', 3, 27, 'Leeds', 6, 30],
['Sale', 2, 27, 'Bath', 3, 10],
['Bath', 1, 10, 'Leeds', 4, 30],
['Leeds', 2, 22, 'Sale', 2, 22],
['Leeds', 2, 3, 'Bath', 0, 5],
['Sale', 1, 20, 'Bath', 2, 10]],),
[['Leeds', 13, 2, 21], ['Sale', 11, 2, 24], ['Bath', 6, 1, -50], ['Wasps', 4, 1, 5]]),
('variant scenario 2',
([['Sale', 3, 33, 'Bath', 2, 12],
['Wasps', 3, 27, 'Bath', 3, 22],
['Sale', 0, 5, 'Wasps', 2, 3],
['Wasps', 4, 10, 'Leeds', 2, 30],
['Sale', 3, 7, 'Leeds', 5, 24],
['Bath', 0, 15, 'Leeds', 5, 22]],),
[['Leeds', 14, 3, 44], ['Sale', 8, 2, 6], ['Wasps', 6, 1, -17], ['Bath', 2, 0, -33]])],
[('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: try bonus threshold',
([['Sale', 1, 27, 'Leeds', 3, 15],
['Bath', 5, 33, 'Leeds', 4, 3],
['Bath', 0, 20, 'Sale', 4, 3],
['Wasps', 2, 24, 'Bath', 2, 17],
['Bath', 5, 24, 'Leeds', 4, 20]],),
[['Bath', 15, 3, 44], ['Sale', 5, 1, -5], ['Wasps', 4, 1, 7], ['Leeds', 3, 0, -46]]),
('variant scenario 1',
([['Wasps', 5, 5, 'Bath', 1, 10],
['Wasps', 3, 10, 'Sale', 4, 20],
['Sale', 1, 10, 'Leeds', 3, 5],
['Wasps', 6, 30, 'Sale', 6, 3],
['Wasps', 3, 20, 'Leeds', 1, 3],
['Leeds', 3, 12, 'Sale', 3, 30],
['Sale', 2, 20, 'Wasps', 6, 7],
['Sale', 2, 5, 'Wasps', 2, 5]],),
[['Sale', 20, 4, 19], ['Wasps', 14, 2, 16], ['Bath', 4, 1, 5], ['Leeds', 1, 0, -40]]),
('variant scenario 2',
([['Wasps', 4, 17, 'Sale', 3, 5],
['Bath', 3, 3, 'Wasps', 2, 10],
['Wasps', 3, 17, 'Leeds', 5, 15],
['Leeds', 1, 30, 'Sale', 2, 24],
['Sale', 3, 24, 'Bath', 3, 3],
['Sale', 4, 5, 'Wasps', 2, 15],
['Leeds', 4, 27, 'Wasps', 6, 24]],),
[['Wasps', 19, 4, 28], ['Leeds', 11, 2, 7], ['Sale', 6, 1, -7], ['Bath', 1, 0, -28]])],
[('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: try bonus threshold',
([['Sale', 2, 17, 'Leeds', 1, 20],
['Leeds', 1, 17, 'Wasps', 1, 30],
['Wasps', 4, 17, 'Bath', 6, 22],
['Sale', 0, 27, 'Leeds', 6, 3],
['Bath', 1, 7, 'Sale', 4, 20],
['Bath', 1, 20, 'Wasps', 1, 17],
['Sale', 4, 33, 'Bath', 2, 17],
['Leeds', 0, 15, 'Sale', 4, 20]],),
[['Sale', 20, 4, 55], ['Bath', 9, 2, -21], ['Wasps', 7, 1, 5], ['Leeds', 6, 1, -39]]),
('variant scenario 1',
([['Sale', 5, 24, 'Wasps', 2, 30],
['Bath', 6, 20, 'Wasps', 5, 24],
['Bath', 1, 27, 'Sale', 3, 30],
['Leeds', 2, 15, 'Sale', 6, 30],
['Wasps', 0, 30, 'Leeds', 4, 24],
['Bath', 5, 10, 'Leeds', 3, 30]],),
[['Wasps', 13, 3, 16], ['Sale', 11, 2, 12], ['Leeds', 6, 1, -1], ['Bath', 4, 0, -27]]),
('variant scenario 2',
([['Bath', 3, 5, 'Sale', 0, 30],
['Leeds', 3, 10, 'Wasps', 0, 5],
['Bath', 6, 7, 'Sale', 2, 30],
['Leeds', 0, 33, 'Sale', 2, 5],
['Leeds', 1, 17, 'Wasps', 0, 5]],),
[['Leeds', 12, 3, 45], ['Sale', 8, 2, 20], ['Wasps', 1, 0, -17], ['Bath', 1, 0, -48]])]]
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', 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: try bonus threshold | [['Wasps', 7, 1, 0], ['Leeds', 4, 1, 5], ['Sale', 3, 0, 0], ['Bath', 2, 0, -5]] | [['Wasps', 8, 1, 0], ['Leeds', 5, 1, 5], ['Sale', 3, 0, 0], ['Bath', 2, 0, -5]] | Failed |
| variant scenario 1 | [['Sale', 4, 1, 22], ['Bath', 4, 1, 7], ['Leeds', 1, 0, -7], ['Wasps', 1, 0, -22]] | [['Sale', 4, 1, 22], ['Bath', 4, 1, 7], ['Leeds', 1, 0, -7], ['Wasps', 1, 0, -22]] | Passed |
| variant scenario 2 | [['Sale', 6, 1, 13], ['Bath', 4, 1, 15], ['Leeds', 3, 0, -28]] | [['Sale', 6, 1, 13], ['Bath', 4, 1, 15], ['Leeds', 3, 0, -28]] | Passed |
SHA-256 / f676f9a809bf5a9c75184584b475078740c20806047b2b11d91ee8e0f7653b83
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: try bonus threshold',
([['Wasps', 0, 15, 'Sale', 6, 15],
['Wasps', 4, 22, 'Leeds', 6, 27],
['Wasps', 2, 27, 'Bath', 6, 22]],),
[['Wasps', 8, 1, 0], ['Leeds', 5, 1, 5], ['Sale', 3, 0, 0], ['Bath', 2, 0, -5]]),
('variant scenario 1',
([['Bath', 2, 27, 'Leeds', 0, 20], ['Sale', 0, 27, 'Wasps', 6, 5]],),
[['Sale', 4, 1, 22], ['Bath', 4, 1, 7], ['Leeds', 1, 0, -7], ['Wasps', 1, 0, -22]]),
('variant scenario 2',
([['Leeds', 5, 7, 'Sale', 3, 20],
['Leeds', 1, 7, 'Bath', 3, 22],
['Sale', 0, 15, 'Leeds', 3, 15]],),
[['Sale', 6, 1, 13], ['Bath', 4, 1, 15], ['Leeds', 3, 0, -28]])],
[('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: try bonus threshold',
([['Wasps', 3, 24, 'Sale', 3, 12],
['Leeds', 2, 5, 'Wasps', 2, 3],
['Sale', 5, 20, 'Wasps', 5, 10],
['Wasps', 3, 10, 'Leeds', 5, 10],
['Leeds', 5, 27, 'Sale', 5, 10]],),
[['Leeds', 12, 2, 19], ['Wasps', 8, 1, 0], ['Sale', 6, 1, -19]]),
('regression: try bonus threshold',
([['Wasps', 0, 22, 'Sale', 5, 30], ['Leeds', 0, 17, 'Sale', 4, 30]],),
[['Sale', 10, 2, 21], ['Wasps', 0, 0, -8], ['Leeds', 0, 0, -13]]),
('variant scenario 1',
([['Wasps', 4, 12, 'Sale', 3, 30],
['Sale', 5, 30, 'Bath', 2, 27],
['Leeds', 1, 3, 'Sale', 4, 17],
['Sale', 1, 5, 'Bath', 2, 3],
['Bath', 2, 30, 'Sale', 6, 17],
['Sale', 4, 27, 'Wasps', 1, 20]],),
[['Sale', 24, 5, 31], ['Bath', 6, 1, 8], ['Wasps', 2, 0, -25], ['Leeds', 0, 0, -14]]),
('variant scenario 2',
([['Bath', 6, 5, 'Sale', 2, 10],
['Leeds', 2, 3, 'Bath', 5, 12],
['Bath', 0, 22, 'Wasps', 4, 22],
['Leeds', 2, 5, 'Sale', 6, 12]],),
[['Sale', 9, 2, 12], ['Bath', 9, 1, 4], ['Wasps', 3, 0, 0], ['Leeds', 1, 0, -16]])],
[('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: try bonus threshold',
([['Bath', 1, 5, 'Leeds', 5, 3],
['Sale', 3, 33, 'Wasps', 4, 30],
['Sale', 2, 12, 'Bath', 0, 5],
['Wasps', 1, 12, 'Bath', 5, 5]],),
[['Sale', 8, 2, 10], ['Bath', 7, 1, -12], ['Wasps', 6, 1, 4], ['Leeds', 2, 0, -2]]),
('variant scenario 1',
([['Wasps', 1, 17, 'Bath', 4, 12],
['Sale', 3, 27, 'Leeds', 6, 30],
['Sale', 2, 27, 'Bath', 3, 10],
['Bath', 1, 10, 'Leeds', 4, 30],
['Leeds', 2, 22, 'Sale', 2, 22],
['Leeds', 2, 3, 'Bath', 0, 5],
['Sale', 1, 20, 'Bath', 2, 10]],),
[['Leeds', 13, 2, 21], ['Sale', 11, 2, 24], ['Bath', 6, 1, -50], ['Wasps', 4, 1, 5]]),
('variant scenario 2',
([['Sale', 3, 33, 'Bath', 2, 12],
['Wasps', 3, 27, 'Bath', 3, 22],
['Sale', 0, 5, 'Wasps', 2, 3],
['Wasps', 4, 10, 'Leeds', 2, 30],
['Sale', 3, 7, 'Leeds', 5, 24],
['Bath', 0, 15, 'Leeds', 5, 22]],),
[['Leeds', 14, 3, 44], ['Sale', 8, 2, 6], ['Wasps', 6, 1, -17], ['Bath', 2, 0, -33]])],
[('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: try bonus threshold',
([['Sale', 1, 27, 'Leeds', 3, 15],
['Bath', 5, 33, 'Leeds', 4, 3],
['Bath', 0, 20, 'Sale', 4, 3],
['Wasps', 2, 24, 'Bath', 2, 17],
['Bath', 5, 24, 'Leeds', 4, 20]],),
[['Bath', 15, 3, 44], ['Sale', 5, 1, -5], ['Wasps', 4, 1, 7], ['Leeds', 3, 0, -46]]),
('variant scenario 1',
([['Wasps', 5, 5, 'Bath', 1, 10],
['Wasps', 3, 10, 'Sale', 4, 20],
['Sale', 1, 10, 'Leeds', 3, 5],
['Wasps', 6, 30, 'Sale', 6, 3],
['Wasps', 3, 20, 'Leeds', 1, 3],
['Leeds', 3, 12, 'Sale', 3, 30],
['Sale', 2, 20, 'Wasps', 6, 7],
['Sale', 2, 5, 'Wasps', 2, 5]],),
[['Sale', 20, 4, 19], ['Wasps', 14, 2, 16], ['Bath', 4, 1, 5], ['Leeds', 1, 0, -40]]),
('variant scenario 2',
([['Wasps', 4, 17, 'Sale', 3, 5],
['Bath', 3, 3, 'Wasps', 2, 10],
['Wasps', 3, 17, 'Leeds', 5, 15],
['Leeds', 1, 30, 'Sale', 2, 24],
['Sale', 3, 24, 'Bath', 3, 3],
['Sale', 4, 5, 'Wasps', 2, 15],
['Leeds', 4, 27, 'Wasps', 6, 24]],),
[['Wasps', 19, 4, 28], ['Leeds', 11, 2, 7], ['Sale', 6, 1, -7], ['Bath', 1, 0, -28]])],
[('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: try bonus threshold',
([['Sale', 2, 17, 'Leeds', 1, 20],
['Leeds', 1, 17, 'Wasps', 1, 30],
['Wasps', 4, 17, 'Bath', 6, 22],
['Sale', 0, 27, 'Leeds', 6, 3],
['Bath', 1, 7, 'Sale', 4, 20],
['Bath', 1, 20, 'Wasps', 1, 17],
['Sale', 4, 33, 'Bath', 2, 17],
['Leeds', 0, 15, 'Sale', 4, 20]],),
[['Sale', 20, 4, 55], ['Bath', 9, 2, -21], ['Wasps', 7, 1, 5], ['Leeds', 6, 1, -39]]),
('variant scenario 1',
([['Sale', 5, 24, 'Wasps', 2, 30],
['Bath', 6, 20, 'Wasps', 5, 24],
['Bath', 1, 27, 'Sale', 3, 30],
['Leeds', 2, 15, 'Sale', 6, 30],
['Wasps', 0, 30, 'Leeds', 4, 24],
['Bath', 5, 10, 'Leeds', 3, 30]],),
[['Wasps', 13, 3, 16], ['Sale', 11, 2, 12], ['Leeds', 6, 1, -1], ['Bath', 4, 0, -27]]),
('variant scenario 2',
([['Bath', 3, 5, 'Sale', 0, 30],
['Leeds', 3, 10, 'Wasps', 0, 5],
['Bath', 6, 7, 'Sale', 2, 30],
['Leeds', 0, 33, 'Sale', 2, 5],
['Leeds', 1, 17, 'Wasps', 0, 5]],),
[['Leeds', 12, 3, 45], ['Sale', 8, 2, 20], ['Wasps', 1, 0, -17], ['Bath', 1, 0, -48]])]]
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: try bonus threshold | [['Wasps', 8, 1, 0], ['Leeds', 5, 1, 5], ['Sale', 3, 0, 0], ['Bath', 2, 0, -5]] | [['Wasps', 8, 1, 0], ['Leeds', 5, 1, 5], ['Sale', 3, 0, 0], ['Bath', 2, 0, -5]] | Passed |
| variant scenario 1 | [['Sale', 4, 1, 22], ['Bath', 4, 1, 7], ['Leeds', 1, 0, -7], ['Wasps', 1, 0, -22]] | [['Sale', 4, 1, 22], ['Bath', 4, 1, 7], ['Leeds', 1, 0, -7], ['Wasps', 1, 0, -22]] | Passed |
| variant scenario 2 | [['Sale', 6, 1, 13], ['Bath', 4, 1, 15], ['Leeds', 3, 0, -28]] | [['Sale', 6, 1, 13], ['Bath', 4, 1, 15], ['Leeds', 3, 0, -28]] | Passed |
SHA-256 / 15d8d2ba7a28feec4ca5847103cd3ad61c87b148fcfe2b5be0507537a06b6a38
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.172044+00:00.
Case digest / e749334d9d71b7b85568e2b94ebb8d8657c79232c8a222d09f1285586d6acb05