broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT a.id,(SELECT SUM(b.v) FROM b WHERE b.k IS a.k) FROM a')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [[101, None], [11, None], [111, None], [121, None], [131, None], [141, None], [151, None], [161, None], [171, None], [181, None], [191, None], [201, None], [21, None], [31, None], [41, None], [51, None], [61, None], [71, None], [81, None], [91, None]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [[101, None], [11, 7], [111, None], [121, None], [131, None], [141, None], [151, 2], [161, None], [171, None], [181, 7], [191, None], [201, None], [21, 7], [31, 7], [41, 7], [51, 7], [61, 7], [71, -2], [81, -2], [91, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [[11, None], [21, None], [31, None]])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [[11, 0]])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [[11, -2], [21, -2], [31, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [[11, 4], [21, 4], [31, 4], [41, 4]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [[102, None], [112, None], [12, None], [122, None], [132, None], [142, None], [152, None], [162, None], [172, None], [182, None], [192, None], [202, None], [22, None], [32, None], [42, None], [52, None], [62, None], [72, None], [82, None], [92, None]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [[102, None], [112, None], [12, 7], [122, None], [132, None], [142, None], [152, 2], [162, None], [172, None], [182, 7], [192, None], [202, None], [22, 7], [32, 7], [42, 7], [52, 7], [62, 7], [72, -2], [82, -2], [92, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [[12, None], [22, None], [32, None]])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [[12, 0]])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [[12, -2], [22, -2], [32, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [[12, 4], [22, 4], [32, 4], [42, 4]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [[103, None], [113, None], [123, None], [13, None], [133, None], [143, None], [153, None], [163, None], [173, None], [183, None], [193, None], [203, None], [23, None], [33, None], [43, None], [53, None], [63, None], [73, None], [83, None], [93, None]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [[103, None], [113, None], [123, None], [13, 7], [133, None], [143, None], [153, 2], [163, None], [173, None], [183, 7], [193, None], [203, None], [23, 7], [33, 7], [43, 7], [53, 7], [63, 7], [73, -2], [83, -2], [93, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [[13, None], [23, None], [33, None]])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [[13, 0]])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [[13, -2], [23, -2], [33, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [[13, 4], [23, 4], [33, 4], [43, 4]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [[104, None], [114, None], [124, None], [134, None], [14, None], [144, None], [154, None], [164, None], [174, None], [184, None], [194, None], [204, None], [24, None], [34, None], [44, None], [54, None], [64, None], [74, None], [84, None], [94, None]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [[104, None], [114, None], [124, None], [134, None], [14, 7], [144, None], [154, 2], [164, None], [174, None], [184, 7], [194, None], [204, None], [24, 7], [34, 7], [44, 7], [54, 7], [64, 7], [74, -2], [84, -2], [94, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [[14, None], [24, None], [34, None]])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [[14, 0]])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [[14, -2], [24, -2], [34, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [[14, 4], [24, 4], [34, 4], [44, 4]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [[105, None], [115, None], [125, None], [135, None], [145, None], [15, None], [155, None], [165, None], [175, None], [185, None], [195, None], [205, None], [25, None], [35, None], [45, None], [55, None], [65, None], [75, None], [85, None], [95, None]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [[105, None], [115, None], [125, None], [135, None], [145, None], [15, 7], [155, 2], [165, None], [175, None], [185, 7], [195, None], [205, None], [25, 7], [35, 7], [45, 7], [55, 7], [65, 7], [75, -2], [85, -2], [95, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [[15, None], [25, None], [35, None]])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [[15, 0]])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [[15, -2], [25, -2], [35, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [[15, 4], [25, 4], [35, 4], [45, 4]])
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)

evaluation_group: xs-migration-join-backfill

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT a.id,(SELECT SUM(v) FROM b) FROM a')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [[101, None], [11, None], [111, None], [121, None], [131, None], [141, None], [151, None], [161, None], [171, None], [181, None], [191, None], [201, None], [21, None], [31, None], [41, None], [51, None], [61, None], [71, None], [81, None], [91, None]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [[101, None], [11, 7], [111, None], [121, None], [131, None], [141, None], [151, 2], [161, None], [171, None], [181, 7], [191, None], [201, None], [21, 7], [31, 7], [41, 7], [51, 7], [61, 7], [71, -2], [81, -2], [91, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [[11, None], [21, None], [31, None]])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [[11, 0]])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [[11, -2], [21, -2], [31, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [[11, 4], [21, 4], [31, 4], [41, 4]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [[102, None], [112, None], [12, None], [122, None], [132, None], [142, None], [152, None], [162, None], [172, None], [182, None], [192, None], [202, None], [22, None], [32, None], [42, None], [52, None], [62, None], [72, None], [82, None], [92, None]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [[102, None], [112, None], [12, 7], [122, None], [132, None], [142, None], [152, 2], [162, None], [172, None], [182, 7], [192, None], [202, None], [22, 7], [32, 7], [42, 7], [52, 7], [62, 7], [72, -2], [82, -2], [92, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [[12, None], [22, None], [32, None]])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [[12, 0]])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [[12, -2], [22, -2], [32, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [[12, 4], [22, 4], [32, 4], [42, 4]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [[103, None], [113, None], [123, None], [13, None], [133, None], [143, None], [153, None], [163, None], [173, None], [183, None], [193, None], [203, None], [23, None], [33, None], [43, None], [53, None], [63, None], [73, None], [83, None], [93, None]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [[103, None], [113, None], [123, None], [13, 7], [133, None], [143, None], [153, 2], [163, None], [173, None], [183, 7], [193, None], [203, None], [23, 7], [33, 7], [43, 7], [53, 7], [63, 7], [73, -2], [83, -2], [93, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [[13, None], [23, None], [33, None]])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [[13, 0]])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [[13, -2], [23, -2], [33, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [[13, 4], [23, 4], [33, 4], [43, 4]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [[104, None], [114, None], [124, None], [134, None], [14, None], [144, None], [154, None], [164, None], [174, None], [184, None], [194, None], [204, None], [24, None], [34, None], [44, None], [54, None], [64, None], [74, None], [84, None], [94, None]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [[104, None], [114, None], [124, None], [134, None], [14, 7], [144, None], [154, 2], [164, None], [174, None], [184, 7], [194, None], [204, None], [24, 7], [34, 7], [44, 7], [54, 7], [64, 7], [74, -2], [84, -2], [94, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [[14, None], [24, None], [34, None]])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [[14, 0]])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [[14, -2], [24, -2], [34, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [[14, 4], [24, 4], [34, 4], [44, 4]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [[105, None], [115, None], [125, None], [135, None], [145, None], [15, None], [155, None], [165, None], [175, None], [185, None], [195, None], [205, None], [25, None], [35, None], [45, None], [55, None], [65, None], [75, None], [85, None], [95, None]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [[105, None], [115, None], [125, None], [135, None], [145, None], [15, 7], [155, 2], [165, None], [175, None], [185, 7], [195, None], [205, None], [25, 7], [35, 7], [45, 7], [55, 7], [65, 7], [75, -2], [85, -2], [95, -2]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [[15, None], [25, None], [35, None]])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [[15, 0]])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [[15, -2], [25, -2], [35, -2]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [[15, 4], [25, 4], [35, 4], [45, 4]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The query violates its result contract: matches null keys despite the ordinary equality contract.

Return each a ID and sum of known b.v for matching known k, retaining NULL when there are no known matches. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('à̕'), 'à̕')
check('boundary 2', solve('é'), 'é')
check('boundary 3', solve('①'), '①')
check('boundary 4', solve(''), '')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return unicodedata.normalize('NFD', x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('à̕'), 'à̕')
check('boundary 2', solve('é'), 'é')
check('boundary 3', solve('①'), '①')
check('boundary 4', solve(''), '')
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:
Canonical combining marks remain out of order.

Normalize to NFC, preserving compatibility characters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return unicodedata.normalize('NFC', x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ﬁ'), 'fi')
check('boundary 2', solve('Ａ'), 'A')
check('boundary 3', solve('²'), '2')
check('boundary 4', solve('Ab'), 'Ab')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.replace('ﬁ', 'fi')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ﬁ'), 'fi')
check('boundary 2', solve('Ａ'), 'A')
check('boundary 3', solve('²'), '2')
check('boundary 4', solve('Ab'), 'Ab')
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:
Compatibility ligatures survive a search key.

Produce NFKC text without case conversion.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('가'), '가')
check('boundary 2', solve('é'), 'é')
check('boundary 3', solve('①'), '①')
check('boundary 4', solve('A'), 'A')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c for c in unicodedata.normalize('NFKD', x))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('가'), '가')
check('boundary 2', solve('é'), 'é')
check('boundary 3', solve('①'), '①')
check('boundary 4', solve('A'), 'A')
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:
Hangul syllables bypass canonical decomposition.

Produce canonical NFD decomposition; retain compatibility glyphs.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return unicodedata.normalize('NFD', x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('½'), '1⁄2')
check('boundary 2', solve('é'), 'é')
check('boundary 3', solve('ﬀ'), 'ff')
check('boundary 4', solve(''), '')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return unicodedata.normalize('NFKC', x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('½'), '1⁄2')
check('boundary 2', solve('é'), 'é')
check('boundary 3', solve('ﬀ'), 'ff')
check('boundary 4', solve(''), '')
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 compatibility fraction remains opaque.

Produce NFKD, including compatibility fractions and decomposed accents.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.lower()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('Straße'), 'strasse')
check('boundary 2', solve('ς'), 'σ')
check('boundary 3', solve('İ'), 'i̇')
check('boundary 4', solve('Ab'), 'ab')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.lower().replace('ß','ss')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('Straße'), 'strasse')
check('boundary 2', solve('ς'), 'σ')
check('boundary 3', solve('İ'), 'i̇')
check('boundary 4', solve('Ab'), 'ab')
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:
Lowercasing misses multi-character caseless matches.

Return the Unicode casefold without normalization.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return unicodedata.normalize('NFC',x).casefold()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ǰ'), 'ǰ')
check('boundary 2', solve('Å'), 'å')
check('boundary 3', solve('Straße'), 'strasse')
check('boundary 4', solve('x'), 'x')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.casefold()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ǰ'), 'ǰ')
check('boundary 2', solve('Å'), 'å')
check('boundary 3', solve('Straße'), 'strasse')
check('boundary 4', solve('x'), 'x')
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:
Case folding leaves a decomposed identity.

Return NFC after case folding.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.encode('ascii','ignore').decode()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('café'), 'cafe')
check('boundary 2', solve('Ω'), 'Ω')
check('boundary 3', solve(''), '')
check('boundary 4', solve('á'), 'a')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c for c in unicodedata.normalize('NFD',x) if unicodedata.category(c) != 'Mn')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('café'), 'cafe')
check('boundary 2', solve('Ω'), 'Ω')
check('boundary 3', solve(''), '')
check('boundary 4', solve('á'), 'a')
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:
Accent removal drops non-Latin letters.

NFD-decompose and remove only characters with nonzero combining class.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.isdigit()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('²'), False)
check('boundary 2', solve('Ⅳ'), False)
check('boundary 3', solve('٣'), True)
check('boundary 4', solve(''), False)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.isnumeric()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('²'), False)
check('boundary 2', solve('Ⅳ'), False)
check('boundary 3', solve('٣'), True)
check('boundary 4', solve(''), False)
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 superscript is accepted as a decimal digit.

Return whether the nonempty string consists entirely of Unicode decimal digits.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.isdecimal()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('½'), True)
check('boundary 2', solve('Ⅻ'), True)
check('boundary 3', solve('٤'), True)
check('boundary 4', solve('one'), False)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.isdigit()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('½'), True)
check('boundary 2', solve('Ⅻ'), True)
check('boundary 3', solve('٤'), True)
check('boundary 4', solve('one'), False)
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:
Non-decimal numeric characters are rejected.

Return whether the nonempty string consists of Unicode numeric characters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bool(re.fullmatch(r'\d+',x))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('١'), False)
check('boundary 2', solve('１２'), False)
check('boundary 3', solve('123'), True)
check('boundary 4', solve(''), False)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.isdecimal()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('١'), False)
check('boundary 2', solve('１２'), False)
check('boundary 3', solve('123'), True)
check('boundary 4', solve(''), False)
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:
Unicode digits leak into an ASCII decimal token.

Accept one or more ASCII digits, with no whitespace or sign.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.isalnum()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('_a'), True)
check('boundary 2', solve('1a'), False)
check('boundary 3', solve('á'), True)
check('boundary 4', solve('class'), True)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bool(x) and (x[0].isalpha() or x[0]=='_') and all(c.isalnum() or c=='_' for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('_a'), True)
check('boundary 2', solve('1a'), False)
check('boundary 3', solve('á'), True)
check('boundary 4', solve('class'), True)
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:
An identifier rejects underscores and admits leading digits.

Validate Python Unicode identifiers, including keywords as lexical identifiers.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return all(ord(c)>=32 for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('a\u2028b'), False)
check('boundary 2', solve('\u200b'), False)
check('boundary 3', solve(''), True)
check('boundary 4', solve(' a '), True)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return all(not c.isspace() or c==' ' for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('a\u2028b'), False)
check('boundary 2', solve('\u200b'), False)
check('boundary 3', solve(''), True)
check('boundary 4', solve(' a '), True)
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 line separator is treated as printable text.

Use Unicode str.isprintable semantics, including printable empty text.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bool(x) and all(c in ' \x09\r\n' for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('\xa0'), True)
check('boundary 2', solve(''), False)
check('boundary 3', solve('\u2028\t'), True)
check('boundary 4', solve('x'), False)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return all(c.isspace() for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('\xa0'), True)
check('boundary 2', solve(''), False)
check('boundary 3', solve('\u2028\t'), True)
check('boundary 4', solve('x'), False)
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 nonbreaking space is not recognized as whitespace.

True exactly for nonempty Unicode whitespace strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return all(c.isupper() for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ABC!'), True)
check('boundary 2', solve('123'), False)
check('boundary 3', solve(''), False)
check('boundary 4', solve('Aß'), False)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x == x.upper()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ABC!'), True)
check('boundary 2', solve('123'), False)
check('boundary 3', solve(''), False)
check('boundary 4', solve('Aß'), False)
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:
Uncased punctuation invalidates uppercase text.

True if at least one cased character exists and every cased character is uppercase.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.upper()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ǳuro'), 'ǲuro')
check('boundary 2', solve("they're"), "They'Re")
check('boundary 3', solve('hello-world'), 'Hello-World')
check('boundary 4', solve(''), '')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ' '.join(w.capitalize() for w in x.split(' '))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ǳuro'), 'ǲuro')
check('boundary 2', solve("they're"), "They'Re")
check('boundary 3', solve('hello-world'), 'Hello-World')
check('boundary 4', solve(''), '')
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 titlecase digraph is reduced to an uppercase digraph.

Titlecase every word using Unicode titlecase mappings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x[:1].upper()+x[1:]
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('hELLO'), 'Hello')
check('boundary 2', solve('two WORDS'), 'Two words')
check('boundary 3', solve('ǳABC'), 'ǲabc')
check('boundary 4', solve(''), '')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.title()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('hELLO'), 'Hello')
check('boundary 2', solve('two WORDS'), 'Two words')
check('boundary 3', solve('ǳABC'), 'ǲabc')
check('boundary 4', solve(''), '')
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:
Capitalization leaves an uppercase tail.

Capitalize the first character and lowercase the remainder using Unicode rules.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c.lower() if c.isupper() else c.upper()[:1] for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ß'), 'SS')
check('boundary 2', solve('ǅ'), 'ǅ')
check('boundary 3', solve('Ab'), 'aB')
check('boundary 4', solve('!'), '!')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c.lower() if c.isupper() else c.upper() for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('ß'), 'SS')
check('boundary 2', solve('ǅ'), 'ǅ')
check('boundary 3', solve('Ab'), 'aB')
check('boundary 4', solve('!'), '!')
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:
An uppercase expansion is truncated during case swap.

Apply Unicode swapcase, retaining multi-character mappings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c for c in x if c.isalnum())
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('A1Ⅳ'), 'A')
check('boundary 2', solve('中é'), '中é')
check('boundary 3', solve('á'), 'a')
check('boundary 4', solve(''), '')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c for c in x if c.isalpha() or c.isnumeric())
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('A1Ⅳ'), 'A')
check('boundary 2', solve('中é'), '中é')
check('boundary 3', solve('á'), 'a')
check('boundary 4', solve(''), '')
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:
Alphabetic filtering admits combining letter numbers.

Keep only Unicode characters whose general category starts with L.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c for c in x if not unicodedata.combining(c))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('a'), 'a')
check('boundary 2', solve('का'), 'क')
check('boundary 3', solve('é'), 'é')
check('boundary 4', solve('á'), 'a')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c for c in x if unicodedata.category(c)!='Mn')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('a'), 'a')
check('boundary 2', solve('का'), 'क')
check('boundary 3', solve('é'), 'é')
check('boundary 4', solve('á'), 'a')
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 zero-class mark survives mark stripping.

Remove every Unicode M-category code point without decomposing text.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c for c in x if unicodedata.category(c)!='Cc')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('a\u200bb'), 'ab')
check('boundary 2', solve('a\x00b'), 'ab')
check('boundary 3', solve('\ue000'), '\ue000')
check('boundary 4', solve('a b'), 'a b')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ''.join(c for c in x if not unicodedata.category(c).startswith('C'))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('a\u200bb'), 'ab')
check('boundary 2', solve('a\x00b'), 'ab')
check('boundary 3', solve('\ue000'), '\ue000')
check('boundary 4', solve('a b'), 'a b')
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:
Invisible format controls survive control filtering.

Remove Unicode categories Cc and Cf; preserve spacing and private-use characters.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return len(x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('Ａ中'), 4)
check('boundary 2', solve('é'), 1)
check('boundary 3', solve('abc'), 3)
check('boundary 4', solve(''), 0)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return sum(2 if unicodedata.east_asian_width(c) in 'WF' else 1 for c in x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('Ａ中'), 4)
check('boundary 2', solve('é'), 1)
check('boundary 3', solve('abc'), 3)
check('boundary 4', solve(''), 0)
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:
Fullwidth letters occupy one display column.

Sum width 2 for W/F, zero for combining marks, and 1 otherwise; this is a codepoint width model.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return len(x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('é'), 2)
check('boundary 2', solve('😀'), 4)
check('boundary 3', solve('abc'), 3)
check('boundary 4', solve(''), 0)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return len(x.encode('utf-16-le'))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('é'), 2)
check('boundary 2', solve('😀'), 4)
check('boundary 3', solve('abc'), 3)
check('boundary 4', solve(''), 0)
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:
Character count underestimates an encoded field.

Return the strict UTF-8 byte length of scalar-value text.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return len(x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('😀'), 2)
check('boundary 2', solve('a'), 1)
check('boundary 3', solve(''), 0)
check('boundary 4', solve('é😀'), 3)
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return len(x.encode('utf-16'))//2
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('😀'), 2)
check('boundary 2', solve('a'), 1)
check('boundary 3', solve(''), 0)
check('boundary 4', solve('é😀'), 3)
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:
An astral character is counted as one UTF-16 unit.

Count UTF-16 code units, excluding a byte order mark.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bytes.fromhex(x).decode('utf-16-le')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('fffe4100'), 'A')
check('boundary 2', solve('feff0041'), 'A')
check('boundary 3', solve('fffe3dd800de'), '😀')
check('boundary 4', solve('feff'), '')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bytes.fromhex(x)[2:].decode('utf-16-le')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('fffe4100'), 'A')
check('boundary 2', solve('feff0041'), 'A')
check('boundary 3', solve('fffe3dd800de'), '😀')
check('boundary 4', solve('feff'), '')
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:
UTF-16 BOM is interpreted as ordinary text.

Decode BOM-bearing UTF-16 hex data honoring the BOM.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bytes.fromhex(x).decode('utf-8','replace')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('80'), '\x80')
check('boundary 2', solve('ff'), 'ÿ')
check('boundary 3', solve('41'), 'A')
check('boundary 4', solve(''), '')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bytes.fromhex(x).decode('cp1252','replace')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('80'), '\x80')
check('boundary 2', solve('ff'), 'ÿ')
check('boundary 3', solve('41'), 'A')
check('boundary 4', solve(''), '')
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:
Latin-1 bytes are decoded through a typographic code page.

Decode every byte one-to-one as ISO-8859-1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bytes.fromhex(x).decode('latin1')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('80'), '€')
check('boundary 2', solve('9394'), '“”')
check('boundary 3', solve('81'), '�')
check('boundary 4', solve('41'), 'A')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bytes.fromhex(x).decode('utf-8','replace')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('80'), '€')
check('boundary 2', solve('9394'), '“”')
check('boundary 3', solve('81'), '�')
check('boundary 4', solve('41'), 'A')
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:
Windows punctuation decodes as controls.

Decode defined Windows-1252 bytes; replace undefined bytes.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bytes.fromhex(x).decode('utf-8','ignore')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('61ff62'), 'a�b')
check('boundary 2', solve('e282'), '�')
check('boundary 3', solve('f09f9880'), '😀')
check('boundary 4', solve(''), '')
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
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return bytes.fromhex(x).decode('latin1')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('61ff62'), 'a�b')
check('boundary 2', solve('e282'), '�')
check('boundary 3', solve('f09f9880'), '😀')
check('boundary 4', solve(''), '')
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:
Invalid UTF-8 bytes silently disappear.

Decode UTF-8 using one standard replacement sequence per decoding error.

split: open-access