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

N = 1
observations = []
def solve(messages, root):
    replies = sorted((m for m in messages if m['root'] == root and not m['deleted']), key=lambda m: m['author'])
    seen = []
    for m in replies:
        if m['author'] not in seen:
            seen.append(m['author'])
    return {'count': len(replies), 'faces': seen[:3], 'more': max(0, len(seen) - 3),
            'last': replies[-1]['seq'] if replies else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 10, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 10, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u4', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u0', 'u1'], 'last': 19, 'more': 2}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 2: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 11, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 11, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u0'], 'last': 19, 'more': 3}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 3: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 12, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 12, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 6, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u5', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 4}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 4: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 13, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 13, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 7, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u3', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 5}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 5: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 14, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 14, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 8, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 6}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(messages, root):
    replies = sorted((m for m in messages if m['root'] == root and not m['deleted']), key=lambda m: -m['seq'])
    seen = []
    for m in replies:
        if m['author'] not in seen:
            seen.append(m['author'])
    return {'count': len(replies), 'faces': seen[:3], 'more': max(0, len(seen) - 3),
            'last': replies[-1]['seq'] if replies else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 10, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 10, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u4', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u0', 'u1'], 'last': 19, 'more': 2}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 2: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 11, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 11, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u0'], 'last': 19, 'more': 3}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 3: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 12, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 12, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 6, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u5', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 4}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 4: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 13, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 13, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 7, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u3', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 5}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 5: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 14, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 14, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 8, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 6}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Faces and the newest-reply pointer follow author names instead of reply order.

messages {seq, root, author, deleted}; replies of a thread have root equal to the root seq (the root itself has root None). Deleted replies are ignored. Result {count, faces: first three distinct reply authors in order of their first reply, more: number of further distinct authors, last: seq of the newest reply or None}.

split: open-access


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

N = 1
observations = []
def solve(messages, root):
    replies = sorted((m for m in messages if m['root'] == root and not m['deleted']), key=lambda m: m['seq'])
    seen = []
    for m in replies:
        if m['author'] not in seen:
            seen.append(m['author'])
    return {'count': len(replies), 'faces': seen[:3], 'more': len(seen) - 3,
            'last': replies[-1]['seq'] if replies else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 10, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 10, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u4', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u0', 'u1'], 'last': 19, 'more': 2}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 2: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 11, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 11, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u0'], 'last': 19, 'more': 3}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 3: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 12, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 12, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 6, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u5', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 4}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 4: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 13, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 13, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 7, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u3', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 5}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 5: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 14, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 14, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 8, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 6}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

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

N = 1
observations = []
def solve(messages, root):
    replies = sorted((m for m in messages if m['root'] == root and not m['deleted']), key=lambda m: m['seq'])
    seen = []
    for m in replies:
        if m['author'] not in seen:
            seen.append(m['author'])
    return {'count': len(replies), 'faces': seen[:3], 'more': len(replies) - 3,
            'last': replies[-1]['seq'] if replies else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 10, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 10, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u4', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u0', 'u1'], 'last': 19, 'more': 2}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 2: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 11, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 11, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u0'], 'last': 19, 'more': 3}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 3: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 12, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 12, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 6, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u5', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 4}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 4: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 13, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 13, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 7, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u3', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 5}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 5: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 14, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 14, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 8, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 6}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Threads with fewer than three participants report a negative "+N more".

messages {seq, root, author, deleted}; replies of a thread have root equal to the root seq (the root itself has root None). Deleted replies are ignored. Result {count, faces: first three distinct reply authors in order of their first reply, more: number of further distinct authors, last: seq of the newest reply or None}.

split: open-access


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

N = 1
observations = []
def solve(messages, root):
    replies = sorted((m for m in messages if m['root'] == root and not m['deleted']), key=lambda m: m['seq'])
    seen = []
    for m in replies:
        if m['author'] not in seen:
            seen.append(m['author'])
    return {'count': len(replies), 'faces': seen[:3], 'more': max(0, len(seen) - 3),
            'last': max((m['seq'] for m in messages if m['root'] == root), default=None)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 10, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 10, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u4', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u0', 'u1'], 'last': 19, 'more': 2}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 2: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 11, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 11, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u0'], 'last': 19, 'more': 3}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 3: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 12, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 12, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 6, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u5', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 4}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 4: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 13, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 13, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 7, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u3', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 5}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 5: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 14, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 14, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 8, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 6}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(messages, root):
    replies = sorted((m for m in messages if m['root'] == root and not m['deleted']), key=lambda m: m['seq'])
    seen = []
    for m in replies:
        if m['author'] not in seen:
            seen.append(m['author'])
    return {'count': len(replies), 'faces': seen[:3], 'more': max(0, len(seen) - 3),
            'last': replies[0]['seq'] if replies else None}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 10, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 10, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u4', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u0', 'u1'], 'last': 19, 'more': 2}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 2: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 11, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 11, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u0'], 'last': 19, 'more': 3}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 3: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 12, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 12, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 6, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u5', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 4}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 4: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 13, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 13, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 7, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u3', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 5}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})], 5: [('root is not a reply', ([{'seq': 5, 'root': None, 'author': 'al', 'deleted': False}, {'seq': 6, 'root': 5, 'author': 'bo', 'deleted': False}, {'seq': 7, 'root': None, 'author': 'cy', 'deleted': False}], 5), {'count': 1, 'faces': ['bo'], 'last': 6, 'more': 0}), ('reply order by seq', ([{'seq': 14, 'root': 1, 'author': 'zed', 'deleted': False}, {'seq': 3, 'root': 1, 'author': 'amy', 'deleted': False}, {'seq': 4, 'root': 1, 'author': 'kim', 'deleted': False}], 1), {'count': 3, 'faces': ['amy', 'kim', 'zed'], 'last': 14, 'more': 0}), ('few authors', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('newest reply deleted', ([{'seq': 2, 'root': 1, 'author': 'a', 'deleted': False}, {'seq': 8, 'root': 1, 'author': 'b', 'deleted': True}], 1), {'count': 1, 'faces': ['a'], 'last': 2, 'more': 0}), ('alternating authors', ([{'seq': 1, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 2, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 3, 'root': 0, 'author': 'b', 'deleted': False}, {'seq': 4, 'root': 0, 'author': 'a', 'deleted': False}, {'seq': 5, 'root': 0, 'author': 'b', 'deleted': False}], 0), {'count': 5, 'faces': ['b', 'a'], 'last': 5, 'more': 0}), ('many authors', ([{'seq': 4, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 5, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 6, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 7, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 8, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 9, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 10, 'root': 3, 'author': 'u1', 'deleted': False}, {'seq': 11, 'root': 3, 'author': 'u2', 'deleted': False}, {'seq': 12, 'root': 3, 'author': 'u3', 'deleted': False}, {'seq': 13, 'root': 3, 'author': 'u4', 'deleted': False}, {'seq': 14, 'root': 3, 'author': 'u5', 'deleted': False}, {'seq': 15, 'root': 3, 'author': 'u6', 'deleted': False}, {'seq': 16, 'root': 3, 'author': 'u7', 'deleted': False}, {'seq': 17, 'root': 3, 'author': 'u8', 'deleted': False}, {'seq': 18, 'root': 3, 'author': 'u0', 'deleted': False}, {'seq': 19, 'root': 3, 'author': 'u1', 'deleted': False}], 3), {'count': 16, 'faces': ['u4', 'u5', 'u6'], 'last': 19, 'more': 6}), ('no replies', ([{'seq': 1, 'root': None, 'author': 'a', 'deleted': False}], 1), {'count': 0, 'faces': [], 'last': None, 'more': 0})]}
for _label, _args, _expected in _CASES[N]:
    check(_label, solve(*_args), _expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The latest-reply pointer targets a deleted reply.

messages {seq, root, author, deleted}; replies of a thread have root equal to the root seq (the root itself has root None). Deleted replies are ignored. Result {count, faces: first three distinct reply authors in order of their first reply, more: number of further distinct authors, last: seq of the newest reply or None}.

split: open-access