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

N = 1
observations = []
def solve(s):
    if len(s) != 12 or not s.isascii() or not s[:2].isalpha() or not s[:2].isupper():
        return 'malformed'
    if not s[2:11].isalnum() or s[2:11] != s[2:11].upper() or not s[11].isdigit():
        return 'malformed'
    digits = ''
    for ch in s[:11]:
        digits += ch if ch.isdigit() else str(ord(ch) - 55)
    total = 0
    for i, ch in enumerate(reversed(digits)):
        d = int(ch)
        if i % 2 == 1:
            d *= 2
            if d > 9:
                d -= 9
        total += d
    check = (10 - total % 10) % 10
    return [check, check == int(s[11])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["US4V5PGS4IX8"]', ['US4V5PGS4IX8'], [0, False]], ['regression ["DEC85GG2TSS1"]', ['DEC85GG2TSS1'], [4, False]], ['partial-repair ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['partial-repair ["XS0K4JDSXBN1"]', ['XS0K4JDSXBN1'], [4, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed']], [['regression ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['regression ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]], ['partial-repair ["AU0000XVGZA3"]', ['AU0000XVGZA3'], [3, True]], ['partial-repair ["DE000BAY0017"]', ['DE000BAY0017'], [7, True]], ['control ["12Q037833100"]', ['12Q037833100'], 'malformed'], ['control ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["XS2021832634"]', ['XS2021832634'], [4, True]]], [['regression ["NL5BVKR8BB60"]', ['NL5BVKR8BB60'], [3, False]], ['regression ["AUKWRNHD2XR3"]', ['AUKWRNHD2XR3'], [8, False]], ['partial-repair ["CA0000ABCDE0"]', ['CA0000ABCDE0'], [9, False]], ['partial-repair ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed']], [['regression ["IE9141151847"]', ['IE9141151847'], [0, False]], ['regression ["LU7763909076"]', ['LU7763909076'], [8, False]], ['partial-repair ["CA3CKMM2IAN8"]', ['CA3CKMM2IAN8'], [0, False]], ['partial-repair ["AU0000XVGZA3"]', ['AU0000XVGZA3'], [3, True]], ['control ["12Q037833100"]', ['12Q037833100'], 'malformed'], ['control ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["XS2021832634"]', ['XS2021832634'], [4, True]]], [['regression ["BM9170095145"]', ['BM9170095145'], [7, False]], ['regression ["US0378331005"]', ['US0378331005'], [5, True]], ['partial-repair ["US38259P5089"]', ['US38259P5089'], [9, True]], ['partial-repair ["CA0000ABCDE0"]', ['CA0000ABCDE0'], [9, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], '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) != 12 or not s.isascii() or not s[:2].isalpha() or not s[:2].isupper():
        return 'malformed'
    if not s[2:11].isalnum() or s[2:11] != s[2:11].upper() or not s[11].isdigit():
        return 'malformed'
    digits = ''
    for ch in s[:11]:
        digits += ch if ch.isdigit() else str(ord(ch) - 55)
    total = 0
    for i, ch in enumerate(reversed(digits)):
        d = int(ch)
        if (len(digits) - 1 - i) % 2 == 0:
            d *= 2
            if d > 9:
                d -= 9
        total += d
    check = (10 - total % 10) % 10
    return [check, check == int(s[11])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["US4V5PGS4IX8"]', ['US4V5PGS4IX8'], [0, False]], ['regression ["DEC85GG2TSS1"]', ['DEC85GG2TSS1'], [4, False]], ['partial-repair ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['partial-repair ["XS0K4JDSXBN1"]', ['XS0K4JDSXBN1'], [4, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed']], [['regression ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['regression ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]], ['partial-repair ["AU0000XVGZA3"]', ['AU0000XVGZA3'], [3, True]], ['partial-repair ["DE000BAY0017"]', ['DE000BAY0017'], [7, True]], ['control ["12Q037833100"]', ['12Q037833100'], 'malformed'], ['control ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["XS2021832634"]', ['XS2021832634'], [4, True]]], [['regression ["NL5BVKR8BB60"]', ['NL5BVKR8BB60'], [3, False]], ['regression ["AUKWRNHD2XR3"]', ['AUKWRNHD2XR3'], [8, False]], ['partial-repair ["CA0000ABCDE0"]', ['CA0000ABCDE0'], [9, False]], ['partial-repair ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed']], [['regression ["IE9141151847"]', ['IE9141151847'], [0, False]], ['regression ["LU7763909076"]', ['LU7763909076'], [8, False]], ['partial-repair ["CA3CKMM2IAN8"]', ['CA3CKMM2IAN8'], [0, False]], ['partial-repair ["AU0000XVGZA3"]', ['AU0000XVGZA3'], [3, True]], ['control ["12Q037833100"]', ['12Q037833100'], 'malformed'], ['control ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["XS2021832634"]', ['XS2021832634'], [4, True]]], [['regression ["BM9170095145"]', ['BM9170095145'], [7, False]], ['regression ["US0378331005"]', ['US0378331005'], [5, True]], ['partial-repair ["US38259P5089"]', ['US38259P5089'], [9, True]], ['partial-repair ["CA0000ABCDE0"]', ['CA0000ABCDE0'], [9, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], '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:
Computed ISIN check digits disagree with issued identifiers.

Input a 12-character ISIN: two uppercase ASCII letters (country), nine uppercase alphanumerics, one check digit; anything else is "malformed". Letters expand to two digits (A=10 .. Z=35), then Luhn doubling starts at the rightmost digit of the expanded 11-character payload. Return [computed check digit, whether it matches].

split: open-access


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

N = 1
observations = []
def solve(s):
    if len(s) != 12 or not s.isascii() or not s[:2].isalpha() or not s[:2].isupper():
        return 'malformed'
    if not s[2:11].isalnum() or not s[11].isdigit():
        return 'malformed'
    digits = ''
    for ch in s[:11]:
        digits += ch if ch.isdigit() else str(ord(ch) - 55)
    total = 0
    for i, ch in enumerate(reversed(digits)):
        d = int(ch)
        if i % 2 == 0:
            d *= 2
            if d > 9:
                d -= 9
        total += d
    check = (10 - total % 10) % 10
    return [check, check == int(s[11])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["US4V5PGS4IX8"]', ['US4V5PGS4IX8'], [0, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["DEC85GG2TSS1"]', ['DEC85GG2TSS1'], [4, False]], ['control ["JPFWKDL124I1"]', ['JPFWKDL124I1'], [1, True]], ['control ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['control ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]], ['control ["XS0K4JDSXBN1"]', ['XS0K4JDSXBN1'], [4, False]]], [['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]], ['control ["XS0K4JDSXBN1"]', ['XS0K4JDSXBN1'], [4, False]], ['control ["NL5BVKR8BB60"]', ['NL5BVKR8BB60'], [3, False]], ['control ["AUKWRNHD2XR3"]', ['AUKWRNHD2XR3'], [8, False]], ['control ["CA3CKMM2IAN8"]', ['CA3CKMM2IAN8'], [0, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["IE9141151847"]', ['IE9141151847'], [0, False]]], [['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["IE9141151847"]', ['IE9141151847'], [0, False]], ['control ["LU7763909076"]', ['LU7763909076'], [8, False]], ['control ["KY3791880781"]', ['KY3791880781'], [4, False]], ['control ["BM9170095145"]', ['BM9170095145'], [7, False]], ['control ["US0378331005"]', ['US0378331005'], [5, True]], ['control ["US5949181045"]', ['US5949181045'], [5, True]]], [['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["US0378331005"]', ['US0378331005'], [5, True]], ['control ["US5949181045"]', ['US5949181045'], [5, True]], ['control ["GB0002634946"]', ['GB0002634946'], [6, True]], ['control ["AU0000XVGZA3"]', ['AU0000XVGZA3'], [3, True]], ['control ["DE000BAY0017"]', ['DE000BAY0017'], [7, True]], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed']], [['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed'], ['control ["12Q037833100"]', ['12Q037833100'], 'malformed'], ['control ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["XS2021832634"]', ['XS2021832634'], [4, True]], ['control ["US38259P5089"]', ['US38259P5089'], [9, True]]]]
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(s):
    if len(s) != 12 or not s.isascii() or not s[:2].isalpha() or not s[:2].isupper():
        return 'malformed'
    if not s[2:11].isalnum() or s[:2] != s[:2].upper() or not s[11].isdigit():
        return 'malformed'
    digits = ''
    for ch in s[:11]:
        digits += ch if ch.isdigit() else str(ord(ch) - 55)
    total = 0
    for i, ch in enumerate(reversed(digits)):
        d = int(ch)
        if i % 2 == 0:
            d *= 2
            if d > 9:
                d -= 9
        total += d
    check = (10 - total % 10) % 10
    return [check, check == int(s[11])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["US4V5PGS4IX8"]', ['US4V5PGS4IX8'], [0, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["DEC85GG2TSS1"]', ['DEC85GG2TSS1'], [4, False]], ['control ["JPFWKDL124I1"]', ['JPFWKDL124I1'], [1, True]], ['control ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['control ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]], ['control ["XS0K4JDSXBN1"]', ['XS0K4JDSXBN1'], [4, False]]], [['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]], ['control ["XS0K4JDSXBN1"]', ['XS0K4JDSXBN1'], [4, False]], ['control ["NL5BVKR8BB60"]', ['NL5BVKR8BB60'], [3, False]], ['control ["AUKWRNHD2XR3"]', ['AUKWRNHD2XR3'], [8, False]], ['control ["CA3CKMM2IAN8"]', ['CA3CKMM2IAN8'], [0, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["IE9141151847"]', ['IE9141151847'], [0, False]]], [['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["IE9141151847"]', ['IE9141151847'], [0, False]], ['control ["LU7763909076"]', ['LU7763909076'], [8, False]], ['control ["KY3791880781"]', ['KY3791880781'], [4, False]], ['control ["BM9170095145"]', ['BM9170095145'], [7, False]], ['control ["US0378331005"]', ['US0378331005'], [5, True]], ['control ["US5949181045"]', ['US5949181045'], [5, True]]], [['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["US0378331005"]', ['US0378331005'], [5, True]], ['control ["US5949181045"]', ['US5949181045'], [5, True]], ['control ["GB0002634946"]', ['GB0002634946'], [6, True]], ['control ["AU0000XVGZA3"]', ['AU0000XVGZA3'], [3, True]], ['control ["DE000BAY0017"]', ['DE000BAY0017'], [7, True]], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed']], [['regression ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed'], ['control ["12Q037833100"]', ['12Q037833100'], 'malformed'], ['control ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["XS2021832634"]', ['XS2021832634'], [4, True]], ['control ["US38259P5089"]', ['US38259P5089'], [9, True]]]]
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:
A lowercase body produces a check-digit verdict instead of being rejected.

Input a 12-character ISIN: two uppercase ASCII letters (country), nine uppercase alphanumerics, one check digit; anything else is "malformed". Letters expand to two digits (A=10 .. Z=35), then Luhn doubling starts at the rightmost digit of the expanded 11-character payload. Return [computed check digit, whether it matches].

split: open-access


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

N = 1
observations = []
def solve(s):
    if len(s) != 12 or not s.isascii() or not s[:2].isupper():
        return 'malformed'
    if not s[2:11].isalnum() or s[2:11] != s[2:11].upper() or not s[11].isdigit():
        return 'malformed'
    digits = ''
    for ch in s[:11]:
        digits += ch if ch.isdigit() else str(ord(ch) - 55)
    total = 0
    for i, ch in enumerate(reversed(digits)):
        d = int(ch)
        if i % 2 == 0:
            d *= 2
            if d > 9:
                d -= 9
        total += d
    check = (10 - total % 10) % 10
    return [check, check == int(s[11])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["US4V5PGS4IX8"]', ['US4V5PGS4IX8'], [0, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["DEC85GG2TSS1"]', ['DEC85GG2TSS1'], [4, False]], ['control ["JPFWKDL124I1"]', ['JPFWKDL124I1'], [1, True]], ['control ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['control ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]]], [['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]], ['control ["XS0K4JDSXBN1"]', ['XS0K4JDSXBN1'], [4, False]], ['control ["NL5BVKR8BB60"]', ['NL5BVKR8BB60'], [3, False]], ['control ["AUKWRNHD2XR3"]', ['AUKWRNHD2XR3'], [8, False]], ['control ["CA3CKMM2IAN8"]', ['CA3CKMM2IAN8'], [0, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]]], [['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["IE9141151847"]', ['IE9141151847'], [0, False]], ['control ["LU7763909076"]', ['LU7763909076'], [8, False]], ['control ["KY3791880781"]', ['KY3791880781'], [4, False]], ['control ["BM9170095145"]', ['BM9170095145'], [7, False]], ['control ["US0378331005"]', ['US0378331005'], [5, True]]], [['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["US0378331005"]', ['US0378331005'], [5, True]], ['control ["US5949181045"]', ['US5949181045'], [5, True]], ['control ["GB0002634946"]', ['GB0002634946'], [6, True]], ['control ["AU0000XVGZA3"]', ['AU0000XVGZA3'], [3, True]], ['control ["DE000BAY0017"]', ['DE000BAY0017'], [7, True]], ['control ["US037833100"]', ['US037833100'], 'malformed']], [['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed'], ['control ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["12Q037833100"]', ['12Q037833100'], 'malformed'], ['control ["XS2021832634"]', ['XS2021832634'], [4, True]], ['control ["US38259P5089"]', ['US38259P5089'], [9, True]]]]
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) != 12 or not s.isascii() or not s[0].isalpha() or not s[0].isupper():
        return 'malformed'
    if not s[2:11].isalnum() or s[2:11] != s[2:11].upper() or not s[11].isdigit():
        return 'malformed'
    digits = ''
    for ch in s[:11]:
        digits += ch if ch.isdigit() else str(ord(ch) - 55)
    total = 0
    for i, ch in enumerate(reversed(digits)):
        d = int(ch)
        if i % 2 == 0:
            d *= 2
            if d > 9:
                d -= 9
        total += d
    check = (10 - total % 10) % 10
    return [check, check == int(s[11])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["US4V5PGS4IX8"]', ['US4V5PGS4IX8'], [0, False]], ['control ["GBOV8F5J6090"]', ['GBOV8F5J6090'], [7, False]], ['control ["DEC85GG2TSS1"]', ['DEC85GG2TSS1'], [4, False]], ['control ["JPFWKDL124I1"]', ['JPFWKDL124I1'], [1, True]], ['control ["CHXVXSVIT016"]', ['CHXVXSVIT016'], [1, False]], ['control ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]]], [['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["FRLWNIYHPT37"]', ['FRLWNIYHPT37'], [5, False]], ['control ["XS0K4JDSXBN1"]', ['XS0K4JDSXBN1'], [4, False]], ['control ["NL5BVKR8BB60"]', ['NL5BVKR8BB60'], [3, False]], ['control ["AUKWRNHD2XR3"]', ['AUKWRNHD2XR3'], [8, False]], ['control ["CA3CKMM2IAN8"]', ['CA3CKMM2IAN8'], [0, False]], ['control ["US6754047769"]', ['US6754047769'], [8, False]]], [['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["US6754047769"]', ['US6754047769'], [8, False]], ['control ["IE9141151847"]', ['IE9141151847'], [0, False]], ['control ["LU7763909076"]', ['LU7763909076'], [8, False]], ['control ["KY3791880781"]', ['KY3791880781'], [4, False]], ['control ["BM9170095145"]', ['BM9170095145'], [7, False]], ['control ["US0378331005"]', ['US0378331005'], [5, True]]], [['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['control ["US0378331005"]', ['US0378331005'], [5, True]], ['control ["US5949181045"]', ['US5949181045'], [5, True]], ['control ["GB0002634946"]', ['GB0002634946'], [6, True]], ['control ["AU0000XVGZA3"]', ['AU0000XVGZA3'], [3, True]], ['control ["DE000BAY0017"]', ['DE000BAY0017'], [7, True]], ['control ["US037833100"]', ['US037833100'], 'malformed']], [['regression ["1S0378331005"]', ['1S0378331005'], 'malformed'], ['regression ["U10378331005"]', ['U10378331005'], 'malformed'], ['control ["US037833100"]', ['US037833100'], 'malformed'], ['control ["us0378331005"]', ['us0378331005'], 'malformed'], ['control ["US03783310a5"]', ['US03783310a5'], 'malformed'], ['control ["12Q037833100"]', ['12Q037833100'], 'malformed'], ['control ["XS2021832634"]', ['XS2021832634'], [4, True]], ['control ["US38259P5089"]', ['US38259P5089'], [9, True]]]]
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:
Identifiers without an alphabetic country code are checksummed as if they were ISINs.

Input a 12-character ISIN: two uppercase ASCII letters (country), nine uppercase alphanumerics, one check digit; anything else is "malformed". Letters expand to two digits (A=10 .. Z=35), then Luhn doubling starts at the rightmost digit of the expanded 11-character payload. Return [computed check digit, whether it matches].

split: open-access


prompt:
Generated check digits fail validation of the very number they were computed for.

Verhoeff dihedral-group scheme. mode "generate" returns the check digit for a nonempty ASCII digit payload; mode "validate" returns whether a nonempty digit string ending in its check digit is correct. Digits are processed from the right with permutation P[(i + offset) % 8], offset 1 when generating and 0 when validating; the check digit is the dihedral inverse of the final state. Empty or non-digit input returns None.

split: open-access


prompt:
Only palindromic payloads produce correct check digits.

Verhoeff dihedral-group scheme. mode "generate" returns the check digit for a nonempty ASCII digit payload; mode "validate" returns whether a nonempty digit string ending in its check digit is correct. Digits are processed from the right with permutation P[(i + offset) % 8], offset 1 when generating and 0 when validating; the check digit is the dihedral inverse of the final state. Empty or non-digit input returns None.

split: open-access


prompt:
Payloads ending in states 1-4 get a check digit that does not validate.

Verhoeff dihedral-group scheme. mode "generate" returns the check digit for a nonempty ASCII digit payload; mode "validate" returns whether a nonempty digit string ending in its check digit is correct. Digits are processed from the right with permutation P[(i + offset) % 8], offset 1 when generating and 0 when validating; the check digit is the dihedral inverse of the final state. Empty or non-digit input returns None.

split: open-access


prompt:
Numbers containing reflections produce wrong check digits.

Verhoeff dihedral-group scheme. mode "generate" returns the check digit for a nonempty ASCII digit payload; mode "validate" returns whether a nonempty digit string ending in its check digit is correct. Digits are processed from the right with permutation P[(i + offset) % 8], offset 1 when generating and 0 when validating; the check digit is the dihedral inverse of the final state. Empty or non-digit input returns None.

split: open-access


prompt:
Most generated check digits disagree with the Damm reference.

Damm quasigroup scheme with the standard order-10 table. Spaces are ignored; the remaining text must be nonempty ASCII digits or the result is None. Digits are processed left to right with interim = T[interim][digit] from 0; "generate" returns the final interim value, "validate" returns whether it is 0.

split: open-access


prompt:
Check digits only match for palindromic payloads.

Damm quasigroup scheme with the standard order-10 table. Spaces are ignored; the remaining text must be nonempty ASCII digits or the result is None. Digits are processed left to right with interim = T[interim][digit] from 0; "generate" returns the final interim value, "validate" returns whether it is 0.

split: open-access


prompt:
References printed in groups of digits return None.

Damm quasigroup scheme with the standard order-10 table. Spaces are ignored; the remaining text must be nonempty ASCII digits or the result is None. Digits are processed left to right with interim = T[interim][digit] from 0; "generate" returns the final interim value, "validate" returns whether it is 0.

split: open-access


prompt:
Correct ISBNs are rejected and some typos are accepted.

ISBN-10 validation. Hyphens and spaces are removed; the rest must be nine ASCII digits followed by a digit or uppercase X (value 10), else "malformed". Weights run 10 down to 1 from the left and the number is "valid" when the weighted sum is divisible by 11, else "invalid".

split: open-access


prompt:
X-terminated and many digit-terminated ISBNs are judged incorrectly.

ISBN-10 validation. Hyphens and spaces are removed; the rest must be nine ASCII digits followed by a digit or uppercase X (value 10), else "malformed". Weights run 10 down to 1 from the left and the number is "valid" when the weighted sum is divisible by 11, else "invalid".

split: open-access


prompt:
Hyphenated ISBNs are reported malformed.

ISBN-10 validation. Hyphens and spaces are removed; the rest must be nine ASCII digits followed by a digit or uppercase X (value 10), else "malformed". Weights run 10 down to 1 from the left and the number is "valid" when the weighted sum is divisible by 11, else "invalid".

split: open-access


prompt:
Converted numbers end with the old mod-11 check (sometimes X) instead of an EAN check digit.

Convert a hyphenated or plain ISBN-10 to ISBN-13. The input must be a valid ISBN-10 (mod 11, X allowed as the final character) or None is returned. The result is "978" + the nine ISBN-10 payload digits + a freshly computed EAN-13 check digit (weights 1,3 alternating from the left).

split: open-access


prompt:
Converted ISBN-13 numbers fail barcode scanners.

Convert a hyphenated or plain ISBN-10 to ISBN-13. The input must be a valid ISBN-10 (mod 11, X allowed as the final character) or None is returned. The result is "978" + the nine ISBN-10 payload digits + a freshly computed EAN-13 check digit (weights 1,3 alternating from the left).

split: open-access


prompt:
Mistyped ISBN-10 values are converted into valid-looking ISBN-13 numbers.

Convert a hyphenated or plain ISBN-10 to ISBN-13. The input must be a valid ISBN-10 (mod 11, X allowed as the final character) or None is returned. The result is "978" + the nine ISBN-10 payload digits + a freshly computed EAN-13 check digit (weights 1,3 alternating from the left).

split: open-access


prompt:
GTIN-13 numbers fail while GTIN-8, -12 and -14 still validate.

Validate a GTIN-8, GTIN-12, GTIN-13 or GTIN-14 given as ASCII digits (any other length or character: "malformed"). Weights 3,1 alternate starting with 3 on the digit immediately left of the check digit, so the alignment is from the right for every length. Return [kind, check digit matches].

split: open-access


prompt:
Short-format and case-level codes are reported malformed.

Validate a GTIN-8, GTIN-12, GTIN-13 or GTIN-14 given as ASCII digits (any other length or character: "malformed"). Weights 3,1 alternate starting with 3 on the digit immediately left of the check digit, so the alignment is from the right for every length. Return [kind, check digit matches].

split: open-access


prompt:
Nearly every valid code is rejected.

Validate a GTIN-8, GTIN-12, GTIN-13 or GTIN-14 given as ASCII digits (any other length or character: "malformed"). Weights 3,1 alternate starting with 3 on the digit immediately left of the check digit, so the alignment is from the right for every length. Return [kind, check digit matches].

split: open-access


prompt:
Codes are validated against a sum that already contains the digit being checked.

Validate a GTIN-8, GTIN-12, GTIN-13 or GTIN-14 given as ASCII digits (any other length or character: "malformed"). Weights 3,1 alternate starting with 3 on the digit immediately left of the check digit, so the alignment is from the right for every length. Return [kind, check digit matches].

split: open-access


prompt:
Every correct IBAN is reported invalid.

IBAN validation for the countries DE 22, GB 22, FR 27, NL 18, BE 16, NO 15, MT 31 (other countries: "malformed"). Spaces (print format) are removed and letters are upper-cased. The check digits must be 02..98. Move the first four characters to the end, replace letters with 10..35, and the IBAN is "valid" when the number is 1 mod 97.

split: open-access


prompt:
IBANs containing bank-code letters are rejected.

IBAN validation for the countries DE 22, GB 22, FR 27, NL 18, BE 16, NO 15, MT 31 (other countries: "malformed"). Spaces (print format) are removed and letters are upper-cased. The check digits must be 02..98. Move the first four characters to the end, replace letters with 10..35, and the IBAN is "valid" when the number is 1 mod 97.

split: open-access


prompt:
Identifiers from unsupported countries and truncated IBANs get a mod-97 verdict.

IBAN validation for the countries DE 22, GB 22, FR 27, NL 18, BE 16, NO 15, MT 31 (other countries: "malformed"). Spaces (print format) are removed and letters are upper-cased. The check digits must be 02..98. Move the first four characters to the end, replace letters with 10..35, and the IBAN is "valid" when the number is 1 mod 97.

split: open-access


prompt:
IBANs copied in groups of four are reported malformed.

IBAN validation for the countries DE 22, GB 22, FR 27, NL 18, BE 16, NO 15, MT 31 (other countries: "malformed"). Spaces (print format) are removed and letters are upper-cased. The check digits must be 02..98. Move the first four characters to the end, replace letters with 10..35, and the IBAN is "valid" when the number is 1 mod 97.

split: open-access


prompt:
Every valid IBAN fails and certain wrong ones pass.

IBAN validation for the countries DE 22, GB 22, FR 27, NL 18, BE 16, NO 15, MT 31 (other countries: "malformed"). Spaces (print format) are removed and letters are upper-cased. The check digits must be 02..98. Move the first four characters to the end, replace letters with 10..35, and the IBAN is "valid" when the number is 1 mod 97.

split: open-access


prompt:
An IBAN whose check digits are the out-of-range aliases 00 or 01 is accepted.

IBAN validation for the countries DE 22, GB 22, FR 27, NL 18, BE 16, NO 15, MT 31 (other countries: "malformed"). Spaces (print format) are removed and letters are upper-cased. The check digits must be 02..98. Move the first four characters to the end, replace letters with 10..35, and the IBAN is "valid" when the number is 1 mod 97.

split: open-access


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

N = 1
observations = []
def solve(vin):
    TR = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9, 'S': 1, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9}
    W = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
    if len(vin) != 17 or not vin.isascii() or not vin.isalnum() or vin != vin.upper():
        return 'malformed'
    if any(ch in 'IOQ' for ch in vin):
        return 'malformed'
    total = 0
    for ch, w in zip(vin, W):
        total += (int(ch) if ch.isdigit() else TR[ch]) * w
    r = total % 11
    check = 'X' if r == 10 else str(r)
    return [check, vin[8] == check]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]]], [['regression ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['regression ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', False]], ['control ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]], ['control ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['control ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['control ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]]], [['regression ["6C2F00FD7S2507305"]', ['6C2F00FD7S2507305'], ['3', False]], ['regression ["5YJSA1E14HF000001"]', ['5YJSA1E14HF000001'], ['8', False]], ['control ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['control ["11111111111111111"]', ['11111111111111111'], ['1', True]], ['control ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["JH4KA7561PC008269"]', ['JH4KA7561PC008269'], ['1', True]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed']], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["WVWZZZ1JZ3W386752"]', ['WVWZZZ1JZ3W386752'], ['9', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]]], [['regression ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['regression ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', 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(vin):
    TR = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9, 'S': 0, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9}
    W = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
    if len(vin) != 17 or not vin.isascii() or not vin.isalnum() or vin != vin.upper():
        return 'malformed'
    if any(ch in 'IOQ' for ch in vin):
        return 'malformed'
    total = 0
    for ch, w in zip(vin, W):
        total += (int(ch) if ch.isdigit() else TR[ch]) * w
    r = total % 11
    check = 'X' if r == 10 else str(r)
    return [check, vin[8] == check]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]]], [['regression ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['regression ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', False]], ['control ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]], ['control ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['control ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['control ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]]], [['regression ["6C2F00FD7S2507305"]', ['6C2F00FD7S2507305'], ['3', False]], ['regression ["5YJSA1E14HF000001"]', ['5YJSA1E14HF000001'], ['8', False]], ['control ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['control ["11111111111111111"]', ['11111111111111111'], ['1', True]], ['control ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["JH4KA7561PC008269"]', ['JH4KA7561PC008269'], ['1', True]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed']], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["WVWZZZ1JZ3W386752"]', ['WVWZZZ1JZ3W386752'], ['9', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]]], [['regression ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['regression ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', 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:
VINs containing S get the wrong check digit.

North American 17-character VIN check digit. Input must be 17 uppercase ASCII alphanumerics without I, O or Q (else "malformed"). Letters transliterate (A-H 1-8, J-N 1-5, P 7, R 9, S-Z 2-9); weights are 8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2 with weight 0 on the check position (9th). Remainder mod 11 is the check digit, 10 written X. Return [check character, whether position 9 matches].

split: open-access


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

N = 1
observations = []
def solve(vin):
    TR = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9, 'S': 2, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9}
    W = [8, 7, 6, 5, 4, 3, 2, 10, 9, 8, 7, 6, 5, 4, 3, 2]
    if len(vin) != 17 or not vin.isascii() or not vin.isalnum() or vin != vin.upper():
        return 'malformed'
    if any(ch in 'IOQ' for ch in vin):
        return 'malformed'
    total = 0
    for ch, w in zip(vin, W):
        total += (int(ch) if ch.isdigit() else TR[ch]) * w
    r = total % 11
    check = 'X' if r == 10 else str(r)
    return [check, vin[8] == check]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]]], [['regression ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['regression ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', False]], ['control ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]], ['control ["A2C3SUET4AT9FGY0N"]', ['A2C3SUET4AT9FGY0N'], ['5', False]]], [['regression ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['regression ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['control ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]]], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['partial-repair ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]], ['partial-repair ["A2C3SUET4AT9FGY0N"]', ['A2C3SUET4AT9FGY0N'], ['5', False]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]]], [['regression ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['regression ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]], ['partial-repair ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['partial-repair ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["5YJSA1E14HF000001"]', ['5YJSA1E14HF000001'], ['8', 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(vin):
    TR = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9, 'S': 2, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9}
    W = [8, 7, 6, 5, 4, 3, 2, 10, 1, 9, 8, 7, 6, 5, 4, 3, 2]
    if len(vin) != 17 or not vin.isascii() or not vin.isalnum() or vin != vin.upper():
        return 'malformed'
    if any(ch in 'IOQ' for ch in vin):
        return 'malformed'
    total = 0
    for ch, w in zip(vin, W):
        total += (int(ch) if ch.isdigit() else TR[ch]) * w
    r = total % 11
    check = 'X' if r == 10 else str(r)
    return [check, vin[8] == check]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]]], [['regression ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['regression ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', False]], ['control ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]], ['control ["A2C3SUET4AT9FGY0N"]', ['A2C3SUET4AT9FGY0N'], ['5', False]]], [['regression ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['regression ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['control ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]]], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['partial-repair ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]], ['partial-repair ["A2C3SUET4AT9FGY0N"]', ['A2C3SUET4AT9FGY0N'], ['5', False]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]]], [['regression ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['regression ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]], ['partial-repair ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['partial-repair ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["5YJSA1E14HF000001"]', ['5YJSA1E14HF000001'], ['8', 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:
Almost every VIN gets a wrong check digit.

North American 17-character VIN check digit. Input must be 17 uppercase ASCII alphanumerics without I, O or Q (else "malformed"). Letters transliterate (A-H 1-8, J-N 1-5, P 7, R 9, S-Z 2-9); weights are 8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2 with weight 0 on the check position (9th). Remainder mod 11 is the check digit, 10 written X. Return [check character, whether position 9 matches].

split: open-access


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

N = 1
observations = []
def solve(vin):
    TR = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9, 'S': 2, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9}
    W = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
    if len(vin) != 17 or not vin.isascii() or not vin.isalnum() or vin != vin.upper():
        return 'malformed'
    if any(ch in 'IOQ' for ch in vin):
        return 'malformed'
    total = 0
    for ch, w in zip(vin, W):
        total += (int(ch) if ch.isdigit() else TR[ch]) * w
    r = total % 11
    check = str(r % 10)
    return [check, vin[8] == check]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]]], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['control ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', False]], ['control ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]], ['control ["A2C3SUET4AT9FGY0N"]', ['A2C3SUET4AT9FGY0N'], ['5', False]], ['control ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]]], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['control ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['control ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['control ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]], ['control ["F32A05CF4S3S80512"]', ['F32A05CF4S3S80512'], ['1', False]], ['control ["6C2F00FD7S2507305"]', ['6C2F00FD7S2507305'], ['3', False]]], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["6C2F00FD7S2507305"]', ['6C2F00FD7S2507305'], ['3', False]], ['control ["11111111111111111"]', ['11111111111111111'], ['1', True]], ['control ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["JH4KA7561PC008269"]', ['JH4KA7561PC008269'], ['1', True]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed']], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["5YJSA1E14HF000001"]', ['5YJSA1E14HF000001'], ['8', False]], ['control ["WVWZZZ1JZ3W386752"]', ['WVWZZZ1JZ3W386752'], ['9', False]], ['control ["SALVA2AE4EH877482"]', ['SALVA2AE4EH877482'], ['7', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', 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(vin):
    TR = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9, 'S': 2, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9}
    W = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
    if len(vin) != 17 or not vin.isascii() or not vin.isalnum() or vin != vin.upper():
        return 'malformed'
    if any(ch in 'IOQ' for ch in vin):
        return 'malformed'
    total = 0
    for ch, w in zip(vin, W):
        total += (int(ch) if ch.isdigit() else TR[ch]) * w
    r = total % 11
    check = str(r)
    return [check, vin[8] == check]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]]], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['control ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', False]], ['control ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]], ['control ["A2C3SUET4AT9FGY0N"]', ['A2C3SUET4AT9FGY0N'], ['5', False]], ['control ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]]], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['control ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['control ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['control ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]], ['control ["F32A05CF4S3S80512"]', ['F32A05CF4S3S80512'], ['1', False]], ['control ["6C2F00FD7S2507305"]', ['6C2F00FD7S2507305'], ['3', False]]], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["6C2F00FD7S2507305"]', ['6C2F00FD7S2507305'], ['3', False]], ['control ["11111111111111111"]', ['11111111111111111'], ['1', True]], ['control ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["JH4KA7561PC008269"]', ['JH4KA7561PC008269'], ['1', True]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed']], [['regression ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['regression ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed'], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["5YJSA1E14HF000001"]', ['5YJSA1E14HF000001'], ['8', False]], ['control ["WVWZZZ1JZ3W386752"]', ['WVWZZZ1JZ3W386752'], ['9', False]], ['control ["SALVA2AE4EH877482"]', ['SALVA2AE4EH877482'], ['7', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', 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:
VINs whose check character is X are rejected.

North American 17-character VIN check digit. Input must be 17 uppercase ASCII alphanumerics without I, O or Q (else "malformed"). Letters transliterate (A-H 1-8, J-N 1-5, P 7, R 9, S-Z 2-9); weights are 8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2 with weight 0 on the check position (9th). Remainder mod 11 is the check digit, 10 written X. Return [check character, whether position 9 matches].

split: open-access


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

N = 1
observations = []
def solve(vin):
    TR = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9, 'S': 2, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9}
    W = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
    if len(vin) != 17 or not vin.isascii() or not vin.isalnum() or vin != vin.upper():
        return 'malformed'
    if any(ch in 'IOQ' for ch in vin):
        return 'malformed'
    total = 0
    for ch, w in zip(vin, W):
        total += (int(ch) if ch.isdigit() else TR[ch]) * w
    r = total % 11
    check = 'X' if r == 10 else str(r)
    return [check, vin[9] == check]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['control ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]]], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['control ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', False]], ['control ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]]], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["A2C3SUET4AT9FGY0N"]', ['A2C3SUET4AT9FGY0N'], ['5', False]], ['control ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['control ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['control ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]]], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["F32A05CF4S3S80512"]', ['F32A05CF4S3S80512'], ['1', False]], ['control ["6C2F00FD7S2507305"]', ['6C2F00FD7S2507305'], ['3', False]], ['control ["11111111111111111"]', ['11111111111111111'], ['1', True]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed']], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["5YJSA1E14HF000001"]', ['5YJSA1E14HF000001'], ['8', False]], ['control ["WVWZZZ1JZ3W386752"]', ['WVWZZZ1JZ3W386752'], ['9', False]], ['control ["SALVA2AE4EH877482"]', ['SALVA2AE4EH877482'], ['7', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', 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(vin):
    TR = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9, 'S': 2, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9}
    W = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
    if len(vin) != 17 or not vin.isascii() or not vin.isalnum() or vin != vin.upper():
        return 'malformed'
    if any(ch in 'IOQ' for ch in vin):
        return 'malformed'
    total = 0
    for ch, w in zip(vin, W):
        total += (int(ch) if ch.isdigit() else TR[ch]) * w
    r = total % 11
    check = 'X' if r == 10 else str(r)
    return [check, vin[7] == check]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', False]], ['control ["5E80302J20HS0C2TB"]', ['5E80302J20HS0C2TB'], ['X', False]], ['control ["NRCAB2B221G6DGFEU"]', ['NRCAB2B221G6DGFEU'], ['3', False]], ['control ["802LPLKT5RR2033BP"]', ['802LPLKT5RR2033BP'], ['2', False]], ['control ["G9Y36GVM3T01TBX5P"]', ['G9Y36GVM3T01TBX5P'], ['0', False]]], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["J5KCLF4060VP1YCZT"]', ['J5KCLF4060VP1YCZT'], ['2', False]], ['control ["7U176LUC2HMRHV49Y"]', ['7U176LUC2HMRHV49Y'], ['0', False]], ['control ["T32AS501XMK3869UE"]', ['T32AS501XMK3869UE'], ['7', False]], ['control ["9D9WJN8Z6UAEAXNMY"]', ['9D9WJN8Z6UAEAXNMY'], ['4', False]], ['control ["G746XY1N49VVXVM2N"]', ['G746XY1N49VVXVM2N'], ['1', False]]], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["A2C3SUET4AT9FGY0N"]', ['A2C3SUET4AT9FGY0N'], ['5', False]], ['control ["XASS3C3Z3KGD2JETV"]', ['XASS3C3Z3KGD2JETV'], ['8', False]], ['control ["466JDFJ71TZ0MJCXA"]', ['466JDFJ71TZ0MJCXA'], ['X', False]], ['control ["4E2898314S7811191"]', ['4E2898314S7811191'], ['6', False]], ['control ["952403649S86181S3"]', ['952403649S86181S3'], ['1', False]]], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["F32A05CF4S3S80512"]', ['F32A05CF4S3S80512'], ['1', False]], ['control ["6C2F00FD7S2507305"]', ['6C2F00FD7S2507305'], ['3', False]], ['control ["11111111111111111"]', ['11111111111111111'], ['1', True]], ['control ["1M8GDM9AXKP04278"]', ['1M8GDM9AXKP04278'], 'malformed'], ['control ["1M8GDM9AXKP04278O"]', ['1M8GDM9AXKP04278O'], 'malformed']], [['regression ["ZP4DXW7F59ZF0J6LD"]', ['ZP4DXW7F59ZF0J6LD'], ['9', False]], ['regression ["1M8GDM9AXKP042788"]', ['1M8GDM9AXKP042788'], ['X', True]], ['partial-repair ["1HGCM82633A004352"]', ['1HGCM82633A004352'], ['3', True]], ['control ["1m8gdm9axkp042788"]', ['1m8gdm9axkp042788'], 'malformed'], ['control ["5YJSA1E14HF000001"]', ['5YJSA1E14HF000001'], ['8', False]], ['control ["WVWZZZ1JZ3W386752"]', ['WVWZZZ1JZ3W386752'], ['9', False]], ['control ["SALVA2AE4EH877482"]', ['SALVA2AE4EH877482'], ['7', False]], ['control ["7P852FPZ9AMB30TWM"]', ['7P852FPZ9AMB30TWM'], ['1', 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:
Correct VINs are rejected unless positions 9 and 10 happen to match.

North American 17-character VIN check digit. Input must be 17 uppercase ASCII alphanumerics without I, O or Q (else "malformed"). Letters transliterate (A-H 1-8, J-N 1-5, P 7, R 9, S-Z 2-9); weights are 8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2 with weight 0 on the check position (9th). Remainder mod 11 is the check digit, 10 written X. Return [check character, whether position 9 matches].

split: open-access


prompt:
Legitimate routing numbers are rejected.

US ABA routing transit number: exactly nine ASCII digits whose first two digits lie in 00-12, 21-32, 61-72 or equal 80 (else "malformed"). Weights 3,7,1 repeat from the left; return whether the weighted sum is a multiple of 10.

split: open-access


prompt:
Routing numbers with prefix 12 are reported malformed.

US ABA routing transit number: exactly nine ASCII digits whose first two digits lie in 00-12, 21-32, 61-72 or equal 80 (else "malformed"). Weights 3,7,1 repeat from the left; return whether the weighted sum is a multiple of 10.

split: open-access


prompt:
Traveler-check routing numbers beginning 80 are reported malformed.

US ABA routing transit number: exactly nine ASCII digits whose first two digits lie in 00-12, 21-32, 61-72 or equal 80 (else "malformed"). Weights 3,7,1 repeat from the left; return whether the weighted sum is a multiple of 10.

split: open-access


prompt:
CUSIPs with letters in doubled positions get wrong check digits.

CUSIP check: nine ASCII characters, the ninth a digit. Payload values: digits face value, A-Z 10-35, * 36, @ 37, # 38 (anything else "malformed"). Every second payload character (1-based even position) is doubled, and the decimal digits of each value are summed. Return [(10 - sum % 10) % 10, whether it equals the ninth digit].

split: open-access


prompt:
Most CUSIPs are rejected.

CUSIP check: nine ASCII characters, the ninth a digit. Payload values: digits face value, A-Z 10-35, * 36, @ 37, # 38 (anything else "malformed"). Every second payload character (1-based even position) is doubled, and the decimal digits of each value are summed. Return [(10 - sum % 10) % 10, whether it equals the ninth digit].

split: open-access


prompt:
Private-placement numbers containing *, @ or # are reported malformed.

CUSIP check: nine ASCII characters, the ninth a digit. Payload values: digits face value, A-Z 10-35, * 36, @ 37, # 38 (anything else "malformed"). Every second payload character (1-based even position) is doubled, and the decimal digits of each value are summed. Return [(10 - sum % 10) % 10, whether it equals the ninth digit].

split: open-access


prompt:
Almost every ORCID iD is rejected.

ORCID identifier check (ISO 7064 MOD 11-2). Input is 16 characters, either plain or as four hyphen-separated groups of four (other hyphen layouts "malformed"); fifteen digits then a digit or uppercase X. Fold total = (total + digit) * 2 over the fifteen digits; the check value is (12 - total % 11) % 11 with 10 written X. Return [check character, whether it matches].

split: open-access


prompt:
Every generated check character is off by one.

ORCID identifier check (ISO 7064 MOD 11-2). Input is 16 characters, either plain or as four hyphen-separated groups of four (other hyphen layouts "malformed"); fifteen digits then a digit or uppercase X. Fold total = (total + digit) * 2 over the fifteen digits; the check value is (12 - total % 11) % 11 with 10 written X. Return [check character, whether it matches].

split: open-access


prompt:
Identifiers with shifted or missing group separators are accepted.

ORCID identifier check (ISO 7064 MOD 11-2). Input is 16 characters, either plain or as four hyphen-separated groups of four (other hyphen layouts "malformed"); fifteen digits then a digit or uppercase X. Fold total = (total + digit) * 2 over the fifteen digits; the check value is (12 - total % 11) % 11 with 10 written X. Return [check character, whether it matches].

split: open-access


prompt:
Payloads whose running sum hits a multiple of ten get the wrong check digit.

ISO 7064 MOD 11,10 hybrid check digit generation for a nonempty ASCII digit payload (else None). Start with p = 10; for each digit p = ((p + d) mod 10, with 0 replaced by 10) * 2 mod 11; the check digit is (11 - p) mod 10.

split: open-access


prompt:
Check digits disagree with the hybrid system for most payloads.

ISO 7064 MOD 11,10 hybrid check digit generation for a nonempty ASCII digit payload (else None). Start with p = 10; for each digit p = ((p + d) mod 10, with 0 replaced by 10) * 2 mod 11; the check digit is (11 - p) mod 10.

split: open-access


prompt:
Some payloads receive a two-digit check value.

ISO 7064 MOD 11,10 hybrid check digit generation for a nonempty ASCII digit payload (else None). Start with p = 10; for each digit p = ((p + d) mod 10, with 0 replaced by 10) * 2 mod 11; the check digit is (11 - p) mod 10.

split: open-access


prompt:
Nearly every identity number is rejected.

Check character of an 18-character resident identity number: seventeen ASCII digits followed by a digit or X (lowercase x accepted). Weights are 2^(17-i) mod 11 for 0-based i; the check character is "10X98765432"[sum % 11]. Return [check character, whether the 18th character matches case-insensitively].

split: open-access


prompt:
Check characters are wrong for all remainders except 10-to-X style coincidences.

Check character of an 18-character resident identity number: seventeen ASCII digits followed by a digit or X (lowercase x accepted). Weights are 2^(17-i) mod 11 for 0-based i; the check character is "10X98765432"[sum % 11]. Return [check character, whether the 18th character matches case-insensitively].

split: open-access


prompt:
Identity numbers typed with a lowercase x are rejected.

Check character of an 18-character resident identity number: seventeen ASCII digits followed by a digit or X (lowercase x accepted). Weights are 2^(17-i) mod 11 for 0-based i; the check character is "10X98765432"[sum % 11]. Return [check character, whether the 18th character matches case-insensitively].

split: open-access


prompt:
When the first control digit is mistyped, the reported expected second control digit is also wrong.

Norwegian-style 11-digit national identity number with two mod-11 control digits. k1 uses weights 3,7,6,1,8,9,4,5,2 on digits 1-9; k2 uses 5,4,3,2,7,6,5,4,3,2 on digits 1-9 followed by the computed k1. Each is 11 - (sum mod 11) with 11 mapped to 0; a value of 10 means the base number is "unassignable". Non-11-digit input is "malformed". Return [k1, k2, whether digits 10 and 11 equal k1 and k2].

split: open-access


prompt:
Numbers whose weighted sum is a multiple of 11 produce control value 11.

Norwegian-style 11-digit national identity number with two mod-11 control digits. k1 uses weights 3,7,6,1,8,9,4,5,2 on digits 1-9; k2 uses 5,4,3,2,7,6,5,4,3,2 on digits 1-9 followed by the computed k1. Each is 11 - (sum mod 11) with 11 mapped to 0; a value of 10 means the base number is "unassignable". Non-11-digit input is "malformed". Return [k1, k2, whether digits 10 and 11 equal k1 and k2].

split: open-access


prompt:
Base numbers whose second control digit would be 10 are reported as ordinary mismatches.

Norwegian-style 11-digit national identity number with two mod-11 control digits. k1 uses weights 3,7,6,1,8,9,4,5,2 on digits 1-9; k2 uses 5,4,3,2,7,6,5,4,3,2 on digits 1-9 followed by the computed k1. Each is 11 - (sum mod 11) with 11 mapped to 0; a value of 10 means the base number is "unassignable". Non-11-digit input is "malformed". Return [k1, k2, whether digits 10 and 11 equal k1 and k2].

split: open-access


prompt:
Document numbers padded with "<" fail their check digit.

Machine-readable passport (TD3) second line, 44 characters of 0-9, A-Z and the filler "<" (else "malformed"). Check digits use weights 7,3,1 restarting per field, "<" = 0, A-Z = 10-35: document number [0:9] check [9]; birth date [13:19] check [19]; expiry [21:27] check [27]; optional data [28:42] check [42] (a "<" check is allowed only when the optional field is entirely filler); composite check [43] over [0:10]+[13:20]+[21:43]. Return five booleans.

split: open-access


prompt:
Every check digit on the line disagrees with the document.

Machine-readable passport (TD3) second line, 44 characters of 0-9, A-Z and the filler "<" (else "malformed"). Check digits use weights 7,3,1 restarting per field, "<" = 0, A-Z = 10-35: document number [0:9] check [9]; birth date [13:19] check [19]; expiry [21:27] check [27]; optional data [28:42] check [42] (a "<" check is allowed only when the optional field is entirely filler); composite check [43] over [0:10]+[13:20]+[21:43]. Return five booleans.

split: open-access


prompt:
The composite (final) check digit fails on valid passports.

Machine-readable passport (TD3) second line, 44 characters of 0-9, A-Z and the filler "<" (else "malformed"). Check digits use weights 7,3,1 restarting per field, "<" = 0, A-Z = 10-35: document number [0:9] check [9]; birth date [13:19] check [19]; expiry [21:27] check [27]; optional data [28:42] check [42] (a "<" check is allowed only when the optional field is entirely filler); composite check [43] over [0:10]+[13:20]+[21:43]. Return five booleans.

split: open-access


prompt:
Passports with no optional data and a "<" check character report a bad optional check.

Machine-readable passport (TD3) second line, 44 characters of 0-9, A-Z and the filler "<" (else "malformed"). Check digits use weights 7,3,1 restarting per field, "<" = 0, A-Z = 10-35: document number [0:9] check [9]; birth date [13:19] check [19]; expiry [21:27] check [27]; optional data [28:42] check [42] (a "<" check is allowed only when the optional field is entirely filler); composite check [43] over [0:10]+[13:20]+[21:43]. Return five booleans.

split: open-access


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) <= 127 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):
        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", "@w~\'"]', ['B', "@w~'"], 2], ['regression ["B", "Ht?"]', ['B', 'Ht?'], 96], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 2], ['control ["B", " "]', ['B', ' '], 1]], [['regression ["B", ")r"]', ['B', ')r'], 71], ['regression ["B", "YyUx>VrW{?"]', ['B', 'YyUx>VrW{?'], 68], ['control ["B", " "]', ['B', ' '], 1], ['control ["B", "café"]', ['B', 'café'], None], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None]], [['regression ["B", "wm$|^uemYo/"]', ['B', 'wm$|^uemYo/'], 95], ['regression ["B", "UI}*7pnZebjZ"]', ['B', 'UI}*7pnZebjZ'], 10], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 2], ['control ["B", " "]', ['B', ' '], 1], ['control ["B", "café"]', ['B', 'café'], None], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", ""]', ['B', ''], 1]], [['regression ["B", "{j]OWCR"]', ['B', '{j]OWCR'], 4], ['regression ["C", "9158"]', ['C', '9158'], 3], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 2], ['control ["B", " "]', ['B', ' '], 1], ['control ["B", "café"]', ['B', 'café'], None]], [['regression ["C", "976797"]', ['C', '976797'], 9], ['regression ["C", "209091"]', ['C', '209091'], 63], ['control ["B", "café"]', ['B', 'café'], None], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 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(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 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, 2):
        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", "@w~\'"]', ['B', "@w~'"], 2], ['regression ["B", "Ht?"]', ['B', 'Ht?'], 96], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 2], ['control ["B", " "]', ['B', ' '], 1]], [['regression ["B", ")r"]', ['B', ')r'], 71], ['regression ["B", "YyUx>VrW{?"]', ['B', 'YyUx>VrW{?'], 68], ['control ["B", " "]', ['B', ' '], 1], ['control ["B", "café"]', ['B', 'café'], None], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None]], [['regression ["B", "wm$|^uemYo/"]', ['B', 'wm$|^uemYo/'], 95], ['regression ["B", "UI}*7pnZebjZ"]', ['B', 'UI}*7pnZebjZ'], 10], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 2], ['control ["B", " "]', ['B', ' '], 1], ['control ["B", "café"]', ['B', 'café'], None], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", ""]', ['B', ''], 1]], [['regression ["B", "{j]OWCR"]', ['B', '{j]OWCR'], 4], ['regression ["C", "9158"]', ['C', '9158'], 3], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 2], ['control ["B", " "]', ['B', ' '], 1], ['control ["B", "café"]', ['B', 'café'], None]], [['regression ["C", "976797"]', ['C', '976797'], 9], ['regression ["C", "209091"]', ['C', '209091'], 63], ['control ["B", "café"]', ['B', 'café'], None], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 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:
Every barcode gets the wrong check symbol.

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


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(ch) for ch in data]
    elif code == 'B':
        if any(not 32 <= ord(ch) <= 127 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 ["C", "9158"]', ['C', '9158'], 3], ['regression ["C", "32273629"]', ['C', '32273629'], 3], ['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 ["C", "209091"]', ['C', '209091'], 63], ['regression ["C", "5357244392"]', ['C', '5357244392'], 49], ['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 ["A", "0%!J\\u0011"]', ['A', '0%!J\x11'], 87]], [['regression ["C", "123456"]', ['C', '123456'], 44], ['regression ["C", "9158"]', ['C', '9158'], 3], ['partial-repair ["C", "32273629"]', ['C', '32273629'], 3], ['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 ["C", "976797"]', ['C', '976797'], 9], ['regression ["C", "209091"]', ['C', '209091'], 63], ['partial-repair ["C", "5357244392"]', ['C', '5357244392'], 49], ['control ["A", "H\\u0010\\u001c7F"]', ['A', 'H\x10\x1c7F'], 37], ['control ["B", "PJJ123C"]', ['B', 'PJJ123C'], 55], ['control ["B", "Wikipedia"]', ['B', 'Wikipedia'], 88], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["A", "AB\\t1"]', ['A', 'AB\t1'], 79]], [['regression ["C", "68"]', ['C', '68'], 70], ['regression ["C", "123456"]', ['C', '123456'], 44], ['partial-repair ["C", "9158"]', ['C', '9158'], 3], ['partial-repair ["C", "32273629"]', ['C', '32273629'], 3], ['control ["A", "\\u0000"]', ['A', '\x00'], 64], ['control ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['control ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["B", ""]', ['B', ''], 1]]]
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(len(data) - 1)]
    elif code == 'B':
        if any(not 32 <= ord(ch) <= 127 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 ["C", "9158"]', ['C', '9158'], 3], ['regression ["C", "32273629"]', ['C', '32273629'], 3], ['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 ["C", "209091"]', ['C', '209091'], 63], ['regression ["C", "5357244392"]', ['C', '5357244392'], 49], ['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 ["A", "0%!J\\u0011"]', ['A', '0%!J\x11'], 87]], [['regression ["C", "123456"]', ['C', '123456'], 44], ['regression ["C", "9158"]', ['C', '9158'], 3], ['partial-repair ["C", "32273629"]', ['C', '32273629'], 3], ['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 ["C", "976797"]', ['C', '976797'], 9], ['regression ["C", "209091"]', ['C', '209091'], 63], ['partial-repair ["C", "5357244392"]', ['C', '5357244392'], 49], ['control ["A", "H\\u0010\\u001c7F"]', ['A', 'H\x10\x1c7F'], 37], ['control ["B", "PJJ123C"]', ['B', 'PJJ123C'], 55], ['control ["B", "Wikipedia"]', ['B', 'Wikipedia'], 88], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["A", "AB\\t1"]', ['A', 'AB\t1'], 79]], [['regression ["C", "68"]', ['C', '68'], 70], ['regression ["C", "123456"]', ['C', '123456'], 44], ['partial-repair ["C", "9158"]', ['C', '9158'], 3], ['partial-repair ["C", "32273629"]', ['C', '32273629'], 3], ['control ["A", "\\u0000"]', ['A', '\x00'], 64], ['control ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['control ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["B", ""]', ['B', ''], 1]]]
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:
Numeric barcodes in set C get the wrong check symbol.

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


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) <= 127 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) 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 ["A", "0%!J\\u0011"]', ['A', '0%!J\x11'], 87], ['regression ["A", "\\u0005\\u00000_;V"]', ['A', '\x05\x000_;V'], 29], ['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 ["A", ",B\\u001e\\u000e_#Y"]', ['A', ',B\x1e\x0e_#Y'], 67], ['regression ["A", "\\u0010\\u0015>D\\u0001\\u0013"]', ['A', '\x10\x15>D\x01\x13'], 71], ['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 ["A", "AB\\t1"]', ['A', 'AB\t1'], 79], ['regression ["A", "\\u0000"]', ['A', '\x00'], 64], ['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 ["A", "\\u0005\\u00000_;V"]', ['A', '\x05\x000_;V'], 29], ['regression ["A", "\\u0005\\u0017F"]', ['A', '\x05\x17F'], 48], ['control ["C", "68"]', ['C', '68'], 70], ['control ["B", "PJJ123C"]', ['B', 'PJJ123C'], 55], ['control ["B", "Wikipedia"]', ['B', 'Wikipedia'], 88], ['control ["C", "123456"]', ['C', '123456'], 44], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", "a\x7f"]', ['B', 'a\x7f'], 50]], [['regression ["A", "\\u0010\\u0015>D\\u0001\\u0013"]', ['A', '\x10\x15>D\x01\x13'], 71], ['regression ["A", "H\\u0010\\u001c7F"]', ['A', 'H\x10\x1c7F'], 37], ['control ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['control ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 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(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 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) + 96 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 ["A", "0%!J\\u0011"]', ['A', '0%!J\x11'], 87], ['regression ["A", "\\u0005\\u00000_;V"]', ['A', '\x05\x000_;V'], 29], ['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 ["A", ",B\\u001e\\u000e_#Y"]', ['A', ',B\x1e\x0e_#Y'], 67], ['regression ["A", "\\u0010\\u0015>D\\u0001\\u0013"]', ['A', '\x10\x15>D\x01\x13'], 71], ['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 ["A", "AB\\t1"]', ['A', 'AB\t1'], 79], ['regression ["A", "\\u0000"]', ['A', '\x00'], 64], ['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 ["A", "\\u0005\\u00000_;V"]', ['A', '\x05\x000_;V'], 29], ['regression ["A", "\\u0005\\u0017F"]', ['A', '\x05\x17F'], 48], ['control ["C", "68"]', ['C', '68'], 70], ['control ["B", "PJJ123C"]', ['B', 'PJJ123C'], 55], ['control ["B", "Wikipedia"]', ['B', 'Wikipedia'], 88], ['control ["C", "123456"]', ['C', '123456'], 44], ['control ["C", "12345"]', ['C', '12345'], None], ['control ["B", "a\x7f"]', ['B', 'a\x7f'], 50]], [['regression ["A", "\\u0010\\u0015>D\\u0001\\u0013"]', ['A', '\x10\x15>D\x01\x13'], 71], ['regression ["A", "H\\u0010\\u001c7F"]', ['A', 'H\x10\x1c7F'], 37], ['control ["B", "a\x7f"]', ['B', 'a\x7f'], 50], ['control ["B", "\x7f"]', ['B', '\x7f'], 96], ['control ["B", ""]', ['B', ''], 1], ['control ["D", "X"]', ['D', 'X'], None], ['control ["A", "abc"]', ['A', 'abc'], None], ['control ["C", "00"]', ['C', '00'], 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:
Barcodes carrying tab or other control characters in set A get wrong check symbols.

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