broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points):
    names = ['0', '15', '30', '40']
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        elif p == 'B':
            b += 1
        else:
            return 'invalid point ' + p
        if (a >= 4 or b >= 4) and abs(a - b) >= 1:
            return 'game A' if a > b else 'game B'
    if a >= 3 and b >= 3:
        if a == b:
            return 'deuce'
        return 'advantage A' if a > b else 'advantage B'
    return names[a] + '-' + names[b]
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 love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('ABABABB',), 'advantage B'),
  ('regression: game lead margin', ('AABBAA',), 'game A'),
  ('variant scenario 1', ('',), '0-0'),
  ('variant scenario 2', ('ABB',), '15-30')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('ABBABBAAA',), 'game B'),
  ('regression: game lead margin', ('ABAABBB',), 'advantage B'),
  ('variant scenario 1', ('BABAAAABB',), 'game A'),
  ('variant scenario 2', ('',), '0-0')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('BABABBAAA',), 'game B'),
  ('regression: game lead margin', ('BBAABAABABB',), 'advantage B'),
  ('variant scenario 1', ('ABABBBBAB',), 'game B'),
  ('variant scenario 2', ('BAAABB',), 'deuce')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('ABBBAABAAABBA',), 'game A'),
  ('variant scenario 1', ('AABBBBBABBABA',), 'game B'),
  ('variant scenario 2', ('AAABABABAAAAA',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('BBAAAABBBBBABAAC',), 'game A'),
  ('regression: game lead margin', ('BAAABBBAAAA',), 'game A'),
  ('variant scenario 1', ('BBABABBBBABx',), 'game B'),
  ('variant scenario 2', ('ABBAAABAABAAB',), 'game A')]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points):
    names = ['0', '15', '30', '40']
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        elif p == 'B':
            b += 1
        else:
            return 'invalid point ' + p
        if (a >= 4 or b >= 4) and abs(a - b) > 2:
            return 'game A' if a > b else 'game B'
    if a >= 3 and b >= 3:
        if a == b:
            return 'deuce'
        return 'advantage A' if a > b else 'advantage B'
    return names[a] + '-' + names[b]
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 love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('ABABABB',), 'advantage B'),
  ('regression: game lead margin', ('AABBAA',), 'game A'),
  ('variant scenario 1', ('',), '0-0'),
  ('variant scenario 2', ('ABB',), '15-30')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('ABBABBAAA',), 'game B'),
  ('regression: game lead margin', ('ABAABBB',), 'advantage B'),
  ('variant scenario 1', ('BABAAAABB',), 'game A'),
  ('variant scenario 2', ('',), '0-0')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('BABABBAAA',), 'game B'),
  ('regression: game lead margin', ('BBAABAABABB',), 'advantage B'),
  ('variant scenario 1', ('ABABBBBAB',), 'game B'),
  ('variant scenario 2', ('BAAABB',), 'deuce')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('ABBBAABAAABBA',), 'game A'),
  ('variant scenario 1', ('AABBBBBABBABA',), 'game B'),
  ('variant scenario 2', ('AAABABABAAAAA',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game lead margin', ('BBAAAABBBBBABAAC',), 'game A'),
  ('regression: game lead margin', ('BAAABBBAAAA',), 'game A'),
  ('variant scenario 1', ('BBABABBBBABx',), 'game B'),
  ('variant scenario 2', ('ABBAAABAABAAB',), 'game A')]]
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)

prompt:
After deuce the display jumps straight to a game instead of showing advantage.

points is a string of rally winners, each character A or B. A game ends at the first point where a player has at least 4 points and leads by at least 2; characters after that point are ignored. Return "game A"/"game B" when finished; otherwise "deuce" when both have at least 3 points and are level, "advantage A"/"advantage B" when both have at least 3 points and differ by one, else "S-R" using the labels 0, 15, 30, 40 in A-B order. A character other than A or B that is reached before the game ends returns "invalid point <c>".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points):
    names = ['0', '15', '30', '40']
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        elif p == 'B':
            b += 1
        else:
            return 'invalid point ' + p
        if (a >= 3 or b >= 3) and abs(a - b) >= 2:
            return 'game A' if a > b else 'game B'
    if a >= 3 and b >= 3:
        if a == b:
            return 'deuce'
        return 'advantage A' if a > b else 'advantage B'
    return names[a] + '-' + names[b]
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 love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('BBBAAC',), 'invalid point C'),
  ('variant scenario 1', ('',), '0-0'),
  ('variant scenario 2', ('AABBB',), '30-40')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('BBBA',), '15-40'),
  ('variant scenario 1', ('B',), '0-15'),
  ('variant scenario 2', ('AABAABBAAB',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('BABBAAA',), 'advantage A'),
  ('variant scenario 1', ('AB',), '15-15'),
  ('variant scenario 2', ('ABBAAABBBABC',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('AAABB',), '40-30'),
  ('variant scenario 1', ('BABABBAx',), 'game B'),
  ('variant scenario 2', ('AAAABBAAABAABA',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('BAAABBABBABA',), 'deuce'),
  ('variant scenario 1', ('ABABBAABBBBABBB',), 'game B'),
  ('variant scenario 2', ('B',), '0-15')]]
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points):
    names = ['0', '15', '30', '40']
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        elif p == 'B':
            b += 1
        else:
            return 'invalid point ' + p
        if (a + b >= 4) and abs(a - b) >= 2:
            return 'game A' if a > b else 'game B'
    if a >= 3 and b >= 3:
        if a == b:
            return 'deuce'
        return 'advantage A' if a > b else 'advantage B'
    return names[a] + '-' + names[b]
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 love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('BBBAAC',), 'invalid point C'),
  ('variant scenario 1', ('',), '0-0'),
  ('variant scenario 2', ('AABBB',), '30-40')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('BBBA',), '15-40'),
  ('variant scenario 1', ('B',), '0-15'),
  ('variant scenario 2', ('AABAABBAAB',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('BABBAAA',), 'advantage A'),
  ('variant scenario 1', ('AB',), '15-15'),
  ('variant scenario 2', ('ABBAAABBBABC',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('AAABB',), '40-30'),
  ('variant scenario 1', ('BABABBAx',), 'game B'),
  ('variant scenario 2', ('AAAABBAAABAABA',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: game point minimum', ('BAAABBABBABA',), 'deuce'),
  ('variant scenario 1', ('ABABBAABBBBABBB',), 'game B'),
  ('variant scenario 2', ('B',), '0-15')]]
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)

prompt:
A player leading 40-15 is shown as having won the game one point early.

points is a string of rally winners, each character A or B. A game ends at the first point where a player has at least 4 points and leads by at least 2; characters after that point are ignored. Return "game A"/"game B" when finished; otherwise "deuce" when both have at least 3 points and are level, "advantage A"/"advantage B" when both have at least 3 points and differ by one, else "S-R" using the labels 0, 15, 30, 40 in A-B order. A character other than A or B that is reached before the game ends returns "invalid point <c>".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points):
    names = ['0', '15', '30', '40']
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        elif p == 'B':
            b += 1
        else:
            return 'invalid point ' + p
        if (a >= 4 or b >= 4) and abs(a - b) >= 2:
            return 'game A' if a > b else 'game B'
    if a >= 3 or b >= 3:
        if a == b:
            return 'deuce'
        return 'advantage A' if a > b else 'advantage B'
    return names[a] + '-' + names[b]
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 love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('BBB',), '0-40'),
  ('regression: deuce band', ('AAABB',), '40-30'),
  ('variant scenario 1', ('BABBBAB',), 'game B'),
  ('variant scenario 2', ('',), '0-0')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('AAA',), '40-0'),
  ('regression: deuce band', ('AAABB',), '40-30'),
  ('variant scenario 1', ('A',), '15-0'),
  ('variant scenario 2', ('',), '0-0')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('BAAA',), '40-15'),
  ('regression: deuce band', ('ABABA',), '40-30'),
  ('variant scenario 1', ('AAABBAB',), 'game A'),
  ('variant scenario 2', ('AAABBBABA',), 'advantage A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('BBABA',), '30-40'),
  ('regression: deuce band', ('BAABA',), '40-30'),
  ('variant scenario 1', ('ABAAx',), 'invalid point x'),
  ('variant scenario 2', ('',), '0-0')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('AABA',), '40-15'),
  ('regression: deuce band', ('AABAB',), '40-30'),
  ('variant scenario 1', ('BAAABBAA',), 'game A'),
  ('variant scenario 2', ('AAAABBBAABBAA',), 'game A')]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points):
    names = ['0', '15', '30', '40']
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        elif p == 'B':
            b += 1
        else:
            return 'invalid point ' + p
        if (a >= 4 or b >= 4) and abs(a - b) >= 2:
            return 'game A' if a > b else 'game B'
    if a >= 3 and b >= 2:
        if a == b:
            return 'deuce'
        return 'advantage A' if a > b else 'advantage B'
    return names[a] + '-' + names[b]
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 love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('BBB',), '0-40'),
  ('regression: deuce band', ('AAABB',), '40-30'),
  ('variant scenario 1', ('BABBBAB',), 'game B'),
  ('variant scenario 2', ('',), '0-0')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('AAA',), '40-0'),
  ('regression: deuce band', ('AAABB',), '40-30'),
  ('variant scenario 1', ('A',), '15-0'),
  ('variant scenario 2', ('',), '0-0')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('BAAA',), '40-15'),
  ('regression: deuce band', ('ABABA',), '40-30'),
  ('variant scenario 1', ('AAABBAB',), 'game A'),
  ('variant scenario 2', ('AAABBBABA',), 'advantage A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('BBABA',), '30-40'),
  ('regression: deuce band', ('BAABA',), '40-30'),
  ('variant scenario 1', ('ABAAx',), 'invalid point x'),
  ('variant scenario 2', ('',), '0-0')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: deuce band', ('AABA',), '40-15'),
  ('regression: deuce band', ('AABAB',), '40-30'),
  ('variant scenario 1', ('BAAABBAA',), 'game A'),
  ('variant scenario 2', ('AAAABBBAABBAA',), 'game A')]]
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)

prompt:
A 40-15 score is rendered as an advantage instead of the numeric score.

points is a string of rally winners, each character A or B. A game ends at the first point where a player has at least 4 points and leads by at least 2; characters after that point are ignored. Return "game A"/"game B" when finished; otherwise "deuce" when both have at least 3 points and are level, "advantage A"/"advantage B" when both have at least 3 points and differ by one, else "S-R" using the labels 0, 15, 30, 40 in A-B order. A character other than A or B that is reached before the game ends returns "invalid point <c>".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points):
    names = ['0', '15', '30', '40']
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        elif p == 'B':
            b += 1
        else:
            continue
        if (a >= 4 or b >= 4) and abs(a - b) >= 2:
            return 'game A' if a > b else 'game B'
    if a >= 3 and b >= 3:
        if a == b:
            return 'deuce'
        return 'advantage A' if a > b else 'advantage B'
    return names[a] + '-' + names[b]
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 love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('BAAABABC',), 'game A'),
  ('regression: input validation scope', ('BAABBAx',), 'invalid point x'),
  ('variant scenario 1', ('BBBAB',), 'game B'),
  ('variant scenario 2', ('AAAABAAA',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('BAC',), 'invalid point C'),
  ('regression: input validation scope', ('ABABAAABBC',), 'game A'),
  ('variant scenario 1', ('BBBB',), 'game B'),
  ('variant scenario 2', ('AABBBBBAA',), 'game B')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('x',), 'invalid point x'),
  ('regression: input validation scope', ('BAABBABBBBAx',), 'game B'),
  ('variant scenario 1', ('AAAABABAA',), 'game A'),
  ('variant scenario 2', ('AAABABA',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('BBAAABBABx',), 'invalid point x'),
  ('regression: input validation scope', ('ABBBBAAABx',), 'game B'),
  ('variant scenario 1', ('BAAAAA',), 'game A'),
  ('variant scenario 2', ('AB',), '15-15')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('BABAABBBBAAAx',), 'game B'),
  ('regression: input validation scope', ('ABC',), 'invalid point C'),
  ('variant scenario 1', ('BBAAAABABBABBB',), 'game A'),
  ('variant scenario 2', ('BBBBAABABBA',), 'game B')]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points):
    names = ['0', '15', '30', '40']
    a = b = 0
    for p in points:
        if p not in ('A', 'B'):
            return 'invalid point ' + p
    for p in points:
        if p == 'A':
            a += 1
        elif p == 'B':
            b += 1
        else:
            return 'invalid point ' + p
        if (a >= 4 or b >= 4) and abs(a - b) >= 2:
            return 'game A' if a > b else 'game B'
    if a >= 3 and b >= 3:
        if a == b:
            return 'deuce'
        return 'advantage A' if a > b else 'advantage B'
    return names[a] + '-' + names[b]
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 love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('BAAABABC',), 'game A'),
  ('regression: input validation scope', ('BAABBAx',), 'invalid point x'),
  ('variant scenario 1', ('BBBAB',), 'game B'),
  ('variant scenario 2', ('AAAABAAA',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('BAC',), 'invalid point C'),
  ('regression: input validation scope', ('ABABAAABBC',), 'game A'),
  ('variant scenario 1', ('BBBB',), 'game B'),
  ('variant scenario 2', ('AABBBBBAA',), 'game B')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('x',), 'invalid point x'),
  ('regression: input validation scope', ('BAABBABBBBAx',), 'game B'),
  ('variant scenario 1', ('AAAABABAA',), 'game A'),
  ('variant scenario 2', ('AAABABA',), 'game A')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('BBAAABBABx',), 'invalid point x'),
  ('regression: input validation scope', ('ABBBBAAABx',), 'game B'),
  ('variant scenario 1', ('BAAAAA',), 'game A'),
  ('variant scenario 2', ('AB',), '15-15')],
 [('control love-thirty', ('BB',), '0-30'),
  ('boundary first deuce', ('AABBAB',), 'deuce'),
  ('boundary advantage after deuce', ('AAABBBB',), 'advantage B'),
  ('control straight game', ('AAAA',), 'game A'),
  ('boundary win from advantage', ('ABABABAA',), 'game A'),
  ('control empty log', ('',), '0-0'),
  ('regression: input validation scope', ('BABAABBBBAAAx',), 'game B'),
  ('regression: input validation scope', ('ABC',), 'invalid point C'),
  ('variant scenario 1', ('BBAAAABABBABBB',), 'game A'),
  ('variant scenario 2', ('BBBBAABABBA',), 'game B')]]
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)

prompt:
Corrupt characters are silently skipped or trailing garbage after a finished game is reported as an error.

points is a string of rally winners, each character A or B. A game ends at the first point where a player has at least 4 points and leads by at least 2; characters after that point are ignored. Return "game A"/"game B" when finished; otherwise "deuce" when both have at least 3 points and are level, "advantage A"/"advantage B" when both have at least 3 points and differ by one, else "S-R" using the labels 0, 15, 30, 40 in A-B order. A character other than A or B that is reached before the game ends returns "invalid point <c>".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return max(x, y) >= target and abs(x - y) >= 1
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
        if finished(a, b):
            break
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if ((played + 1) // 2) % 2 == 0 else other
    ends_change = played > 0 and played % 6 == 0 and winner is None
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin', ('AAAABABABBBBB', 'A', 7), [6, 7, None, 'B', False]),
  ('regression: two point margin', ('BABABBBAABABA', 'B', 7), [5, 7, 'B', None, False]),
  ('variant scenario 1', ('BAABA', 'A', 10), [3, 2, None, 'B', False]),
  ('variant scenario 2', ('ABBA', 'A', 7), [2, 2, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin', ('BABABAAABBBB', 'B', 7), [5, 7, 'B', None, False]),
  ('regression: two point margin', ('ABBAABBBBAAAB', 'A', 7), [6, 7, None, 'B', False]),
  ('variant scenario 1', ('BAABBBBBABBAABBB', 'B', 10), [5, 10, 'B', None, False]),
  ('variant scenario 2', ('A', 'A', 7), [1, 0, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin', ('AABBBABBAAAABAA', 'A', 7), [7, 5, 'A', None, False]),
  ('regression: two point margin', ('BAAAABBBBABABABBA', 'A', 7), [7, 9, 'B', None, False]),
  ('variant scenario 1', ('BBABABB', 'B', 10), [2, 5, None, 'B', False]),
  ('variant scenario 2', ('ABBBABAAAAABAABBBAB', 'B', 7), [7, 4, 'A', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin', ('ABBAAABBAABBBBABBABA', 'B', 7), [6, 8, 'B', None, False]),
  ('variant scenario 1', ('ABBAA', 'B', 10), [3, 2, None, 'A', False]),
  ('variant scenario 2', ('AAAAAAABAABAABBBBBAABA', 'B', 10), [10, 2, 'A', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin',
   ('BABABBABAABAABBBABABABBB', 'A', 10),
   [8, 10, 'B', None, False]),
  ('regression: two point margin', ('BABBAABBAABABBABBBAAA', 'B', 7), [6, 8, 'B', None, False]),
  ('variant scenario 1', ('ABBBBAAABBBAABBAAA', 'A', 7), [4, 7, 'B', None, False]),
  ('variant scenario 2', ('BABABAB', 'A', 7), [3, 4, None, 'A', False])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return max(x, y) >= target and abs(x - y) > 2
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
        if finished(a, b):
            break
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if ((played + 1) // 2) % 2 == 0 else other
    ends_change = played > 0 and played % 6 == 0 and winner is None
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin', ('AAAABABABBBBB', 'A', 7), [6, 7, None, 'B', False]),
  ('regression: two point margin', ('BABABBBAABABA', 'B', 7), [5, 7, 'B', None, False]),
  ('variant scenario 1', ('BAABA', 'A', 10), [3, 2, None, 'B', False]),
  ('variant scenario 2', ('ABBA', 'A', 7), [2, 2, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin', ('BABABAAABBBB', 'B', 7), [5, 7, 'B', None, False]),
  ('regression: two point margin', ('ABBAABBBBAAAB', 'A', 7), [6, 7, None, 'B', False]),
  ('variant scenario 1', ('BAABBBBBABBAABBB', 'B', 10), [5, 10, 'B', None, False]),
  ('variant scenario 2', ('A', 'A', 7), [1, 0, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin', ('AABBBABBAAAABAA', 'A', 7), [7, 5, 'A', None, False]),
  ('regression: two point margin', ('BAAAABBBBABABABBA', 'A', 7), [7, 9, 'B', None, False]),
  ('variant scenario 1', ('BBABABB', 'B', 10), [2, 5, None, 'B', False]),
  ('variant scenario 2', ('ABBBABAAAAABAABBBAB', 'B', 7), [7, 4, 'A', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin', ('ABBAAABBAABBBBABBABA', 'B', 7), [6, 8, 'B', None, False]),
  ('variant scenario 1', ('ABBAA', 'B', 10), [3, 2, None, 'A', False]),
  ('variant scenario 2', ('AAAAAAABAABAABBBBBAABA', 'B', 10), [10, 2, 'A', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: two point margin',
   ('BABABBABAABAABBBABABABBB', 'A', 10),
   [8, 10, 'B', None, False]),
  ('regression: two point margin', ('BABBAABBAABABBABBBAAA', 'B', 7), [6, 8, 'B', None, False]),
  ('variant scenario 1', ('ABBBBAAABBBAABBAAA', 'A', 7), [4, 7, 'B', None, False]),
  ('variant scenario 2', ('BABABAB', 'A', 7), [3, 4, None, 'A', False])]]
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)

prompt:
A tiebreak at 7-6 is reported as won instead of continuing.

Tiebreak game. points is a string of A/B point winners; target is 7 (standard) or 10 (match tiebreak). The tiebreak ends at the first point where a player has at least target points and a two-point lead; later points are ignored. first_server serves point 0, then serve alternates every two points (point k is served by first_server when ((k + 1) // 2) is even). Return [a, b, winner or None, server of the next point or None when finished, ends_change] where ends_change is true when the tiebreak is unfinished and a positive multiple of 6 points has been played.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return max(x, y) > target and abs(x - y) >= 2
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
        if finished(a, b):
            break
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if ((played + 1) // 2) % 2 == 0 else other
    ends_change = played > 0 and played % 6 == 0 and winner is None
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('BBBBABBB', 'A', 7), [1, 7, 'B', None, False]),
  ('variant scenario 1', ('B', 'A', 7), [0, 1, None, 'B', False]),
  ('variant scenario 2', ('BAAA', 'A', 10), [3, 1, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('BBAAAABBBABBB', 'B', 7), [5, 7, 'B', None, False]),
  ('regression: target threshold', ('BAAAABBAABAABBAB', 'B', 7), [7, 4, 'A', None, False]),
  ('variant scenario 1', ('AAAAA', 'B', 7), [5, 0, None, 'A', False]),
  ('variant scenario 2', ('ABBA', 'A', 7), [2, 2, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('AAABABA', 'A', 7), [5, 2, None, 'A', False]),
  ('regression: target threshold', ('ABABAABAAABA', 'B', 7), [7, 3, 'A', None, False]),
  ('variant scenario 1', ('AA', 'A', 10), [2, 0, None, 'B', False]),
  ('variant scenario 2', ('BABBBABBABBABA', 'B', 10), [5, 9, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('BBBBABABABBBBABABB', 'B', 10), [3, 10, 'B', None, False]),
  ('variant scenario 1', ('ABB', 'B', 7), [1, 2, None, 'B', False]),
  ('variant scenario 2', ('AABAAABBBABABBBBABBBB', 'A', 10), [8, 10, 'B', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('BBABBBBBBBABBBBABABBAA', 'A', 10), [2, 10, 'B', None, False]),
  ('variant scenario 1', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('variant scenario 2', ('BBBBABBAABBBAABB', 'A', 7), [3, 7, 'B', None, False])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return x + y >= target and abs(x - y) >= 2
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
        if finished(a, b):
            break
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if ((played + 1) // 2) % 2 == 0 else other
    ends_change = played > 0 and played % 6 == 0 and winner is None
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('BBBBABBB', 'A', 7), [1, 7, 'B', None, False]),
  ('variant scenario 1', ('B', 'A', 7), [0, 1, None, 'B', False]),
  ('variant scenario 2', ('BAAA', 'A', 10), [3, 1, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('BBAAAABBBABBB', 'B', 7), [5, 7, 'B', None, False]),
  ('regression: target threshold', ('BAAAABBAABAABBAB', 'B', 7), [7, 4, 'A', None, False]),
  ('variant scenario 1', ('AAAAA', 'B', 7), [5, 0, None, 'A', False]),
  ('variant scenario 2', ('ABBA', 'A', 7), [2, 2, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('AAABABA', 'A', 7), [5, 2, None, 'A', False]),
  ('regression: target threshold', ('ABABAABAAABA', 'B', 7), [7, 3, 'A', None, False]),
  ('variant scenario 1', ('AA', 'A', 10), [2, 0, None, 'B', False]),
  ('variant scenario 2', ('BABBBABBABBABA', 'B', 10), [5, 9, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('BBBBABABABBBBABABB', 'B', 10), [3, 10, 'B', None, False]),
  ('variant scenario 1', ('ABB', 'B', 7), [1, 2, None, 'B', False]),
  ('variant scenario 2', ('AABAAABBBABABBBBABBBB', 'A', 10), [8, 10, 'B', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: target threshold', ('BBABBBBBBBABBBBABABBAA', 'A', 10), [2, 10, 'B', None, False]),
  ('variant scenario 1', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('variant scenario 2', ('BBBBABBAABBBAABB', 'A', 7), [3, 7, 'B', None, False])]]
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)

prompt:
A 7-5 tiebreak is not closed and play continues to eight points.

Tiebreak game. points is a string of A/B point winners; target is 7 (standard) or 10 (match tiebreak). The tiebreak ends at the first point where a player has at least target points and a two-point lead; later points are ignored. first_server serves point 0, then serve alternates every two points (point k is served by first_server when ((k + 1) // 2) is even). Return [a, b, winner or None, server of the next point or None when finished, ends_change] where ends_change is true when the tiebreak is unfinished and a positive multiple of 6 points has been played.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return max(x, y) >= target and abs(x - y) >= 2
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
        if finished(a, b):
            break
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if (played // 2) % 2 == 0 else other
    ends_change = played > 0 and played % 6 == 0 and winner is None
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('BAABAAABB', 'B', 7), [5, 4, None, 'A', False]),
  ('regression: service rotation phase', ('BABAAA', 'B', 7), [4, 2, None, 'A', True]),
  ('variant scenario 1', ('BBAABBBABBBB', 'B', 7), [3, 7, 'B', None, False]),
  ('variant scenario 2', ('AAAB', 'A', 7), [3, 1, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('ABBAAAA', 'B', 10), [5, 2, None, 'B', False]),
  ('variant scenario 1', ('AABBAAABABAAABB', 'A', 7), [7, 4, 'A', None, False]),
  ('variant scenario 2', ('BBBB', 'B', 7), [0, 4, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('AAAAAA', 'B', 7), [6, 0, None, 'A', True]),
  ('regression: service rotation phase', ('BBABB', 'B', 7), [1, 4, None, 'A', False]),
  ('variant scenario 1', ('BBABBA', 'A', 7), [2, 4, None, 'B', True]),
  ('variant scenario 2', ('BAB', 'B', 7), [1, 2, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('BAABBAABBBABAAA', 'B', 10), [8, 7, None, 'B', False]),
  ('variant scenario 1', ('BBABAAABAABB', 'B', 7), [6, 6, None, 'B', True]),
  ('variant scenario 2', ('ABAAABBBBBAAAAABBABAB', 'A', 7), [8, 6, 'A', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('AABABBABAABBAB', 'A', 10), [7, 7, None, 'B', False]),
  ('regression: service rotation phase', ('BABBB', 'A', 7), [1, 4, None, 'B', False]),
  ('variant scenario 1', ('BAAABBBBBAABBBAABAABAB', 'A', 10), [7, 10, 'B', None, False]),
  ('variant scenario 2', ('BBAAABBBABBBA', 'B', 7), [4, 7, 'B', None, False])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return max(x, y) >= target and abs(x - y) >= 2
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
        if finished(a, b):
            break
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if played % 2 == 0 else other
    ends_change = played > 0 and played % 6 == 0 and winner is None
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('BAABAAABB', 'B', 7), [5, 4, None, 'A', False]),
  ('regression: service rotation phase', ('BABAAA', 'B', 7), [4, 2, None, 'A', True]),
  ('variant scenario 1', ('BBAABBBABBBB', 'B', 7), [3, 7, 'B', None, False]),
  ('variant scenario 2', ('AAAB', 'A', 7), [3, 1, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('ABBAAAA', 'B', 10), [5, 2, None, 'B', False]),
  ('variant scenario 1', ('AABBAAABABAAABB', 'A', 7), [7, 4, 'A', None, False]),
  ('variant scenario 2', ('BBBB', 'B', 7), [0, 4, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('AAAAAA', 'B', 7), [6, 0, None, 'A', True]),
  ('regression: service rotation phase', ('BBABB', 'B', 7), [1, 4, None, 'A', False]),
  ('variant scenario 1', ('BBABBA', 'A', 7), [2, 4, None, 'B', True]),
  ('variant scenario 2', ('BAB', 'B', 7), [1, 2, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('BAABBAABBBABAAA', 'B', 10), [8, 7, None, 'B', False]),
  ('variant scenario 1', ('BBABAAABAABB', 'B', 7), [6, 6, None, 'B', True]),
  ('variant scenario 2', ('ABAAABBBBBAAAAABBABAB', 'A', 7), [8, 6, 'A', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: service rotation phase', ('AABABBABAABBAB', 'A', 10), [7, 7, None, 'B', False]),
  ('regression: service rotation phase', ('BABBB', 'A', 7), [1, 4, None, 'B', False]),
  ('variant scenario 1', ('BAAABBBBBAABBBAABAABAB', 'A', 10), [7, 10, 'B', None, False]),
  ('variant scenario 2', ('BBAAABBBABBBA', 'B', 7), [4, 7, 'B', None, False])]]
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)

prompt:
The server indicator shows the wrong player after the first point of a tiebreak.

Tiebreak game. points is a string of A/B point winners; target is 7 (standard) or 10 (match tiebreak). The tiebreak ends at the first point where a player has at least target points and a two-point lead; later points are ignored. first_server serves point 0, then serve alternates every two points (point k is served by first_server when ((k + 1) // 2) is even). Return [a, b, winner or None, server of the next point or None when finished, ends_change] where ends_change is true when the tiebreak is unfinished and a positive multiple of 6 points has been played.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return max(x, y) >= target and abs(x - y) >= 2
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if ((played + 1) // 2) % 2 == 0 else other
    ends_change = played > 0 and played % 6 == 0 and winner is None
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion', ('AAAABBBBAAABB', 'A', 7), [7, 4, 'A', None, False]),
  ('regression: points after completion', ('AABBBABBBBBAB', 'B', 7), [3, 7, 'B', None, False]),
  ('variant scenario 1', ('ABAABABAA', 'A', 7), [6, 3, None, 'B', False]),
  ('variant scenario 2', ('AAAABBBBAABBB', 'A', 10), [6, 7, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion', ('AAAAAAABBABA', 'A', 7), [7, 0, 'A', None, False]),
  ('regression: points after completion', ('BBBBABBBBABBBB', 'A', 7), [1, 7, 'B', None, False]),
  ('variant scenario 1', ('ABABAABBAAAABA', 'A', 10), [9, 5, None, 'B', False]),
  ('variant scenario 2', ('ABBBAAABAA', 'B', 7), [6, 4, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion', ('ABBAABBBBBAAABAA', 'B', 7), [3, 7, 'B', None, False]),
  ('variant scenario 1', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('variant scenario 2', ('BAA', 'A', 7), [2, 1, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion',
   ('AAAABABABAABBBBBAABB', 'A', 7),
   [7, 3, 'A', None, False]),
  ('regression: points after completion',
   ('ABBBBBBAABABBBABBBBBA', 'A', 7),
   [3, 7, 'B', None, False]),
  ('variant scenario 1', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('variant scenario 2', ('BABAA', 'B', 10), [3, 2, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion',
   ('BABABAAABBABABAAABABAA', 'A', 10),
   [10, 7, 'A', None, False]),
  ('regression: points after completion',
   ('BABABBBBABABBBAABBBAABBAA', 'B', 10),
   [4, 10, 'B', None, False]),
  ('variant scenario 1', ('AABABAABAABABAABB', 'B', 10), [10, 5, 'A', None, False]),
  ('variant scenario 2', ('BABAABA', 'A', 7), [4, 3, None, 'A', False])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return max(x, y) >= target and abs(x - y) >= 2
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
        if finished(a, b) and a > b:
            break
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if ((played + 1) // 2) % 2 == 0 else other
    ends_change = played > 0 and played % 6 == 0 and winner is None
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion', ('AAAABBBBAAABB', 'A', 7), [7, 4, 'A', None, False]),
  ('regression: points after completion', ('AABBBABBBBBAB', 'B', 7), [3, 7, 'B', None, False]),
  ('variant scenario 1', ('ABAABABAA', 'A', 7), [6, 3, None, 'B', False]),
  ('variant scenario 2', ('AAAABBBBAABBB', 'A', 10), [6, 7, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion', ('AAAAAAABBABA', 'A', 7), [7, 0, 'A', None, False]),
  ('regression: points after completion', ('BBBBABBBBABBBB', 'A', 7), [1, 7, 'B', None, False]),
  ('variant scenario 1', ('ABABAABBAAAABA', 'A', 10), [9, 5, None, 'B', False]),
  ('variant scenario 2', ('ABBBAAABAA', 'B', 7), [6, 4, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion', ('ABBAABBBBBAAABAA', 'B', 7), [3, 7, 'B', None, False]),
  ('variant scenario 1', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('variant scenario 2', ('BAA', 'A', 7), [2, 1, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion',
   ('AAAABABABAABBBBBAABB', 'A', 7),
   [7, 3, 'A', None, False]),
  ('regression: points after completion',
   ('ABBBBBBAABABBBABBBBBA', 'A', 7),
   [3, 7, 'B', None, False]),
  ('variant scenario 1', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('variant scenario 2', ('BABAA', 'B', 10), [3, 2, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: points after completion',
   ('BABABAAABBABABAAABABAA', 'A', 10),
   [10, 7, 'A', None, False]),
  ('regression: points after completion',
   ('BABABBBBABABBBAABBBAABBAA', 'B', 10),
   [4, 10, 'B', None, False]),
  ('variant scenario 1', ('AABABAABAABABAABB', 'B', 10), [10, 5, 'A', None, False]),
  ('variant scenario 2', ('BABAABA', 'A', 7), [4, 3, None, 'A', False])]]
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)

prompt:
A log that contains trailing warm-up points changes the final tiebreak score.

Tiebreak game. points is a string of A/B point winners; target is 7 (standard) or 10 (match tiebreak). The tiebreak ends at the first point where a player has at least target points and a two-point lead; later points are ignored. first_server serves point 0, then serve alternates every two points (point k is served by first_server when ((k + 1) // 2) is even). Return [a, b, winner or None, server of the next point or None when finished, ends_change] where ends_change is true when the tiebreak is unfinished and a positive multiple of 6 points has been played.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return max(x, y) >= target and abs(x - y) >= 2
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
        if finished(a, b):
            break
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if ((played + 1) // 2) % 2 == 0 else other
    ends_change = played % 6 == 0
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('', 'A', 10), [0, 0, None, 'A', False]),
  ('regression: ends change conditions', ('AABBABBBABABB', 'A', 7), [5, 7, 'B', None, False]),
  ('variant scenario 1', ('BBBAABABB', 'A', 7), [3, 6, None, 'B', False]),
  ('variant scenario 2', ('A', 'A', 7), [1, 0, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('regression: ends change conditions', ('BBAAAAAABBBAAAA', 'A', 7), [7, 5, 'A', None, False]),
  ('variant scenario 1', ('BAAAAABAABAABB', 'A', 7), [7, 2, 'A', None, False]),
  ('variant scenario 2', ('ABABAABAABABAB', 'A', 7), [7, 4, 'A', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('BBAABBAAAABAAA', 'A', 7), [7, 5, 'A', None, False]),
  ('variant scenario 1', ('BBBAAA', 'B', 7), [3, 3, None, 'A', True]),
  ('variant scenario 2', ('', 'A', 7), [0, 0, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('AABABBAAABBAABABA', 'B', 7), [7, 5, 'A', None, False]),
  ('variant scenario 1', ('AAAABAABABBABAAB', 'B', 10), [10, 5, 'A', None, False]),
  ('variant scenario 2', ('ABB', 'B', 7), [1, 2, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('BBBABAAAABAABABBBAA', 'B', 7), [7, 5, 'A', None, False]),
  ('variant scenario 1', ('AABBB', 'B', 7), [2, 3, None, 'A', False]),
  ('variant scenario 2', ('ABBBAABBBBAB', 'B', 10), [4, 8, None, 'B', True])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(points, first_server, target):
    def finished(x, y):
        return max(x, y) >= target and abs(x - y) >= 2
    a = b = 0
    for p in points:
        if p == 'A':
            a += 1
        else:
            b += 1
        if finished(a, b):
            break
    played = a + b
    winner = None
    if finished(a, b):
        winner = 'A' if a > b else 'B'
    other = 'B' if first_server == 'A' else 'A'
    server = first_server if ((played + 1) // 2) % 2 == 0 else other
    ends_change = played > 0 and played % 6 == 0
    return [a, b, winner, None if winner else server, ends_change]
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 opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('', 'A', 10), [0, 0, None, 'A', False]),
  ('regression: ends change conditions', ('AABBABBBABABB', 'A', 7), [5, 7, 'B', None, False]),
  ('variant scenario 1', ('BBBAABABB', 'A', 7), [3, 6, None, 'B', False]),
  ('variant scenario 2', ('A', 'A', 7), [1, 0, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('regression: ends change conditions', ('BBAAAAAABBBAAAA', 'A', 7), [7, 5, 'A', None, False]),
  ('variant scenario 1', ('BAAAAABAABAABB', 'A', 7), [7, 2, 'A', None, False]),
  ('variant scenario 2', ('ABABAABAABABAB', 'A', 7), [7, 4, 'A', None, False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('BBAABBAAAABAAA', 'A', 7), [7, 5, 'A', None, False]),
  ('variant scenario 1', ('BBBAAA', 'B', 7), [3, 3, None, 'A', True]),
  ('variant scenario 2', ('', 'A', 7), [0, 0, None, 'A', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('AABABBAAABBAABABA', 'B', 7), [7, 5, 'A', None, False]),
  ('variant scenario 1', ('AAAABAABABBABAAB', 'B', 10), [10, 5, 'A', None, False]),
  ('variant scenario 2', ('ABB', 'B', 7), [1, 2, None, 'B', False])],
 [('control opening point', ('', 'A', 7), [0, 0, None, 'A', False]),
  ('boundary second server pair', ('A', 'A', 7), [1, 0, None, 'B', False]),
  ('boundary third point back to first', ('AB', 'B', 7), [1, 1, None, 'A', False]),
  ('control seven-five tiebreak', ('AAAAABBBBBAA', 'A', 7), [7, 5, 'A', None, False]),
  ('boundary change of ends at six', ('ABABAB', 'A', 7), [3, 3, None, 'B', True]),
  ('control match tiebreak not over at seven', ('AAAAAAA', 'B', 10), [7, 0, None, 'B', False]),
  ('regression: ends change conditions', ('BBBABAAAABAABABBBAA', 'B', 7), [7, 5, 'A', None, False]),
  ('variant scenario 1', ('AABBB', 'B', 7), [2, 3, None, 'A', False]),
  ('variant scenario 2', ('ABBBAABBBBAB', 'B', 10), [4, 8, None, 'B', True])]]
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)

prompt:
The umpire is told to change ends before any point is played or after a 7-5 finish.

Tiebreak game. points is a string of A/B point winners; target is 7 (standard) or 10 (match tiebreak). The tiebreak ends at the first point where a player has at least target points and a two-point lead; later points are ignored. first_server serves point 0, then serve alternates every two points (point k is served by first_server when ((k + 1) // 2) is even). Return [a, b, winner or None, server of the next point or None when finished, ends_change] where ends_change is true when the tiebreak is unfinished and a positive multiple of 6 points has been played.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(games, best_of):
    sets = []
    a = b = 0
    won = {'A': 0, 'B': 0}
    need = best_of // 2 + 1
    for g in games:
        if g == 'A':
            a += 1
        else:
            b += 1
        if (max(a, b) >= 6 and abs(a - b) >= 2):
            w = 'A' if a > b else 'B'
            won[w] += 1
            sets.append('%d-%d' % (a, b))
            a = b = 0
            if won[w] == need:
                return [sets, w]
    if a or b:
        sets.append('%d-%d' % (a, b))
    return [sets, None]
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 bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure', ('AAABAABBBAABABABABBABAA', 3), [['6-4', '7-6'], 'A']),
  ('variant scenario 1', ('AAAAAA', 5), [['6-0'], None]),
  ('variant scenario 2', ('AAABBBAAAABBAAAAAAAAABABAA', 3), [['6-3', '6-2'], 'A'])],
 [('control bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure',
   ('BAAABBBBAABABAAAABABBAB', 5),
   [['6-7', '6-3', '0-1'], None]),
  ('variant scenario 1', ('ABBBAABABBA', 5), [['4-6', '1-0'], None]),
  ('variant scenario 2', ('ABABAA', 3), [['4-2'], None])],
 [('control bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure',
   ('AABAABBBBAABBABABAABABABABBA', 3),
   [['6-7', '6-4', '2-3'], None]),
  ('variant scenario 1', ('ABBABABBBABBBABAB', 5), [['3-6', '3-5'], None]),
  ('variant scenario 2', ('BBABBAAAAABBAAABBABAABABBBAAAABAAA', 3), [['6-4', '7-6'], 'A'])],
 [('control bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure', ('BABABABBAAABBBBBB', 3), [['6-7', '0-4'], None]),
  ('variant scenario 1',
   ('AABAABBBAAAAABBBBAAABABBABBBABAAABABBAAABBABABAABB', 5),
   [['6-4', '6-4', '2-6', '6-4'], 'A']),
  ('variant scenario 2', ('BABAABAAAAABAABAAABABBBA', 3), [['6-3', '6-2'], 'A'])],
 [('control bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure',
   ('BBAABABBBBAAAABABBBBABABABAABBABAAABBAAAABAB', 3),
   [['3-6', '6-7'], 'B']),
  ('variant scenario 1',
   ('AAAAABBAAAABBABBBBABAAAAABBAAAAABBAAAA', 5),
   [['6-2', '4-6', '6-1', '6-4'], 'A']),
  ('variant scenario 2',
   ('BABABBAAAAAABABAAAABAAAABAAABAABBBABAAABBBAABABABAAAB', 5),
   [['6-4', '6-2', '6-2'], 'A'])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(games, best_of):
    sets = []
    a = b = 0
    won = {'A': 0, 'B': 0}
    need = best_of // 2 + 1
    for g in games:
        if g == 'A':
            a += 1
        else:
            b += 1
        if (max(a, b) >= 6 and abs(a - b) >= 2) or a + b == 12:
            w = 'A' if a > b else 'B'
            won[w] += 1
            sets.append('%d-%d' % (a, b))
            a = b = 0
            if won[w] == need:
                return [sets, w]
    if a or b:
        sets.append('%d-%d' % (a, b))
    return [sets, None]
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 bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure', ('AAABAABBBAABABABABBABAA', 3), [['6-4', '7-6'], 'A']),
  ('variant scenario 1', ('AAAAAA', 5), [['6-0'], None]),
  ('variant scenario 2', ('AAABBBAAAABBAAAAAAAAABABAA', 3), [['6-3', '6-2'], 'A'])],
 [('control bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure',
   ('BAAABBBBAABABAAAABABBAB', 5),
   [['6-7', '6-3', '0-1'], None]),
  ('variant scenario 1', ('ABBBAABABBA', 5), [['4-6', '1-0'], None]),
  ('variant scenario 2', ('ABABAA', 3), [['4-2'], None])],
 [('control bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure',
   ('AABAABBBBAABBABABAABABABABBA', 3),
   [['6-7', '6-4', '2-3'], None]),
  ('variant scenario 1', ('ABBABABBBABBBABAB', 5), [['3-6', '3-5'], None]),
  ('variant scenario 2', ('BBABBAAAAABBAAABBABAABABBBAAAABAAA', 3), [['6-4', '7-6'], 'A'])],
 [('control bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure', ('BABABABBAAABBBBBB', 3), [['6-7', '0-4'], None]),
  ('variant scenario 1',
   ('AABAABBBAAAAABBBBAAABABBABBBABAAABABBAAABBABABAABB', 5),
   [['6-4', '6-4', '2-6', '6-4'], 'A']),
  ('variant scenario 2', ('BABAABAAAAABAABAAABABBBA', 3), [['6-3', '6-2'], 'A'])],
 [('control bagel set', ('AAAAAA', 3), [['6-0'], None]),
  ('boundary seven-five', ('AAAAABBBBBAA', 3), [['7-5'], None]),
  ('boundary tiebreak set', ('AAAAABBBBBABB', 3), [['6-7'], None]),
  ('control straight sets', ('AAAAAAAAAAAA', 3), [['6-0', '6-0'], 'A']),
  ('control in-progress set', ('AAAAAAB', 3), [['6-0', '0-1'], None]),
  ('control empty', ('', 5), [[], None]),
  ('regression: tiebreak set closure',
   ('BBAABABBBBAAAABABBBBABABABAABBABAAABBAAAABAB', 3),
   [['3-6', '6-7'], 'B']),
  ('variant scenario 1',
   ('AAAAABBAAAABBABBBBABAAAAABBAAAAABBAAAA', 5),
   [['6-2', '4-6', '6-1', '6-4'], 'A']),
  ('variant scenario 2',
   ('BABABBAAAAAABABAAAABAAAABAAABAABBBABAAABBBAABABABAAAB', 5),
   [['6-4', '6-2', '6-2'], 'A'])]]
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)

prompt:
A set that went to a tiebreak is reported as 8-6 or longer instead of 7-6.

games is a string of game winners (A/B); best_of is 3 or 5. A set is won by the first player to 6 games with a lead of two, or at 7 games (7-5, or 7-6 after the tiebreak game played at 6-6). The match ends when a player has won best_of // 2 + 1 sets; later games are ignored. Return [set scores as "a-b" strings in A-B order, match winner or None]; an unfinished set with at least one game is appended as its current score.

split: open-access