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

N = 1
observations = []
def solve(code, data):
    starts = {'A': 103, 'B': 104, 'C': 105}
    if code not in starts:
        return None
    if code == 'C':
        if len(data) % 2 or not data.isascii() or not data.isdigit():
            return None
        values = [int(data[i:i + 2]) for i in range(0, len(data), 2)]
    elif code == 'B':
        if any(not 32 <= ord(ch) <= 126 for ch in data):
            return None
        values = [ord(ch) - 32 for ch in data]
    else:
        if any(not 0 <= ord(ch) <= 95 for ch in data):
            return None
        values = [ord(ch) - 32 if ord(ch) >= 32 else ord(ch) + 64 for ch in data]
    total = starts[code]
    for pos, v in enumerate(values, 1):
        total += pos * v
    return total % 103
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["B", "@w~\'"]', ['B', "@w~'"], 2], ['control ["B", "Ht?"]', ['B', 'Ht?'], 96], ['control ["B", "U?tS;F"]', ['B', 'U?tS;F'], 8], ['control ["B", ")r"]', ['B', ')r'], 71], ['control ["B", "YyUx>VrW{?"]', ['B', 'YyUx>VrW{?'], 68], ['control ["B", "4Y&P%jOM+J/"]', ['B', '4Y&P%jOM+J/'], 24]], [['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['control ["B", "4Y&P%jOM+J/"]', ['B', '4Y&P%jOM+J/'], 24], ['control ["B", "wm$|^uemYo/"]', ['B', 'wm$|^uemYo/'], 95], ['control ["B", "UI}*7pnZebjZ"]', ['B', 'UI}*7pnZebjZ'], 10], ['control ["B", "GOJ%^JsFlN="]', ['B', 'GOJ%^JsFlN='], 100], ['control ["B", "{j]OWCR"]', ['B', '{j]OWCR'], 4], ['control ["C", "9158"]', ['C', '9158'], 3]], [['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["C", "9158"]', ['C', '9158'], 3], ['control ["C", "32273629"]', ['C', '32273629'], 3], ['control ["C", "976797"]', ['C', '976797'], 9], ['control ["C", "209091"]', ['C', '209091'], 63], ['control ["C", "5357244392"]', ['C', '5357244392'], 49], ['control ["C", "68"]', ['C', '68'], 70]], [['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['control ["C", "68"]', ['C', '68'], 70], ['control ["A", "0%!J\\u0011"]', ['A', '0%!J\x11'], 87], ['control ["A", "\\u0005\\u00000_;V"]', ['A', '\x05\x000_;V'], 29], ['control ["A", "\\u0005\\u0017F"]', ['A', '\x05\x17F'], 48], ['control ["A", ",B\\u001e\\u000e_#Y"]', ['A', ',B\x1e\x0e_#Y'], 67], ['control ["A", "\\u0010\\u0015>D\\u0001\\u0013"]', ['A', '\x10\x15>D\x01\x13'], 71]], [['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["A", "\\u0010\\u0015>D\\u0001\\u0013"]', ['A', '\x10\x15>D\x01\x13'], 71], ['control ["A", "H\\u0010\\u001c7F"]', ['A', 'H\x10\x1c7F'], 37], ['control ["B", "PJJ123C"]', ['B', 'PJJ123C'], 55], ['control ["B", "Wikipedia"]', ['B', 'Wikipedia'], 88], ['control ["C", "123456"]', ['C', '123456'], 44], ['control ["C", "12345"]', ['C', '12345'], None]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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(code, data):
    starts = {'A': 103, 'B': 104, 'C': 105}
    if code not in starts:
        return None
    if code == 'C':
        if len(data) % 2 or not data.isascii() or not data.isdigit():
            return None
        values = [int(data[i:i + 2]) for i in range(0, len(data), 2)]
    elif code == 'B':
        if any(not (32 <= ord(ch) <= 127 and ch.isprintable()) for ch in data):
            return None
        values = [ord(ch) - 32 for ch in data]
    else:
        if any(not 0 <= ord(ch) <= 95 for ch in data):
            return None
        values = [ord(ch) - 32 if ord(ch) >= 32 else ord(ch) + 64 for ch in data]
    total = starts[code]
    for pos, v in enumerate(values, 1):
        total += pos * v
    return total % 103
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["B", "@w~\'"]', ['B', "@w~'"], 2], ['control ["B", "Ht?"]', ['B', 'Ht?'], 96], ['control ["B", "U?tS;F"]', ['B', 'U?tS;F'], 8], ['control ["B", ")r"]', ['B', ')r'], 71], ['control ["B", "YyUx>VrW{?"]', ['B', 'YyUx>VrW{?'], 68], ['control ["B", "4Y&P%jOM+J/"]', ['B', '4Y&P%jOM+J/'], 24]], [['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['control ["B", "4Y&P%jOM+J/"]', ['B', '4Y&P%jOM+J/'], 24], ['control ["B", "wm$|^uemYo/"]', ['B', 'wm$|^uemYo/'], 95], ['control ["B", "UI}*7pnZebjZ"]', ['B', 'UI}*7pnZebjZ'], 10], ['control ["B", "GOJ%^JsFlN="]', ['B', 'GOJ%^JsFlN='], 100], ['control ["B", "{j]OWCR"]', ['B', '{j]OWCR'], 4], ['control ["C", "9158"]', ['C', '9158'], 3]], [['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["C", "9158"]', ['C', '9158'], 3], ['control ["C", "32273629"]', ['C', '32273629'], 3], ['control ["C", "976797"]', ['C', '976797'], 9], ['control ["C", "209091"]', ['C', '209091'], 63], ['control ["C", "5357244392"]', ['C', '5357244392'], 49], ['control ["C", "68"]', ['C', '68'], 70]], [['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['control ["C", "68"]', ['C', '68'], 70], ['control ["A", "0%!J\\u0011"]', ['A', '0%!J\x11'], 87], ['control ["A", "\\u0005\\u00000_;V"]', ['A', '\x05\x000_;V'], 29], ['control ["A", "\\u0005\\u0017F"]', ['A', '\x05\x17F'], 48], ['control ["A", ",B\\u001e\\u000e_#Y"]', ['A', ',B\x1e\x0e_#Y'], 67], ['control ["A", "\\u0010\\u0015>D\\u0001\\u0013"]', ['A', '\x10\x15>D\x01\x13'], 71]], [['regression ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['regression ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["A", "\\u0010\\u0015>D\\u0001\\u0013"]', ['A', '\x10\x15>D\x01\x13'], 71], ['control ["A", "H\\u0010\\u001c7F"]', ['A', 'H\x10\x1c7F'], 37], ['control ["B", "PJJ123C"]', ['B', 'PJJ123C'], 55], ['control ["B", "Wikipedia"]', ['B', 'Wikipedia'], 88], ['control ["C", "123456"]', ['C', '123456'], 44], ['control ["C", "12345"]', ['C', '12345'], None]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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:
Data containing DEL (value 95) in set B is refused.

Code 128 symbol check value. Start codes A/B/C have values 103/104/105 (other codes: None). Code B accepts characters 32..127 (value ord - 32); code A accepts 0..95 (values ord - 32, controls ord + 64); code C accepts an even number of ASCII digits taken in pairs (value 0..99). The checksum is (start + sum(position * value)) mod 103 with positions starting at 1 after the start code. Invalid data returns None.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
Codes ending in compressed digit 2 expand into the wrong manufacturer number.

Expand an 8-digit UPC-E (number system 0 or 1, six compressed digits m1..m6, check digit) to UPC-A. By m6: 0-2 -> m1 m2 m6 0000 m3 m4 m5; 3 -> m1 m2 m3 00000 m4 m5; 4 -> m1 m2 m3 m4 00000 m5; 5-9 -> m1..m5 0000 m6. The UPC-A check (weights 3,1 from the left over the 11 digits) must equal the given check digit; return the 12-digit UPC-A string, or None for malformed or mismatching input.

split: open-access


prompt:
Codes ending in compressed digit 4 expand to the wrong product number.

Expand an 8-digit UPC-E (number system 0 or 1, six compressed digits m1..m6, check digit) to UPC-A. By m6: 0-2 -> m1 m2 m6 0000 m3 m4 m5; 3 -> m1 m2 m3 00000 m4 m5; 4 -> m1 m2 m3 m4 00000 m5; 5-9 -> m1..m5 0000 m6. The UPC-A check (weights 3,1 from the left over the 11 digits) must equal the given check digit; return the 12-digit UPC-A string, or None for malformed or mismatching input.

split: open-access


prompt:
Codes ending in 5-9 expand into shifted UPC-A numbers.

Expand an 8-digit UPC-E (number system 0 or 1, six compressed digits m1..m6, check digit) to UPC-A. By m6: 0-2 -> m1 m2 m6 0000 m3 m4 m5; 3 -> m1 m2 m3 00000 m4 m5; 4 -> m1 m2 m3 m4 00000 m5; 5-9 -> m1..m5 0000 m6. The UPC-A check (weights 3,1 from the left over the 11 digits) must equal the given check digit; return the 12-digit UPC-A string, or None for malformed or mismatching input.

split: open-access


prompt:
Valid UPC-E labels are rejected.

Expand an 8-digit UPC-E (number system 0 or 1, six compressed digits m1..m6, check digit) to UPC-A. By m6: 0-2 -> m1 m2 m6 0000 m3 m4 m5; 3 -> m1 m2 m3 00000 m4 m5; 4 -> m1 m2 m3 m4 00000 m5; 5-9 -> m1..m5 0000 m6. The UPC-A check (weights 3,1 from the left over the 11 digits) must equal the given check digit; return the 12-digit UPC-A string, or None for malformed or mismatching input.

split: open-access


prompt:
Eight-digit strings starting 2-9 are expanded as if they were UPC-E.

Expand an 8-digit UPC-E (number system 0 or 1, six compressed digits m1..m6, check digit) to UPC-A. By m6: 0-2 -> m1 m2 m6 0000 m3 m4 m5; 3 -> m1 m2 m3 00000 m4 m5; 4 -> m1 m2 m3 m4 00000 m5; 5-9 -> m1..m5 0000 m6. The UPC-A check (weights 3,1 from the left over the 11 digits) must equal the given check digit; return the 12-digit UPC-A string, or None for malformed or mismatching input.

split: open-access


prompt:
References whose base is a multiple of 97 are rejected when they carry 97.

Belgian structured payment communication: optional surrounding +++...+++ or ***...*** (matching), slashes ignored, then exactly 12 ASCII digits (else "malformed"). The last two digits must equal the first ten digits mod 97, where a remainder of 0 is written 97. Return whether they match.

split: open-access


prompt:
References written with asterisks are reported malformed.

Belgian structured payment communication: optional surrounding +++...+++ or ***...*** (matching), slashes ignored, then exactly 12 ASCII digits (else "malformed"). The last two digits must equal the first ten digits mod 97, where a remainder of 0 is written 97. Return whether they match.

split: open-access


prompt:
A reference opened with +++ and closed with *** is accepted.

Belgian structured payment communication: optional surrounding +++...+++ or ***...*** (matching), slashes ignored, then exactly 12 ASCII digits (else "malformed"). The last two digits must equal the first ten digits mod 97, where a remainder of 0 is written 97. Return whether they match.

split: open-access


prompt:
Valid VAT numbers are reported invalid.

UK VAT registration number check. Spaces are removed, the text is upper-cased and an optional GB prefix removed; the rest must be 9 ASCII digits (else "malformed"). Weights 8..2 apply to the first seven digits; the last two digits form a number c. Return "mod97" if (sum + c) is divisible by 97, "mod9755" if (sum + c + 55) is, else "invalid".

split: open-access


prompt:
Numbers issued under the offset scheme are reported invalid.

UK VAT registration number check. Spaces are removed, the text is upper-cased and an optional GB prefix removed; the rest must be 9 ASCII digits (else "malformed"). Weights 8..2 apply to the first seven digits; the last two digits form a number c. Return "mod97" if (sum + c) is divisible by 97, "mod9755" if (sum + c + 55) is, else "invalid".

split: open-access


prompt:
Most valid VAT numbers are rejected.

UK VAT registration number check. Spaces are removed, the text is upper-cased and an optional GB prefix removed; the rest must be 9 ASCII digits (else "malformed"). Weights 8..2 apply to the first seven digits; the last two digits form a number c. Return "mod97" if (sum + c) is divisible by 97, "mod9755" if (sum + c + 55) is, else "invalid".

split: open-access


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

N = 1
observations = []
def solve(s):
    A = '0123456789abcdefghijklmnopqrstuvwxyz'
    n = len(A)
    t = s.lower()
    if not t or any(ch not in A for ch in t):
        return None
    factor = 2
    total = 0
    for ch in reversed(t):
        addend = factor * A.index(ch)
        factor = 1 if factor == 2 else 2
        total += addend // 10 + addend % 10
    return A[(n - total % n) % n]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["lyx7g3y"]', ['lyx7g3y'], 'x'], ['regression ["g22"]', ['g22'], 'y'], ['partial-repair ["hn3a6aj"]', ['hn3a6aj'], 'a'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']], [['regression ["i3wknpx64b"]', ['i3wknpx64b'], 'a'], ['regression ["iu2qty"]', ['iu2qty'], 'k'], ['partial-repair ["a5qsqld2"]', ['a5qsqld2'], 'r'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']], [['regression ["60an"]', ['60an'], '9'], ['regression ["bbw4ngt"]', ['bbw4ngt'], 's'], ['partial-repair ["hgvs8gmf0"]', ['hgvs8gmf0'], 'j'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']], [['regression ["nx"]', ['nx'], 'i'], ['regression ["um"]', ['um'], 'x'], ['partial-repair ["0rr"]', ['0rr'], 'q'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']], [['regression ["w35lg7vo1l"]', ['w35lg7vo1l'], 'c'], ['regression ["w"]', ['w'], '7'], ['partial-repair ["yl5unzgy"]', ['yl5unzgy'], '2'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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(s):
    A = '0123456789abcdefghijklmnopqrstuvwxyz'
    n = len(A)
    t = s.lower()
    if not t or any(ch not in A for ch in t):
        return None
    factor = 2
    total = 0
    for ch in reversed(t):
        addend = factor * A.index(ch)
        factor = 1 if factor == 2 else 2
        total += addend % n
    return A[(n - total % n) % n]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["lyx7g3y"]', ['lyx7g3y'], 'x'], ['regression ["g22"]', ['g22'], 'y'], ['partial-repair ["hn3a6aj"]', ['hn3a6aj'], 'a'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']], [['regression ["i3wknpx64b"]', ['i3wknpx64b'], 'a'], ['regression ["iu2qty"]', ['iu2qty'], 'k'], ['partial-repair ["a5qsqld2"]', ['a5qsqld2'], 'r'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']], [['regression ["60an"]', ['60an'], '9'], ['regression ["bbw4ngt"]', ['bbw4ngt'], 's'], ['partial-repair ["hgvs8gmf0"]', ['hgvs8gmf0'], 'j'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']], [['regression ["nx"]', ['nx'], 'i'], ['regression ["um"]', ['um'], 'x'], ['partial-repair ["0rr"]', ['0rr'], 'q'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']], [['regression ["w35lg7vo1l"]', ['w35lg7vo1l'], 'c'], ['regression ["w"]', ['w'], '7'], ['partial-repair ["yl5unzgy"]', ['yl5unzgy'], '2'], ['control ["1"]', ['1'], 'y'], ['control ["s8zc"]', ['s8zc'], '5'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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:
Codes containing letters in doubled positions receive the wrong check character.

Luhn mod N check-character generation over the base-36 alphabet 0-9a-z (input is lower-cased; empty input or any other character returns None). From the rightmost payload character the factor alternates 2,1,2,...; each addend factor * codepoint is folded as addend // 36 + addend % 36; the check is the alphabet character at (36 - sum % 36) % 36.

split: open-access


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

N = 1
observations = []
def solve(s):
    A = '0123456789abcdefghijklmnopqrstuvwxyz'
    n = len(A)
    t = s.lower()
    if not t or any(ch not in A for ch in t):
        return None
    factor = 1
    total = 0
    for ch in reversed(t):
        addend = factor * A.index(ch)
        factor = 1 if factor == 2 else 2
        total += addend // n + addend % n
    return A[(n - total % n) % n]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["lyx7g3y"]', ['lyx7g3y'], 'x'], ['regression ["1"]', ['1'], 'y'], ['partial-repair ["s8zc"]', ['s8zc'], '5'], ['partial-repair ["i3wknpx64b"]', ['i3wknpx64b'], 'a'], ['control ["0rr"]', ['0rr'], 'q'], ['control ["z"]', ['z'], '1'], ['control ["zz"]', ['zz'], '2'], ['control ["abc-1"]', ['abc-1'], None]], [['regression ["hn3a6aj"]', ['hn3a6aj'], 'a'], ['regression ["s8zc"]', ['s8zc'], '5'], ['partial-repair ["a5qsqld2"]', ['a5qsqld2'], 'r'], ['partial-repair ["60an"]', ['60an'], '9'], ['control ["0"]', ['0'], '0'], ['control ["ZZZZZZ"]', ['ZZZZZZ'], '6'], ['control ["0rr"]', ['0rr'], 'q'], ['control ["z"]', ['z'], '1']], [['regression ["iu2qty"]', ['iu2qty'], 'k'], ['regression ["a5qsqld2"]', ['a5qsqld2'], 'r'], ['partial-repair ["um"]', ['um'], 'x'], ['partial-repair ["w35lg7vo1l"]', ['w35lg7vo1l'], 'c'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0'], ['control ["ZZZZZZ"]', ['ZZZZZZ'], '6']], [['regression ["bbw4ngt"]', ['bbw4ngt'], 's'], ['regression ["hgvs8gmf0"]', ['hgvs8gmf0'], 'j'], ['partial-repair ["s8zc"]', ['s8zc'], '5'], ['partial-repair ["i3wknpx64b"]', ['i3wknpx64b'], 'a'], ['control ["z"]', ['z'], '1'], ['control ["zz"]', ['zz'], '2'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None]], [['regression ["um"]', ['um'], 'x'], ['regression ["w35lg7vo1l"]', ['w35lg7vo1l'], 'c'], ['partial-repair ["a5qsqld2"]', ['a5qsqld2'], 'r'], ['partial-repair ["60an"]', ['60an'], '9'], ['control ["ZZZZZZ"]', ['ZZZZZZ'], '6'], ['control ["0rr"]', ['0rr'], 'q'], ['control ["z"]', ['z'], '1'], ['control ["zz"]', ['zz'], '2']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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(s):
    A = '0123456789abcdefghijklmnopqrstuvwxyz'
    n = len(A)
    t = s.lower()
    if not t or any(ch not in A for ch in t):
        return None
    factor = 2 if len(t) % 2 else 1
    total = 0
    for ch in reversed(t):
        addend = factor * A.index(ch)
        factor = 1 if factor == 2 else 2
        total += addend // n + addend % n
    return A[(n - total % n) % n]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["lyx7g3y"]', ['lyx7g3y'], 'x'], ['regression ["1"]', ['1'], 'y'], ['partial-repair ["s8zc"]', ['s8zc'], '5'], ['partial-repair ["i3wknpx64b"]', ['i3wknpx64b'], 'a'], ['control ["0rr"]', ['0rr'], 'q'], ['control ["z"]', ['z'], '1'], ['control ["zz"]', ['zz'], '2'], ['control ["abc-1"]', ['abc-1'], None]], [['regression ["hn3a6aj"]', ['hn3a6aj'], 'a'], ['regression ["s8zc"]', ['s8zc'], '5'], ['partial-repair ["a5qsqld2"]', ['a5qsqld2'], 'r'], ['partial-repair ["60an"]', ['60an'], '9'], ['control ["0"]', ['0'], '0'], ['control ["ZZZZZZ"]', ['ZZZZZZ'], '6'], ['control ["0rr"]', ['0rr'], 'q'], ['control ["z"]', ['z'], '1']], [['regression ["iu2qty"]', ['iu2qty'], 'k'], ['regression ["a5qsqld2"]', ['a5qsqld2'], 'r'], ['partial-repair ["um"]', ['um'], 'x'], ['partial-repair ["w35lg7vo1l"]', ['w35lg7vo1l'], 'c'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None], ['control ["0"]', ['0'], '0'], ['control ["ZZZZZZ"]', ['ZZZZZZ'], '6']], [['regression ["bbw4ngt"]', ['bbw4ngt'], 's'], ['regression ["hgvs8gmf0"]', ['hgvs8gmf0'], 'j'], ['partial-repair ["s8zc"]', ['s8zc'], '5'], ['partial-repair ["i3wknpx64b"]', ['i3wknpx64b'], 'a'], ['control ["z"]', ['z'], '1'], ['control ["zz"]', ['zz'], '2'], ['control ["abc-1"]', ['abc-1'], None], ['control [""]', [''], None]], [['regression ["um"]', ['um'], 'x'], ['regression ["w35lg7vo1l"]', ['w35lg7vo1l'], 'c'], ['partial-repair ["a5qsqld2"]', ['a5qsqld2'], 'r'], ['partial-repair ["60an"]', ['60an'], '9'], ['control ["ZZZZZZ"]', ['ZZZZZZ'], '6'], ['control ["0rr"]', ['0rr'], 'q'], ['control ["z"]', ['z'], '1'], ['control ["zz"]', ['zz'], '2']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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:
Generated check characters fail validation.

Luhn mod N check-character generation over the base-36 alphabet 0-9a-z (input is lower-cased; empty input or any other character returns None). From the rightmost payload character the factor alternates 2,1,2,...; each addend factor * codepoint is folded as addend // 36 + addend % 36; the check is the alphabet character at (36 - sum % 36) % 36.

split: open-access


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

N = 1
observations = []
def solve(s):
    if len(s) != 11 or not s.isascii() or not s[:3].isalpha() or not s[:3].isupper():
        return 'malformed'
    if s[3] not in 'UJZ' or not s[4:].isdigit():
        return 'malformed'
    vals = {}
    v = 10
    for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
        vals[ch] = v
        v += 1
    total = 0
    for i, ch in enumerate(s[:10]):
        total += (vals[ch] if ch.isalpha() else int(ch)) * 2 ** i
    check = total % 11 % 10
    return [check, check == int(s[10])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['regression ["BYYJ6917585"]', ['BYYJ6917585'], [8, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['control ["YQEU5793145"]', ['YQEU5793145'], [6, False]]], [['regression ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['regression ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['partial-repair ["YQEU5793145"]', ['YQEU5793145'], [6, False]], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["OQHU9278051"]', ['OQHU9278051'], [8, False]]], [['regression ["CYVU1050697"]', ['CYVU1050697'], [7, True]], ['regression ["FLAU0380833"]', ['FLAU0380833'], [7, False]], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["LBRU3332332"]', ['LBRU3332332'], [4, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]]], [['regression ["TRVJ4468592"]', ['TRVJ4468592'], [8, False]], ['regression ["LGSU0173454"]', ['LGSU0173454'], [8, False]], ['partial-repair ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['partial-repair ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed']], [['regression ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['regression ["LBRU3332332"]', ['LBRU3332332'], [4, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['partial-repair ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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(s):
    if len(s) != 11 or not s.isascii() or not s[:3].isalpha() or not s[:3].isupper():
        return 'malformed'
    if s[3] not in 'UJZ' or not s[4:].isdigit():
        return 'malformed'
    vals = {}
    v = 10
    for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
        if v == 11:
            v += 1
        vals[ch] = v
        v += 1
    total = 0
    for i, ch in enumerate(s[:10]):
        total += (vals[ch] if ch.isalpha() else int(ch)) * 2 ** i
    check = total % 11 % 10
    return [check, check == int(s[10])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['regression ["BYYJ6917585"]', ['BYYJ6917585'], [8, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['control ["YQEU5793145"]', ['YQEU5793145'], [6, False]]], [['regression ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['regression ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['partial-repair ["YQEU5793145"]', ['YQEU5793145'], [6, False]], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["OQHU9278051"]', ['OQHU9278051'], [8, False]]], [['regression ["CYVU1050697"]', ['CYVU1050697'], [7, True]], ['regression ["FLAU0380833"]', ['FLAU0380833'], [7, False]], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["LBRU3332332"]', ['LBRU3332332'], [4, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]]], [['regression ["TRVJ4468592"]', ['TRVJ4468592'], [8, False]], ['regression ["LGSU0173454"]', ['LGSU0173454'], [8, False]], ['partial-repair ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['partial-repair ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed']], [['regression ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['regression ["LBRU3332332"]', ['LBRU3332332'], [4, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['partial-repair ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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:
Container numbers with owner letters B or later get the wrong check digit.

Shipping container identification check digit: three uppercase owner letters, category U, J or Z, six serial digits and a check digit (else "malformed"). Letter values start at A=10 and skip every multiple of 11 (so B=12, L=23, V=34, Z=38). Position i (0-based) has weight 2^i; the check digit is (sum mod 11) mod 10. Return [check, match].

split: open-access


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

N = 1
observations = []
def solve(s):
    if len(s) != 11 or not s.isascii() or not s[:3].isalpha() or not s[:3].isupper():
        return 'malformed'
    if s[3] not in 'UJZ' or not s[4:].isdigit():
        return 'malformed'
    vals = {}
    v = 10
    for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
        if v % 11 == 0:
            v += 1
        vals[ch] = v
        v += 1
    total = 0
    for i, ch in enumerate(s[:10]):
        total += (vals[ch] if ch.isalpha() else int(ch)) * 2 ** (i + 1)
    check = total % 11 % 10
    return [check, check == int(s[10])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['regression ["BYYJ6917585"]', ['BYYJ6917585'], [8, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["YQEU5793145"]', ['YQEU5793145'], [6, False]]], [['regression ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['regression ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['partial-repair ["YQEU5793145"]', ['YQEU5793145'], [6, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']], [['regression ["CTZU8384457"]', ['CTZU8384457'], [2, False]], ['regression ["CYVU1050697"]', ['CYVU1050697'], [7, True]], ['partial-repair ["FLAU0380833"]', ['FLAU0380833'], [7, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']], [['regression ["OQHU9278051"]', ['OQHU9278051'], [8, False]], ['regression ["TRVJ4468592"]', ['TRVJ4468592'], [8, False]], ['partial-repair ["LGSU0173454"]', ['LGSU0173454'], [8, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']], [['regression ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['regression ["LBRU3332332"]', ['LBRU3332332'], [4, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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(s):
    if len(s) != 11 or not s.isascii() or not s[:3].isalpha() or not s[:3].isupper():
        return 'malformed'
    if s[3] not in 'UJZ' or not s[4:].isdigit():
        return 'malformed'
    vals = {}
    v = 10
    for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
        if v % 11 == 0:
            v += 1
        vals[ch] = v
        v += 1
    total = 0
    for i, ch in enumerate(s[:10]):
        total += (vals[ch] if ch.isalpha() else int(ch)) * 2 ** (9 - i)
    check = total % 11 % 10
    return [check, check == int(s[10])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['regression ["BYYJ6917585"]', ['BYYJ6917585'], [8, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["YQEU5793145"]', ['YQEU5793145'], [6, False]]], [['regression ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['regression ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['partial-repair ["YQEU5793145"]', ['YQEU5793145'], [6, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']], [['regression ["CTZU8384457"]', ['CTZU8384457'], [2, False]], ['regression ["CYVU1050697"]', ['CYVU1050697'], [7, True]], ['partial-repair ["FLAU0380833"]', ['FLAU0380833'], [7, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']], [['regression ["OQHU9278051"]', ['OQHU9278051'], [8, False]], ['regression ["TRVJ4468592"]', ['TRVJ4468592'], [8, False]], ['partial-repair ["LGSU0173454"]', ['LGSU0173454'], [8, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']], [['regression ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['regression ["LBRU3332332"]', ['LBRU3332332'], [4, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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:
Every container number fails its check.

Shipping container identification check digit: three uppercase owner letters, category U, J or Z, six serial digits and a check digit (else "malformed"). Letter values start at A=10 and skip every multiple of 11 (so B=12, L=23, V=34, Z=38). Position i (0-based) has weight 2^i; the check digit is (sum mod 11) mod 10. Return [check, match].

split: open-access


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

N = 1
observations = []
def solve(s):
    if len(s) != 11 or not s.isascii() or not s[:3].isalpha() or not s[:3].isupper():
        return 'malformed'
    if s[3] not in 'UJZ' or not s[4:].isdigit():
        return 'malformed'
    vals = {}
    v = 10
    for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
        if v % 11 == 0:
            v += 1
        vals[ch] = v
        v += 1
    total = 0
    for i, ch in enumerate(s[:10]):
        total += (vals[ch] if ch.isalpha() else int(ch)) * 2 ** i
    check = total % 11
    return [check, check == int(s[10])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['partial-repair ["BYYJ6917585"]', ['BYYJ6917585'], [8, False]], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed']], [['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['partial-repair ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed']], [['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["CTZU8384457"]', ['CTZU8384457'], [2, False]], ['partial-repair ["CYVU1050697"]', ['CYVU1050697'], [7, True]], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed']], [['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["OQHU9278051"]', ['OQHU9278051'], [8, False]], ['partial-repair ["TRVJ4468592"]', ['TRVJ4468592'], [8, False]], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]]], [['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['partial-repair ["LBRU3332332"]', ['LBRU3332332'], [4, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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(s):
    if len(s) != 11 or not s.isascii() or not s[:3].isalpha() or not s[:3].isupper():
        return 'malformed'
    if s[3] not in 'UJZ' or not s[4:].isdigit():
        return 'malformed'
    vals = {}
    v = 10
    for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
        if v % 11 == 0:
            v += 1
        vals[ch] = v
        v += 1
    total = 0
    for i, ch in enumerate(s[:10]):
        total += (vals[ch] if ch.isalpha() else int(ch)) * 2 ** i
    check = total % 10
    return [check, check == int(s[10])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['partial-repair ["BYYJ6917585"]', ['BYYJ6917585'], [8, False]], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed']], [['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['partial-repair ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed']], [['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["CTZU8384457"]', ['CTZU8384457'], [2, False]], ['partial-repair ["CYVU1050697"]', ['CYVU1050697'], [7, True]], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed']], [['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["OQHU9278051"]', ['OQHU9278051'], [8, False]], ['partial-repair ["TRVJ4468592"]', ['TRVJ4468592'], [8, False]], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]], ['control ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]]], [['regression ["TTNJ3916757"]', ['TTNJ3916757'], [0, False]], ['partial-repair ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['partial-repair ["LBRU3332332"]', ['LBRU3332332'], [4, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed'], ['control ["C1QU3054383"]', ['C1QU3054383'], 'malformed'], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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:
Containers whose sum leaves remainder 10 never validate.

Shipping container identification check digit: three uppercase owner letters, category U, J or Z, six serial digits and a check digit (else "malformed"). Letter values start at A=10 and skip every multiple of 11 (so B=12, L=23, V=34, Z=38). Position i (0-based) has weight 2^i; the check digit is (sum mod 11) mod 10. Return [check, match].

split: open-access


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

N = 1
observations = []
def solve(s):
    if len(s) != 11 or not s.isascii() or not s[:3].isalpha() or not s[:3].isupper():
        return 'malformed'
    if s[3] != 'U' or not s[4:].isdigit():
        return 'malformed'
    vals = {}
    v = 10
    for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
        if v % 11 == 0:
            v += 1
        vals[ch] = v
        v += 1
    total = 0
    for i, ch in enumerate(s[:10]):
        total += (vals[ch] if ch.isalpha() else int(ch)) * 2 ** i
    check = total % 11 % 10
    return [check, check == int(s[10])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["BYYJ6917585"]', ['BYYJ6917585'], [8, False]], ['regression ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['partial-repair ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['control ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['control ["VGQU8532227"]', ['VGQU8532227'], [2, False]], ['control ["YQEU5793145"]', ['YQEU5793145'], [6, False]], ['control ["CTZU8384457"]', ['CTZU8384457'], [2, False]]], [['regression ["TRVJ4468592"]', ['TRVJ4468592'], [8, False]], ['regression ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['partial-repair ["ABCZ0000000"]', ['ABCZ0000000'], [5, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["FLAU0380833"]', ['FLAU0380833'], [7, False]], ['control ["OQHU9278051"]', ['OQHU9278051'], [8, False]], ['control ["LGSU0173454"]', ['LGSU0173454'], [8, False]], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]]], [['regression ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['regression ["NACZ1755331"]', ['NACZ1755331'], [0, False]], ['partial-repair ["ABCZ0000000"]', ['ABCZ0000000'], [5, False]], ['control ["MJWU6668315"]', ['MJWU6668315'], [4, False]], ['control ["NPNU9965846"]', ['NPNU9965846'], [3, False]], ['control ["CCQU2344092"]', ['CCQU2344092'], [4, False]], ['control ["CSQU3054383"]', ['CSQU3054383'], [3, True]], ['control ["MSKU9070323"]', ['MSKU9070323'], [3, True]]], [['regression ["ABCZ0000000"]', ['ABCZ0000000'], [5, False]], ['regression ["XYZJ9999999"]', ['XYZJ9999999'], [1, False]], ['partial-repair ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['partial-repair ["NACZ1755331"]', ['NACZ1755331'], [0, False]], ['control ["TCLU1234560"]', ['TCLU1234560'], [8, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed']], [['regression ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['regression ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['partial-repair ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['control ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['control ["VGQU8532227"]', ['VGQU8532227'], [2, False]], ['control ["YQEU5793145"]', ['YQEU5793145'], [6, False]], ['control ["CTZU8384457"]', ['CTZU8384457'], [2, False]]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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(s):
    if len(s) != 11 or not s.isascii() or not s[:3].isalpha() or not s[:3].isupper():
        return 'malformed'
    if s[3] not in 'UJ' or not s[4:].isdigit():
        return 'malformed'
    vals = {}
    v = 10
    for ch in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
        if v % 11 == 0:
            v += 1
        vals[ch] = v
        v += 1
    total = 0
    for i, ch in enumerate(s[:10]):
        total += (vals[ch] if ch.isalpha() else int(ch)) * 2 ** i
    check = total % 11 % 10
    return [check, check == int(s[10])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["BYYJ6917585"]', ['BYYJ6917585'], [8, False]], ['regression ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['partial-repair ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['control ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['control ["VGQU8532227"]', ['VGQU8532227'], [2, False]], ['control ["YQEU5793145"]', ['YQEU5793145'], [6, False]], ['control ["CTZU8384457"]', ['CTZU8384457'], [2, False]]], [['regression ["TRVJ4468592"]', ['TRVJ4468592'], [8, False]], ['regression ["VQAJ3159690"]', ['VQAJ3159690'], [0, True]], ['partial-repair ["ABCZ0000000"]', ['ABCZ0000000'], [5, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['control ["FLAU0380833"]', ['FLAU0380833'], [7, False]], ['control ["OQHU9278051"]', ['OQHU9278051'], [8, False]], ['control ["LGSU0173454"]', ['LGSU0173454'], [8, False]], ['control ["RGOU0215685"]', ['RGOU0215685'], [3, False]]], [['regression ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['regression ["NACZ1755331"]', ['NACZ1755331'], [0, False]], ['partial-repair ["ABCZ0000000"]', ['ABCZ0000000'], [5, False]], ['control ["MJWU6668315"]', ['MJWU6668315'], [4, False]], ['control ["NPNU9965846"]', ['NPNU9965846'], [3, False]], ['control ["CCQU2344092"]', ['CCQU2344092'], [4, False]], ['control ["CSQU3054383"]', ['CSQU3054383'], [3, True]], ['control ["MSKU9070323"]', ['MSKU9070323'], [3, True]]], [['regression ["ABCZ0000000"]', ['ABCZ0000000'], [5, False]], ['regression ["XYZJ9999999"]', ['XYZJ9999999'], [1, False]], ['partial-repair ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['partial-repair ["NACZ1755331"]', ['NACZ1755331'], [0, False]], ['control ["TCLU1234560"]', ['TCLU1234560'], [8, False]], ['control ["CSQU305438"]', ['CSQU305438'], 'malformed'], ['control ["CSQX3054383"]', ['CSQX3054383'], 'malformed'], ['control ["csqu3054383"]', ['csqu3054383'], 'malformed']], [['regression ["MUHJ6260452"]', ['MUHJ6260452'], [4, False]], ['regression ["GEDJ3497886"]', ['GEDJ3497886'], [3, False]], ['partial-repair ["TSAZ4635083"]', ['TSAZ4635083'], [9, False]], ['partial-repair ["QSJZ1716340"]', ['QSJZ1716340'], [4, False]], ['control ["HRNU7843702"]', ['HRNU7843702'], [9, False]], ['control ["VGQU8532227"]', ['VGQU8532227'], [2, False]], ['control ["YQEU5793145"]', ['YQEU5793145'], [6, False]], ['control ["CTZU8384457"]', ['CTZU8384457'], [2, False]]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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:
Detachable-equipment (J) and trailer (Z) identifiers are rejected.

Shipping container identification check digit: three uppercase owner letters, category U, J or Z, six serial digits and a check digit (else "malformed"). Letter values start at A=10 and skip every multiple of 11 (so B=12, L=23, V=34, Z=38). Position i (0-based) has weight 2^i; the check digit is (sum mod 11) mod 10. Return [check, match].

split: open-access


prompt:
Numbers whose first check digit should be 0 are rejected.

Brazilian CPF taxpayer number: dots and hyphens removed, then 11 ASCII digits that are not all the same digit (else "malformed"). k1 = (sum of digits 1-9 weighted 10..2) * 10 mod 11 mod 10; k2 = (digits 1-9 and the computed k1 weighted 11..2) * 10 mod 11 mod 10. Return [k1, k2, whether digits 10-11 equal them].

split: open-access


prompt:
Placeholder numbers such as 111.111.111-11 pass both check digits.

Brazilian CPF taxpayer number: dots and hyphens removed, then 11 ASCII digits that are not all the same digit (else "malformed"). k1 = (sum of digits 1-9 weighted 10..2) * 10 mod 11 mod 10; k2 = (digits 1-9 and the computed k1 weighted 11..2) * 10 mod 11 mod 10. Return [k1, k2, whether digits 10-11 equal them].

split: open-access


prompt:
Most valid CPFs fail the second check digit.

Brazilian CPF taxpayer number: dots and hyphens removed, then 11 ASCII digits that are not all the same digit (else "malformed"). k1 = (sum of digits 1-9 weighted 10..2) * 10 mod 11 mod 10; k2 = (digits 1-9 and the computed k1 weighted 11..2) * 10 mod 11 mod 10. Return [k1, k2, whether digits 10-11 equal them].

split: open-access


prompt:
Cards issued at the top of the 2-series BIN range are reported as unknown.

Card number screening: spaces removed, nonempty ASCII digits required (else "malformed"). Network by prefix and length: visa 4 with 13/16/19 digits; amex 34 or 37 with 15; mastercard 51-55 or 2221-2720 with 16; discover 6011, 644-649 or 65 with 16-19; otherwise "unknown". Return [network, Luhn validity].

split: open-access


prompt:
Diners-style 35 and 36 prefixes with 15 digits are routed to amex.

Card number screening: spaces removed, nonempty ASCII digits required (else "malformed"). Network by prefix and length: visa 4 with 13/16/19 digits; amex 34 or 37 with 15; mastercard 51-55 or 2221-2720 with 16; discover 6011, 644-649 or 65 with 16-19; otherwise "unknown". Return [network, Luhn validity].

split: open-access


prompt:
Cards with prefixes 640-643 are routed to discover.

Card number screening: spaces removed, nonempty ASCII digits required (else "malformed"). Network by prefix and length: visa 4 with 13/16/19 digits; amex 34 or 37 with 15; mastercard 51-55 or 2221-2720 with 16; discover 6011, 644-649 or 65 with 16-19; otherwise "unknown". Return [network, Luhn validity].

split: open-access


prompt:
Long-format Visa cards are reported as unknown.

Card number screening: spaces removed, nonempty ASCII digits required (else "malformed"). Network by prefix and length: visa 4 with 13/16/19 digits; amex 34 or 37 with 15; mastercard 51-55 or 2221-2720 with 16; discover 6011, 644-649 or 65 with 16-19; otherwise "unknown". Return [network, Luhn validity].

split: open-access


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

N = 1
observations = []
def solve(prefix):
    t = prefix.upper()
    if len(t) != 18 or not t.isascii() or not t.isalnum():
        return None
    n = int(''.join(str(int(ch, 36)) for ch in t + '00'))
    return t + str(98 - n % 97)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['control ["NH4O4Q9HMI8RUJ0D6Y"]', ['NH4O4Q9HMI8RUJ0D6Y'], 'NH4O4Q9HMI8RUJ0D6Y73'], ['control ["9K6IWOG7TS4VC3SHAM"]', ['9K6IWOG7TS4VC3SHAM'], '9K6IWOG7TS4VC3SHAM78'], ['control ["HTJBP9O1O9QSYUUD3R"]', ['HTJBP9O1O9QSYUUD3R'], 'HTJBP9O1O9QSYUUD3R38'], ['control ["ACLPCCV3EGBW4QG3I6"]', ['ACLPCCV3EGBW4QG3I6'], 'ACLPCCV3EGBW4QG3I685'], ['control ["II5XCIYZ03SDPPSQ7Z"]', ['II5XCIYZ03SDPPSQ7Z'], 'II5XCIYZ03SDPPSQ7Z30'], ['control ["H6UNZ3Z93AZ7BYYPJC"]', ['H6UNZ3Z93AZ7BYYPJC'], 'H6UNZ3Z93AZ7BYYPJC84']], [['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['control ["H6UNZ3Z93AZ7BYYPJC"]', ['H6UNZ3Z93AZ7BYYPJC'], 'H6UNZ3Z93AZ7BYYPJC84'], ['control ["2G388X3WHEMWPIB3DO"]', ['2G388X3WHEMWPIB3DO'], '2G388X3WHEMWPIB3DO38'], ['control ["WYITG3CIA2EMN51FG8"]', ['WYITG3CIA2EMN51FG8'], 'WYITG3CIA2EMN51FG854'], ['control ["X22YG0E1MY8V7QUQUU"]', ['X22YG0E1MY8V7QUQUU'], 'X22YG0E1MY8V7QUQUU47'], ['control ["3KL2WVMON87A9JVRD8"]', ['3KL2WVMON87A9JVRD8'], '3KL2WVMON87A9JVRD876'], ['control ["U6G55SH046WQ164I4P"]', ['U6G55SH046WQ164I4P'], 'U6G55SH046WQ164I4P20']], [['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['control ["U6G55SH046WQ164I4P"]', ['U6G55SH046WQ164I4P'], 'U6G55SH046WQ164I4P20'], ['control ["2Y76WQMSKZ26SJ35YB"]', ['2Y76WQMSKZ26SJ35YB'], '2Y76WQMSKZ26SJ35YB12'], ['control ["CU3JXPUYQHVR22PKEM"]', ['CU3JXPUYQHVR22PKEM'], 'CU3JXPUYQHVR22PKEM49'], ['control ["EPXGBGA2NLNHRPYT3N"]', ['EPXGBGA2NLNHRPYT3N'], 'EPXGBGA2NLNHRPYT3N83'], ['control ["BQGZ110JXMYQ68HH60"]', ['BQGZ110JXMYQ68HH60'], 'BQGZ110JXMYQ68HH6058'], ['control ["V6E7H467R3XXTF0UX2"]', ['V6E7H467R3XXTF0UX2'], 'V6E7H467R3XXTF0UX240']], [['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['control ["V6E7H467R3XXTF0UX2"]', ['V6E7H467R3XXTF0UX2'], 'V6E7H467R3XXTF0UX240'], ['control ["11H96GYM52SNV78B6G"]', ['11H96GYM52SNV78B6G'], '11H96GYM52SNV78B6G12'], ['control ["8WZS9XRTCO6DTNCKMU"]', ['8WZS9XRTCO6DTNCKMU'], '8WZS9XRTCO6DTNCKMU93'], ['control ["QBZJYTHC8GNQSKDJSD"]', ['QBZJYTHC8GNQSKDJSD'], 'QBZJYTHC8GNQSKDJSD15'], ['control ["PDZ2BB459ICKWDCEN4"]', ['PDZ2BB459ICKWDCEN4'], 'PDZ2BB459ICKWDCEN446'], ['control ["EMP8BUVSBRJMR8P6P0"]', ['EMP8BUVSBRJMR8P6P0'], 'EMP8BUVSBRJMR8P6P049']], [['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['control ["EMP8BUVSBRJMR8P6P0"]', ['EMP8BUVSBRJMR8P6P0'], 'EMP8BUVSBRJMR8P6P049'], ['control ["JA1SCUCU57DVVWD2MF"]', ['JA1SCUCU57DVVWD2MF'], 'JA1SCUCU57DVVWD2MF33'], ['control ["FUNIAT1L7171F0KBF9"]', ['FUNIAT1L7171F0KBF9'], 'FUNIAT1L7171F0KBF963'], ['control ["Z62YQ0YUTHLSESKG4A"]', ['Z62YQ0YUTHLSESKG4A'], 'Z62YQ0YUTHLSESKG4A79'], ['control ["5493001KJTIIGC8Y1R"]', ['5493001KJTIIGC8Y1R'], '5493001KJTIIGC8Y1R12'], ['control ["5493001kjtiigc8y1r"]', ['5493001kjtiigc8y1r'], '5493001KJTIIGC8Y1R12']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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(prefix):
    t = prefix.upper()
    if len(t) != 18 or not t.isascii() or not t.isalnum():
        return None
    n = int(''.join(str(int(ch, 36)) for ch in t + '00'))
    return t + '%2d' % (98 - n % 97)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['control ["NH4O4Q9HMI8RUJ0D6Y"]', ['NH4O4Q9HMI8RUJ0D6Y'], 'NH4O4Q9HMI8RUJ0D6Y73'], ['control ["9K6IWOG7TS4VC3SHAM"]', ['9K6IWOG7TS4VC3SHAM'], '9K6IWOG7TS4VC3SHAM78'], ['control ["HTJBP9O1O9QSYUUD3R"]', ['HTJBP9O1O9QSYUUD3R'], 'HTJBP9O1O9QSYUUD3R38'], ['control ["ACLPCCV3EGBW4QG3I6"]', ['ACLPCCV3EGBW4QG3I6'], 'ACLPCCV3EGBW4QG3I685'], ['control ["II5XCIYZ03SDPPSQ7Z"]', ['II5XCIYZ03SDPPSQ7Z'], 'II5XCIYZ03SDPPSQ7Z30'], ['control ["H6UNZ3Z93AZ7BYYPJC"]', ['H6UNZ3Z93AZ7BYYPJC'], 'H6UNZ3Z93AZ7BYYPJC84']], [['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['control ["H6UNZ3Z93AZ7BYYPJC"]', ['H6UNZ3Z93AZ7BYYPJC'], 'H6UNZ3Z93AZ7BYYPJC84'], ['control ["2G388X3WHEMWPIB3DO"]', ['2G388X3WHEMWPIB3DO'], '2G388X3WHEMWPIB3DO38'], ['control ["WYITG3CIA2EMN51FG8"]', ['WYITG3CIA2EMN51FG8'], 'WYITG3CIA2EMN51FG854'], ['control ["X22YG0E1MY8V7QUQUU"]', ['X22YG0E1MY8V7QUQUU'], 'X22YG0E1MY8V7QUQUU47'], ['control ["3KL2WVMON87A9JVRD8"]', ['3KL2WVMON87A9JVRD8'], '3KL2WVMON87A9JVRD876'], ['control ["U6G55SH046WQ164I4P"]', ['U6G55SH046WQ164I4P'], 'U6G55SH046WQ164I4P20']], [['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['control ["U6G55SH046WQ164I4P"]', ['U6G55SH046WQ164I4P'], 'U6G55SH046WQ164I4P20'], ['control ["2Y76WQMSKZ26SJ35YB"]', ['2Y76WQMSKZ26SJ35YB'], '2Y76WQMSKZ26SJ35YB12'], ['control ["CU3JXPUYQHVR22PKEM"]', ['CU3JXPUYQHVR22PKEM'], 'CU3JXPUYQHVR22PKEM49'], ['control ["EPXGBGA2NLNHRPYT3N"]', ['EPXGBGA2NLNHRPYT3N'], 'EPXGBGA2NLNHRPYT3N83'], ['control ["BQGZ110JXMYQ68HH60"]', ['BQGZ110JXMYQ68HH60'], 'BQGZ110JXMYQ68HH6058'], ['control ["V6E7H467R3XXTF0UX2"]', ['V6E7H467R3XXTF0UX2'], 'V6E7H467R3XXTF0UX240']], [['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['control ["V6E7H467R3XXTF0UX2"]', ['V6E7H467R3XXTF0UX2'], 'V6E7H467R3XXTF0UX240'], ['control ["11H96GYM52SNV78B6G"]', ['11H96GYM52SNV78B6G'], '11H96GYM52SNV78B6G12'], ['control ["8WZS9XRTCO6DTNCKMU"]', ['8WZS9XRTCO6DTNCKMU'], '8WZS9XRTCO6DTNCKMU93'], ['control ["QBZJYTHC8GNQSKDJSD"]', ['QBZJYTHC8GNQSKDJSD'], 'QBZJYTHC8GNQSKDJSD15'], ['control ["PDZ2BB459ICKWDCEN4"]', ['PDZ2BB459ICKWDCEN4'], 'PDZ2BB459ICKWDCEN446'], ['control ["EMP8BUVSBRJMR8P6P0"]', ['EMP8BUVSBRJMR8P6P0'], 'EMP8BUVSBRJMR8P6P049']], [['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['regression ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502'], ['control ["EMP8BUVSBRJMR8P6P0"]', ['EMP8BUVSBRJMR8P6P0'], 'EMP8BUVSBRJMR8P6P049'], ['control ["JA1SCUCU57DVVWD2MF"]', ['JA1SCUCU57DVVWD2MF'], 'JA1SCUCU57DVVWD2MF33'], ['control ["FUNIAT1L7171F0KBF9"]', ['FUNIAT1L7171F0KBF9'], 'FUNIAT1L7171F0KBF963'], ['control ["Z62YQ0YUTHLSESKG4A"]', ['Z62YQ0YUTHLSESKG4A'], 'Z62YQ0YUTHLSESKG4A79'], ['control ["5493001KJTIIGC8Y1R"]', ['5493001KJTIIGC8Y1R'], '5493001KJTIIGC8Y1R12'], ['control ["5493001kjtiigc8y1r"]', ['5493001kjtiigc8y1r'], '5493001KJTIIGC8Y1R12']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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:
Check values below 10 produce a 19-character LEI.

Generate ISO 17442 LEI check digits (ISO 7064 MOD 97-10): the 18-character alphanumeric prefix is upper-cased (other input returns None), "00" is appended, letters become 10..35, and the check is 98 - (number mod 97) written as exactly two digits. Return the 20-character LEI.

split: open-access


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

N = 1
observations = []
def solve(prefix):
    t = prefix.upper()
    if len(t) != 18 or not t.isascii() or not t.isalnum():
        return None
    n = int(''.join(str(int(ch, 36)) for ch in t))
    return t + '%02d' % (98 - n % 97)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["NH4O4Q9HMI8RUJ0D6Y"]', ['NH4O4Q9HMI8RUJ0D6Y'], 'NH4O4Q9HMI8RUJ0D6Y73'], ['regression ["9K6IWOG7TS4VC3SHAM"]', ['9K6IWOG7TS4VC3SHAM'], '9K6IWOG7TS4VC3SHAM78'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['control ["ACLPCCV3EGBW4QG3I6"]', ['ACLPCCV3EGBW4QG3I6'], 'ACLPCCV3EGBW4QG3I685'], ['control ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502']], [['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['regression ["ACLPCCV3EGBW4QG3I6"]', ['ACLPCCV3EGBW4QG3I6'], 'ACLPCCV3EGBW4QG3I685'], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["2G388X3WHEMWPIB3DO"]', ['2G388X3WHEMWPIB3DO'], '2G388X3WHEMWPIB3DO38'], ['control ["WYITG3CIA2EMN51FG8"]', ['WYITG3CIA2EMN51FG8'], 'WYITG3CIA2EMN51FG854'], ['control ["X22YG0E1MY8V7QUQUU"]', ['X22YG0E1MY8V7QUQUU'], 'X22YG0E1MY8V7QUQUU47']], [['regression ["II5XCIYZ03SDPPSQ7Z"]', ['II5XCIYZ03SDPPSQ7Z'], 'II5XCIYZ03SDPPSQ7Z30'], ['regression ["H6UNZ3Z93AZ7BYYPJC"]', ['H6UNZ3Z93AZ7BYYPJC'], 'H6UNZ3Z93AZ7BYYPJC84'], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["2Y76WQMSKZ26SJ35YB"]', ['2Y76WQMSKZ26SJ35YB'], '2Y76WQMSKZ26SJ35YB12'], ['control ["CU3JXPUYQHVR22PKEM"]', ['CU3JXPUYQHVR22PKEM'], 'CU3JXPUYQHVR22PKEM49'], ['control ["EPXGBGA2NLNHRPYT3N"]', ['EPXGBGA2NLNHRPYT3N'], 'EPXGBGA2NLNHRPYT3N83']], [['regression ["WYITG3CIA2EMN51FG8"]', ['WYITG3CIA2EMN51FG8'], 'WYITG3CIA2EMN51FG854'], ['regression ["X22YG0E1MY8V7QUQUU"]', ['X22YG0E1MY8V7QUQUU'], 'X22YG0E1MY8V7QUQUU47'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["11H96GYM52SNV78B6G"]', ['11H96GYM52SNV78B6G'], '11H96GYM52SNV78B6G12'], ['control ["8WZS9XRTCO6DTNCKMU"]', ['8WZS9XRTCO6DTNCKMU'], '8WZS9XRTCO6DTNCKMU93'], ['control ["QBZJYTHC8GNQSKDJSD"]', ['QBZJYTHC8GNQSKDJSD'], 'QBZJYTHC8GNQSKDJSD15']], [['regression ["U6G55SH046WQ164I4P"]', ['U6G55SH046WQ164I4P'], 'U6G55SH046WQ164I4P20'], ['regression ["2Y76WQMSKZ26SJ35YB"]', ['2Y76WQMSKZ26SJ35YB'], '2Y76WQMSKZ26SJ35YB12'], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["JA1SCUCU57DVVWD2MF"]', ['JA1SCUCU57DVVWD2MF'], 'JA1SCUCU57DVVWD2MF33'], ['control ["FUNIAT1L7171F0KBF9"]', ['FUNIAT1L7171F0KBF9'], 'FUNIAT1L7171F0KBF963'], ['control ["Z62YQ0YUTHLSESKG4A"]', ['Z62YQ0YUTHLSESKG4A'], 'Z62YQ0YUTHLSESKG4A79']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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(prefix):
    t = prefix.upper()
    if len(t) != 18 or not t.isascii() or not t.isalnum():
        return None
    n = int(''.join(str(int(ch, 36)) for ch in t + '0'))
    return t + '%02d' % (98 - n % 97)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["NH4O4Q9HMI8RUJ0D6Y"]', ['NH4O4Q9HMI8RUJ0D6Y'], 'NH4O4Q9HMI8RUJ0D6Y73'], ['regression ["9K6IWOG7TS4VC3SHAM"]', ['9K6IWOG7TS4VC3SHAM'], '9K6IWOG7TS4VC3SHAM78'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['control ["ACLPCCV3EGBW4QG3I6"]', ['ACLPCCV3EGBW4QG3I6'], 'ACLPCCV3EGBW4QG3I685'], ['control ["64WI551TBNLAZEBU15"]', ['64WI551TBNLAZEBU15'], '64WI551TBNLAZEBU1502']], [['regression ["TD7FDXWKLVRV07ALBK"]', ['TD7FDXWKLVRV07ALBK'], 'TD7FDXWKLVRV07ALBK05'], ['regression ["ACLPCCV3EGBW4QG3I6"]', ['ACLPCCV3EGBW4QG3I6'], 'ACLPCCV3EGBW4QG3I685'], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["2G388X3WHEMWPIB3DO"]', ['2G388X3WHEMWPIB3DO'], '2G388X3WHEMWPIB3DO38'], ['control ["WYITG3CIA2EMN51FG8"]', ['WYITG3CIA2EMN51FG8'], 'WYITG3CIA2EMN51FG854'], ['control ["X22YG0E1MY8V7QUQUU"]', ['X22YG0E1MY8V7QUQUU'], 'X22YG0E1MY8V7QUQUU47']], [['regression ["II5XCIYZ03SDPPSQ7Z"]', ['II5XCIYZ03SDPPSQ7Z'], 'II5XCIYZ03SDPPSQ7Z30'], ['regression ["H6UNZ3Z93AZ7BYYPJC"]', ['H6UNZ3Z93AZ7BYYPJC'], 'H6UNZ3Z93AZ7BYYPJC84'], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["2Y76WQMSKZ26SJ35YB"]', ['2Y76WQMSKZ26SJ35YB'], '2Y76WQMSKZ26SJ35YB12'], ['control ["CU3JXPUYQHVR22PKEM"]', ['CU3JXPUYQHVR22PKEM'], 'CU3JXPUYQHVR22PKEM49'], ['control ["EPXGBGA2NLNHRPYT3N"]', ['EPXGBGA2NLNHRPYT3N'], 'EPXGBGA2NLNHRPYT3N83']], [['regression ["WYITG3CIA2EMN51FG8"]', ['WYITG3CIA2EMN51FG8'], 'WYITG3CIA2EMN51FG854'], ['regression ["X22YG0E1MY8V7QUQUU"]', ['X22YG0E1MY8V7QUQUU'], 'X22YG0E1MY8V7QUQUU47'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["11H96GYM52SNV78B6G"]', ['11H96GYM52SNV78B6G'], '11H96GYM52SNV78B6G12'], ['control ["8WZS9XRTCO6DTNCKMU"]', ['8WZS9XRTCO6DTNCKMU'], '8WZS9XRTCO6DTNCKMU93'], ['control ["QBZJYTHC8GNQSKDJSD"]', ['QBZJYTHC8GNQSKDJSD'], 'QBZJYTHC8GNQSKDJSD15']], [['regression ["U6G55SH046WQ164I4P"]', ['U6G55SH046WQ164I4P'], 'U6G55SH046WQ164I4P20'], ['regression ["2Y76WQMSKZ26SJ35YB"]', ['2Y76WQMSKZ26SJ35YB'], '2Y76WQMSKZ26SJ35YB12'], ['control ["000000000000000000"]', ['000000000000000000'], '00000000000000000098'], ['control ["5493001KJTIIGC8Y1"]', ['5493001KJTIIGC8Y1'], None], ['control ["5493001KJTIIGC8Y1R-"]', ['5493001KJTIIGC8Y1R-'], None], ['control ["JA1SCUCU57DVVWD2MF"]', ['JA1SCUCU57DVVWD2MF'], 'JA1SCUCU57DVVWD2MF33'], ['control ["FUNIAT1L7171F0KBF9"]', ['FUNIAT1L7171F0KBF9'], 'FUNIAT1L7171F0KBF963'], ['control ["Z62YQ0YUTHLSESKG4A"]', ['Z62YQ0YUTHLSESKG4A'], 'Z62YQ0YUTHLSESKG4A79']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*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:
Nearly every generated LEI fails validation.

Generate ISO 17442 LEI check digits (ISO 7064 MOD 97-10): the 18-character alphanumeric prefix is upper-cased (other input returns None), "00" is appended, letters become 10..35, and the check is 98 - (number mod 97) written as exactly two digits. Return the 20-character LEI.

split: open-access


prompt:
Identifiers issued from 2000 onwards (T, G) get the wrong check letter.

Singapore-style NRIC/FIN check letter for the S, T, F and G series: nine characters, series letter, seven digits, check letter (else "malformed"). Weights 2,7,6,5,4,3,2; add 4 for T and G; r = sum mod 11; the letter is "JZIHGFEDCBA"[r] for S/T and "XWUTRQPNMLK"[r] for F/G. Return [expected letter, match].

split: open-access


prompt:
Either citizen or foreigner numbers get check letters from the other table.

Singapore-style NRIC/FIN check letter for the S, T, F and G series: nine characters, series letter, seven digits, check letter (else "malformed"). Weights 2,7,6,5,4,3,2; add 4 for T and G; r = sum mod 11; the letter is "JZIHGFEDCBA"[r] for S/T and "XWUTRQPNMLK"[r] for F/G. Return [expected letter, match].

split: open-access


prompt:
Almost every check letter is wrong.

Singapore-style NRIC/FIN check letter for the S, T, F and G series: nine characters, series letter, seven digits, check letter (else "malformed"). Weights 2,7,6,5,4,3,2; add 4 for T and G; r = sum mod 11; the letter is "JZIHGFEDCBA"[r] for S/T and "XWUTRQPNMLK"[r] for F/G. Return [expected letter, match].

split: open-access


prompt:
Unknown digits in doubled positions are recovered incorrectly.

Recover the single unknown digit (marked "?") in a Luhn-protected number: input must be at least two characters, ASCII digits and exactly one "?" (else None). Return the digit 0-9 that makes the whole number Luhn-valid; when the unknown sits in a doubled position the needed contribution must be mapped back through the doubling map.

split: open-access


prompt:
Recovery succeeds only when the number length makes left and right parity agree.

Recover the single unknown digit (marked "?") in a Luhn-protected number: input must be at least two characters, ASCII digits and exactly one "?" (else None). Return the digit 0-9 that makes the whole number Luhn-valid; when the unknown sits in a doubled position the needed contribution must be mapped back through the doubling map.

split: open-access


prompt:
Inputs with several unknown digits get a confident single answer.

Recover the single unknown digit (marked "?") in a Luhn-protected number: input must be at least two characters, ASCII digits and exactly one "?" (else None). Return the digit 0-9 that makes the whole number Luhn-valid; when the unknown sits in a doubled position the needed contribution must be mapped back through the doubling map.

split: open-access


prompt:
Slips longer than six digits receive the wrong verifying digit.

Bank-slip style mod-11 verifying digit: nonempty ASCII digits (else None); weights 2,3,...,9 cycle from the rightmost digit; r = 11 - sum mod 11; results 10 and 11 are replaced by 1.

split: open-access


prompt:
Slips whose remainder is 0 or 1 get verifying digit 0, which is reserved.

Bank-slip style mod-11 verifying digit: nonempty ASCII digits (else None); weights 2,3,...,9 cycle from the rightmost digit; r = 11 - sum mod 11; results 10 and 11 are replaced by 1.

split: open-access


prompt:
Y- and Z-series foreigner numbers get the wrong control letter (X happens to work).

Spanish DNI/NIE control letter: input upper-cased, hyphens removed, then nine characters: eight digits (or X/Y/Z followed by seven digits, the prefix standing for 0/1/2) and a letter (else "malformed"). The letter is "TRWAGMYFPDXBNJZSQVHLCKE"[number mod 23]. Return [expected letter, match].

split: open-access


prompt:
Numbers typed in lowercase are reported as mismatches or malformed.

Spanish DNI/NIE control letter: input upper-cased, hyphens removed, then nine characters: eight digits (or X/Y/Z followed by seven digits, the prefix standing for 0/1/2) and a letter (else "malformed"). The letter is "TRWAGMYFPDXBNJZSQVHLCKE"[number mod 23]. Return [expected letter, match].

split: open-access


prompt:
Reference check digits disagree with the bank.

Swiss ESR/QR reference check digit (modulo 10 recursive): spaces ignored, nonempty ASCII digits required (else None). carry starts at 0 and for each digit becomes T[(carry + digit) mod 10] with T = 0,9,4,6,8,2,7,1,3,5; the check digit is (10 - carry) mod 10.

split: open-access


prompt:
Only references with final carry 0 or 5 get the right check digit.

Swiss ESR/QR reference check digit (modulo 10 recursive): spaces ignored, nonempty ASCII digits required (else None). carry starts at 0 and for each digit becomes T[(carry + digit) mod 10] with T = 0,9,4,6,8,2,7,1,3,5; the check digit is (10 - carry) mod 10.

split: open-access


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

N = 1
observations = []
def solve(x):
    m = x['m']
    k = x['k']
    def fnv(s, seed):
        h = (2166136261 ^ seed) & 0xFFFFFFFF
        for b in s.encode('utf-8'):
            h = ((h ^ b) * 16777619) & 0xFFFFFFFF
        return h
    def probes(s):
        h1 = fnv(s, 0)
        h2 = fnv(s, 0x5bd1e995) | 1
        return [((h1 + i * h2) & 0xFFFFFFFF) % m for i in range(1, k)]
    bits = [0] * m
    for s in x['add']:
        for p in probes(s):
            bits[p] = 1
    hits = [all(bits[p] for p in probes(s)) for s in x['query']]
    return [[i for i in range(m) if bits[i]], hits]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[['bloom 0 m=62 k=3',
   {'add': ['smörgås', 'ember', 'eta', 'jalapeño', 'straße'],
    'k': 3,
    'm': 62,
    'query': ['smörgås', 'ember', 'mu', 'straße', 'beta', 'south']},
   [[0, 1, 15, 16, 18, 19, 20, 23, 26, 43, 46, 49, 51, 52, 56],
    [True, True, True, True, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['crème', 'eta', 'øre', 'theta', 'kappa', 'jalapeño'],
    'k': 4,
    'm': 64,
    'query': ['crème', 'eta', 'übung', 'east', 'frost', 'lambda']},
   [[0, 1, 6, 8, 10, 17, 19, 20, 23, 26, 27, 30, 32, 37, 39, 41, 44, 46, 57, 61, 63],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=39 k=2',
   {'add': ['straße', 'gamma', 'iota', 'øre'],
    'k': 2,
    'm': 39,
    'query': ['straße', 'gamma', 'eta', 'zeta', 'frost', 'grove']},
   [[0, 1, 3, 4, 7, 21, 27], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['river', 'jalapeño', 'mu', 'eta', 'übung', 'lambda', 'übung'],
    'k': 5,
    'm': 29,
    'query': ['river', 'jalapeño', 'theta', 'north', 'café', 'naïve']},
   [[0, 3, 5, 8, 9, 10, 11, 13, 14, 15, 16, 17, 20, 21, 22, 24, 25, 28],
    [True, True, False, True, False, False]]],
  ['bloom 4 m=101 k=3',
   {'add': ['eta', 'gamma', 'naïve', 'straße', 'kappa', 'grove', 'delta', 'café'],
    'k': 3,
    'm': 101,
    'query': ['eta', 'gamma', 'north', 'øre', 'lambda', 'iota']},
   [[1, 16, 19, 20, 23, 28, 36, 44, 46, 50, 52, 53, 66, 74, 79, 80, 82, 83, 84, 86, 94],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['café', 'stone', 'grove', 'straße'],
    'k': 2,
    'm': 16,
    'query': ['café', 'stone', 'theta', 'naïve', 'gamma', 'ember']},
   [[0, 3, 8, 9, 10, 15], [True, True, False, False, False, False]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 24, 'query': ['alpha', 'mu']},
   [[], [False, False]]]],
 [['bloom 0 m=63 k=3',
   {'add': ['epsilon', 'south', 'øre', 'mu', 'jalapeño'],
    'k': 3,
    'm': 63,
    'query': ['epsilon', 'south', 'zeta', 'jalapeño', 'east', 'frost']},
   [[3, 13, 15, 18, 26, 27, 30, 34, 46, 48, 54, 56, 58], [True, True, False, True, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['øre', 'zeta', 'café', 'kappa', 'grove', 'øre'],
    'k': 4,
    'm': 64,
    'query': ['øre', 'zeta', 'naïve', 'smörgås', 'west', 'beta']},
   [[0, 1, 6, 8, 9, 14, 19, 21, 24, 27, 31, 32, 38, 42, 44, 45, 46, 55, 57, 63],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=41 k=2',
   {'add': ['west', 'crème', 'jalapeño', 'übung'],
    'k': 2,
    'm': 41,
    'query': ['west', 'crème', 'øre', 'grove', 'frost', 'zeta']},
   [[3, 15, 21, 23, 26, 27, 40], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['west', 'stone', 'café', 'straße', 'theta', 'crème', 'café'],
    'k': 5,
    'm': 29,
    'query': ['west', 'stone', 'epsilon', 'gamma', 'beta', 'zeta']},
   [[0, 1, 2, 6, 7, 9, 10, 11, 12, 13, 14, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27],
    [True, True, True, False, False, False]]],
  ['bloom 4 m=102 k=3',
   {'add': ['øre', 'smörgås', 'straße', 'crème', 'theta', 'east', 'cloud', 'straße'],
    'k': 3,
    'm': 102,
    'query': ['øre', 'smörgås', 'west', 'epsilon', 'übung', 'grove']},
   [[2, 7, 8, 16, 30, 31, 36, 39, 42, 49, 53, 60, 62, 63, 64, 75, 84, 89, 94],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['naïve', 'north', 'übung', 'jalapeño'],
    'k': 2,
    'm': 16,
    'query': ['naïve', 'north', 'south', 'gamma', 'theta', 'øre']},
   [[1, 2, 4, 7, 11], [True, True, False, False, False, False]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 25, 'query': ['alpha', 'mu']},
   [[], [False, False]]]],
 [['bloom 0 m=64 k=3',
   {'add': ['east', 'straße', 'west', 'grove', 'øre'],
    'k': 3,
    'm': 64,
    'query': ['east', 'straße', 'ember', 'eta', 'cloud', 'gamma']},
   [[3, 6, 19, 24, 25, 31, 38, 46, 53, 54, 57, 60], [True, True, False, False, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['grove', 'øre', 'west', 'delta', 'north', 'übung'],
    'k': 4,
    'm': 64,
    'query': ['grove', 'øre', 'café', 'straße', 'lambda', 'south']},
   [[1, 3, 4, 6, 14, 15, 19, 23, 24, 27, 31, 33, 38, 42, 44, 45, 46, 52, 53, 57, 60, 61],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=43 k=2',
   {'add': ['delta', 'übung', 'gamma', 'café'],
    'k': 2,
    'm': 43,
    'query': ['delta', 'übung', 'epsilon', 'theta', 'smörgås', 'alpha']},
   [[0, 3, 4, 8, 18, 23, 29, 31], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['beta', 'theta', 'delta', 'east', 'epsilon', 'øre', 'straße'],
    'k': 5,
    'm': 29,
    'query': ['beta', 'theta', 'crème', 'kappa', 'zeta', 'naïve']},
   [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 19, 20, 21, 23, 24, 25, 28],
    [True, True, False, True, False, False]]],
  ['bloom 4 m=103 k=3',
   {'add': ['ember', 'west', 'smörgås', 'frost', 'south', 'naïve', 'theta', 'jalapeño'],
    'k': 3,
    'm': 103,
    'query': ['ember', 'west', 'stone', 'grove', 'øre', 'cloud']},
   [[0, 5, 6, 14, 15, 16, 23, 25, 31, 37, 48, 54, 59, 60, 72, 74, 77, 78, 80, 93, 94, 95],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['gamma', 'mu', 'eta', 'øre'],
    'k': 2,
    'm': 16,
    'query': ['gamma', 'mu', 'smörgås', 'ember', 'east', 'øre']},
   [[3, 6, 7, 8, 10, 11, 14], [True, True, False, False, False, True]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 26, 'query': ['alpha', 'mu']},
   [[], [False, False]]]],
 [['bloom 0 m=65 k=3',
   {'add': ['alpha', 'ember', 'eta', 'west', 'übung'],
    'k': 3,
    'm': 65,
    'query': ['alpha', 'ember', 'river', 'theta', 'café', 'lambda']},
   [[0, 6, 7, 9, 14, 15, 16, 26, 28, 37, 47, 49, 56, 64],
    [True, True, False, False, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['alpha', 'east', 'epsilon', 'stone', 'grove', 'café'],
    'k': 4,
    'm': 64,
    'query': ['alpha', 'east', 'zeta', 'delta', 'ember', 'west']},
   [[9, 14, 16, 19, 24, 25, 26, 29, 31, 32, 36, 38, 43, 45, 47, 53, 54, 55, 58, 60],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=45 k=2',
   {'add': ['gamma', 'north', 'river', 'straße'],
    'k': 2,
    'm': 45,
    'query': ['gamma', 'north', 'lambda', 'mu', 'frost', 'beta']},
   [[8, 9, 18, 19, 27, 29, 33], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['ember', 'eta', 'smörgås', 'iota', 'café', 'lambda', 'jalapeño'],
    'k': 5,
    'm': 29,
    'query': ['ember', 'eta', 'øre', 'zeta', 'north', 'kappa']},
   [[0, 3, 5, 7, 9, 10, 12, 13, 14, 15, 17, 19, 20, 21, 24, 25],
    [True, True, False, False, False, False]]],
  ['bloom 4 m=104 k=3',
   {'add': ['naïve', 'beta', 'straße', 'ember', 'jalapeño', 'theta', 'iota', 'øre'],
    'k': 3,
    'm': 104,
    'query': ['naïve', 'beta', 'zeta', 'smörgås', 'frost', 'delta']},
   [[0, 8, 9, 11, 16, 28, 30, 31, 34, 37, 47, 49, 52, 53, 57, 67, 78, 82, 87, 90, 93, 98, 99],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['beta', 'øre', 'stone', 'übung'],
    'k': 2,
    'm': 16,
    'query': ['beta', 'øre', 'ember', 'delta', 'zeta', 'iota']},
   [[1, 3, 4, 6, 7, 10, 15], [True, True, True, False, True, False]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 27, 'query': ['alpha', 'mu']},
   [[], [False, False]]]],
 [['bloom 0 m=66 k=3',
   {'add': ['frost', 'smörgås', 'mu', 'grove', 'café'],
    'k': 3,
    'm': 66,
    'query': ['frost', 'smörgås', 'stone', 'delta', 'alpha', 'kappa']},
   [[0, 6, 14, 29, 33, 36, 37, 41, 45, 46, 51, 55, 58, 61, 62],
    [True, True, False, False, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['crème', 'river', 'smörgås', 'lambda', 'kappa', 'straße'],
    'k': 4,
    'm': 64,
    'query': ['crème', 'river', 'zeta', 'mu', 'frost', 'epsilon']},
   [[1, 3, 6, 8, 11, 16, 17, 18, 24, 25, 27, 30, 32, 37, 39, 42, 46, 60, 61, 63],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=47 k=2',
   {'add': ['delta', 'south', 'café', 'jalapeño'],
    'k': 2,
    'm': 47,
    'query': ['delta', 'south', 'mu', 'zeta', 'naïve', 'øre']},
   [[0, 2, 11, 30, 35, 40, 43], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['café', 'cloud', 'straße', 'übung', 'south', 'theta', 'øre'],
    'k': 5,
    'm': 29,
    'query': ['café', 'cloud', 'east', 'zeta', 'øre', 'kappa']},
   [[1, 2, 4, 6, 7, 10, 11, 12, 13, 14, 16, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28],
    [True, True, False, False, True, False]]],
  ['bloom 4 m=105 k=3',
   {'add': ['grove', 'cloud', 'crème', 'iota', 'beta', 'lambda', 'øre', 'übung'],
    'k': 3,
    'm': 105,
    'query': ['grove', 'cloud', 'delta', 'mu', 'zeta', 'café']},
   [[2, 4, 10, 11, 15, 20, 31, 38, 61, 66, 67, 69, 72, 73, 74, 77, 78, 80, 81, 88, 91],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['jalapeño', 'frost', 'crème', 'café'],
    'k': 2,
    'm': 16,
    'query': ['jalapeño', 'frost', 'smörgås', 'river', 'north', 'stone']},
   [[0, 1, 4, 8, 9, 13, 14], [True, True, False, False, False, False]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 28, 'query': ['alpha', 'mu']},
   [[], [False, False]]]]]
for label, args, expected in cases[N - 1]:
    check(label, solve(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(x):
    m = x['m']
    k = x['k']
    def fnv(s, seed):
        h = (2166136261 ^ seed) & 0xFFFFFFFF
        for b in s.encode('utf-8'):
            h = ((h ^ b) * 16777619) & 0xFFFFFFFF
        return h
    def probes(s):
        h1 = fnv(s, 0)
        h2 = fnv(s, 0x5bd1e995) | 1
        return [((h1 + i * h2) & 0xFFFFFFFF) % m for i in range(1, k + 1)]
    bits = [0] * m
    for s in x['add']:
        for p in probes(s):
            bits[p] = 1
    hits = [all(bits[p] for p in probes(s)) for s in x['query']]
    return [[i for i in range(m) if bits[i]], hits]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[['bloom 0 m=62 k=3',
   {'add': ['smörgås', 'ember', 'eta', 'jalapeño', 'straße'],
    'k': 3,
    'm': 62,
    'query': ['smörgås', 'ember', 'mu', 'straße', 'beta', 'south']},
   [[0, 1, 15, 16, 18, 19, 20, 23, 26, 43, 46, 49, 51, 52, 56],
    [True, True, True, True, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['crème', 'eta', 'øre', 'theta', 'kappa', 'jalapeño'],
    'k': 4,
    'm': 64,
    'query': ['crème', 'eta', 'übung', 'east', 'frost', 'lambda']},
   [[0, 1, 6, 8, 10, 17, 19, 20, 23, 26, 27, 30, 32, 37, 39, 41, 44, 46, 57, 61, 63],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=39 k=2',
   {'add': ['straße', 'gamma', 'iota', 'øre'],
    'k': 2,
    'm': 39,
    'query': ['straße', 'gamma', 'eta', 'zeta', 'frost', 'grove']},
   [[0, 1, 3, 4, 7, 21, 27], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['river', 'jalapeño', 'mu', 'eta', 'übung', 'lambda', 'übung'],
    'k': 5,
    'm': 29,
    'query': ['river', 'jalapeño', 'theta', 'north', 'café', 'naïve']},
   [[0, 3, 5, 8, 9, 10, 11, 13, 14, 15, 16, 17, 20, 21, 22, 24, 25, 28],
    [True, True, False, True, False, False]]],
  ['bloom 4 m=101 k=3',
   {'add': ['eta', 'gamma', 'naïve', 'straße', 'kappa', 'grove', 'delta', 'café'],
    'k': 3,
    'm': 101,
    'query': ['eta', 'gamma', 'north', 'øre', 'lambda', 'iota']},
   [[1, 16, 19, 20, 23, 28, 36, 44, 46, 50, 52, 53, 66, 74, 79, 80, 82, 83, 84, 86, 94],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['café', 'stone', 'grove', 'straße'],
    'k': 2,
    'm': 16,
    'query': ['café', 'stone', 'theta', 'naïve', 'gamma', 'ember']},
   [[0, 3, 8, 9, 10, 15], [True, True, False, False, False, False]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 24, 'query': ['alpha', 'mu']},
   [[], [False, False]]]],
 [['bloom 0 m=63 k=3',
   {'add': ['epsilon', 'south', 'øre', 'mu', 'jalapeño'],
    'k': 3,
    'm': 63,
    'query': ['epsilon', 'south', 'zeta', 'jalapeño', 'east', 'frost']},
   [[3, 13, 15, 18, 26, 27, 30, 34, 46, 48, 54, 56, 58], [True, True, False, True, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['øre', 'zeta', 'café', 'kappa', 'grove', 'øre'],
    'k': 4,
    'm': 64,
    'query': ['øre', 'zeta', 'naïve', 'smörgås', 'west', 'beta']},
   [[0, 1, 6, 8, 9, 14, 19, 21, 24, 27, 31, 32, 38, 42, 44, 45, 46, 55, 57, 63],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=41 k=2',
   {'add': ['west', 'crème', 'jalapeño', 'übung'],
    'k': 2,
    'm': 41,
    'query': ['west', 'crème', 'øre', 'grove', 'frost', 'zeta']},
   [[3, 15, 21, 23, 26, 27, 40], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['west', 'stone', 'café', 'straße', 'theta', 'crème', 'café'],
    'k': 5,
    'm': 29,
    'query': ['west', 'stone', 'epsilon', 'gamma', 'beta', 'zeta']},
   [[0, 1, 2, 6, 7, 9, 10, 11, 12, 13, 14, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27],
    [True, True, True, False, False, False]]],
  ['bloom 4 m=102 k=3',
   {'add': ['øre', 'smörgås', 'straße', 'crème', 'theta', 'east', 'cloud', 'straße'],
    'k': 3,
    'm': 102,
    'query': ['øre', 'smörgås', 'west', 'epsilon', 'übung', 'grove']},
   [[2, 7, 8, 16, 30, 31, 36, 39, 42, 49, 53, 60, 62, 63, 64, 75, 84, 89, 94],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['naïve', 'north', 'übung', 'jalapeño'],
    'k': 2,
    'm': 16,
    'query': ['naïve', 'north', 'south', 'gamma', 'theta', 'øre']},
   [[1, 2, 4, 7, 11], [True, True, False, False, False, False]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 25, 'query': ['alpha', 'mu']},
   [[], [False, False]]]],
 [['bloom 0 m=64 k=3',
   {'add': ['east', 'straße', 'west', 'grove', 'øre'],
    'k': 3,
    'm': 64,
    'query': ['east', 'straße', 'ember', 'eta', 'cloud', 'gamma']},
   [[3, 6, 19, 24, 25, 31, 38, 46, 53, 54, 57, 60], [True, True, False, False, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['grove', 'øre', 'west', 'delta', 'north', 'übung'],
    'k': 4,
    'm': 64,
    'query': ['grove', 'øre', 'café', 'straße', 'lambda', 'south']},
   [[1, 3, 4, 6, 14, 15, 19, 23, 24, 27, 31, 33, 38, 42, 44, 45, 46, 52, 53, 57, 60, 61],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=43 k=2',
   {'add': ['delta', 'übung', 'gamma', 'café'],
    'k': 2,
    'm': 43,
    'query': ['delta', 'übung', 'epsilon', 'theta', 'smörgås', 'alpha']},
   [[0, 3, 4, 8, 18, 23, 29, 31], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['beta', 'theta', 'delta', 'east', 'epsilon', 'øre', 'straße'],
    'k': 5,
    'm': 29,
    'query': ['beta', 'theta', 'crème', 'kappa', 'zeta', 'naïve']},
   [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 19, 20, 21, 23, 24, 25, 28],
    [True, True, False, True, False, False]]],
  ['bloom 4 m=103 k=3',
   {'add': ['ember', 'west', 'smörgås', 'frost', 'south', 'naïve', 'theta', 'jalapeño'],
    'k': 3,
    'm': 103,
    'query': ['ember', 'west', 'stone', 'grove', 'øre', 'cloud']},
   [[0, 5, 6, 14, 15, 16, 23, 25, 31, 37, 48, 54, 59, 60, 72, 74, 77, 78, 80, 93, 94, 95],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['gamma', 'mu', 'eta', 'øre'],
    'k': 2,
    'm': 16,
    'query': ['gamma', 'mu', 'smörgås', 'ember', 'east', 'øre']},
   [[3, 6, 7, 8, 10, 11, 14], [True, True, False, False, False, True]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 26, 'query': ['alpha', 'mu']},
   [[], [False, False]]]],
 [['bloom 0 m=65 k=3',
   {'add': ['alpha', 'ember', 'eta', 'west', 'übung'],
    'k': 3,
    'm': 65,
    'query': ['alpha', 'ember', 'river', 'theta', 'café', 'lambda']},
   [[0, 6, 7, 9, 14, 15, 16, 26, 28, 37, 47, 49, 56, 64],
    [True, True, False, False, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['alpha', 'east', 'epsilon', 'stone', 'grove', 'café'],
    'k': 4,
    'm': 64,
    'query': ['alpha', 'east', 'zeta', 'delta', 'ember', 'west']},
   [[9, 14, 16, 19, 24, 25, 26, 29, 31, 32, 36, 38, 43, 45, 47, 53, 54, 55, 58, 60],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=45 k=2',
   {'add': ['gamma', 'north', 'river', 'straße'],
    'k': 2,
    'm': 45,
    'query': ['gamma', 'north', 'lambda', 'mu', 'frost', 'beta']},
   [[8, 9, 18, 19, 27, 29, 33], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['ember', 'eta', 'smörgås', 'iota', 'café', 'lambda', 'jalapeño'],
    'k': 5,
    'm': 29,
    'query': ['ember', 'eta', 'øre', 'zeta', 'north', 'kappa']},
   [[0, 3, 5, 7, 9, 10, 12, 13, 14, 15, 17, 19, 20, 21, 24, 25],
    [True, True, False, False, False, False]]],
  ['bloom 4 m=104 k=3',
   {'add': ['naïve', 'beta', 'straße', 'ember', 'jalapeño', 'theta', 'iota', 'øre'],
    'k': 3,
    'm': 104,
    'query': ['naïve', 'beta', 'zeta', 'smörgås', 'frost', 'delta']},
   [[0, 8, 9, 11, 16, 28, 30, 31, 34, 37, 47, 49, 52, 53, 57, 67, 78, 82, 87, 90, 93, 98, 99],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['beta', 'øre', 'stone', 'übung'],
    'k': 2,
    'm': 16,
    'query': ['beta', 'øre', 'ember', 'delta', 'zeta', 'iota']},
   [[1, 3, 4, 6, 7, 10, 15], [True, True, True, False, True, False]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 27, 'query': ['alpha', 'mu']},
   [[], [False, False]]]],
 [['bloom 0 m=66 k=3',
   {'add': ['frost', 'smörgås', 'mu', 'grove', 'café'],
    'k': 3,
    'm': 66,
    'query': ['frost', 'smörgås', 'stone', 'delta', 'alpha', 'kappa']},
   [[0, 6, 14, 29, 33, 36, 37, 41, 45, 46, 51, 55, 58, 61, 62],
    [True, True, False, False, False, False]]],
  ['bloom 1 m=64 k=4',
   {'add': ['crème', 'river', 'smörgås', 'lambda', 'kappa', 'straße'],
    'k': 4,
    'm': 64,
    'query': ['crème', 'river', 'zeta', 'mu', 'frost', 'epsilon']},
   [[1, 3, 6, 8, 11, 16, 17, 18, 24, 25, 27, 30, 32, 37, 39, 42, 46, 60, 61, 63],
    [True, True, False, False, False, False]]],
  ['bloom 2 m=47 k=2',
   {'add': ['delta', 'south', 'café', 'jalapeño'],
    'k': 2,
    'm': 47,
    'query': ['delta', 'south', 'mu', 'zeta', 'naïve', 'øre']},
   [[0, 2, 11, 30, 35, 40, 43], [True, True, False, False, False, False]]],
  ['bloom 3 m=29 k=5',
   {'add': ['café', 'cloud', 'straße', 'übung', 'south', 'theta', 'øre'],
    'k': 5,
    'm': 29,
    'query': ['café', 'cloud', 'east', 'zeta', 'øre', 'kappa']},
   [[1, 2, 4, 6, 7, 10, 11, 12, 13, 14, 16, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28],
    [True, True, False, False, True, False]]],
  ['bloom 4 m=105 k=3',
   {'add': ['grove', 'cloud', 'crème', 'iota', 'beta', 'lambda', 'øre', 'übung'],
    'k': 3,
    'm': 105,
    'query': ['grove', 'cloud', 'delta', 'mu', 'zeta', 'café']},
   [[2, 4, 10, 11, 15, 20, 31, 38, 61, 66, 67, 69, 72, 73, 74, 77, 78, 80, 81, 88, 91],
    [True, True, False, False, False, False]]],
  ['bloom 5 m=16 k=2',
   {'add': ['jalapeño', 'frost', 'crème', 'café'],
    'k': 2,
    'm': 16,
    'query': ['jalapeño', 'frost', 'smörgås', 'river', 'north', 'stone']},
   [[0, 1, 4, 8, 9, 13, 14], [True, True, False, False, False, False]]],
  ['empty filter rejects everything',
   {'add': [], 'k': 3, 'm': 28, 'query': ['alpha', 'mu']},
   [[], [False, False]]]]]
for label, args, expected in cases[N - 1]:
    check(label, solve(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 filter sets bits at positions that another writer never probes, and base-hash bits are missing.

Input {m, k, add, query}. Each string is hashed with 32-bit FNV-1a over its UTF-8 bytes using seed 0 (h1) and seed 0x5bd1e995 (h2); h2 is forced odd by OR-ing 1. Probe i for i in 0..k-1 is ((h1 + i*h2) mod 2^32) mod m. Return [sorted set bit indices, membership booleans for query] where membership requires every probe bit.

split: open-access