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

N = 1
observations = []
def solve(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender]
    has_read = [u for u in recipients if read.get(u, -1) >= sent_seq]
    got = [u for u in recipients if delivered.get(u) or u in has_read]
    if not recipients:
        status = 'sent'
    elif len(has_read) == len(recipients):
        status = 'read'
    elif len(got) == len(recipients):
        status = 'delivered'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender and joined_at.get(u, 0) < sent_seq]
    has_read = [u for u in recipients if read.get(u, -1) >= sent_seq]
    got = [u for u in recipients if delivered.get(u) or u in has_read]
    if not recipients:
        status = 'sent'
    elif len(has_read) == len(recipients):
        status = 'read'
    elif len(got) == len(recipients):
        status = 'delivered'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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:
A member who joined after a message was sent can never read it, so the message stays "delivered" forever.

Recipients are members other than the sender whose joined_at (first visible seq, default 0) is <= sent_seq. A recipient has read the message when read[u] (their read marker) >= sent_seq; reading implies delivery. Status is "sent" with no recipients, "read" when every recipient read, "delivered" when every recipient got it, else "sent". Result {status, read_by (sorted), recipients (count)}.

split: open-access


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

N = 1
observations = []
def solve(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender and joined_at.get(u, 0) <= sent_seq]
    has_read = [u for u in recipients if read.get(u, -1) > sent_seq]
    got = [u for u in recipients if delivered.get(u) or u in has_read]
    if not recipients:
        status = 'sent'
    elif len(has_read) == len(recipients):
        status = 'read'
    elif len(got) == len(recipients):
        status = 'delivered'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender and joined_at.get(u, 0) <= sent_seq]
    has_read = [u for u in recipients if read.get(u, -1) == sent_seq]
    got = [u for u in recipients if delivered.get(u) or u in has_read]
    if not recipients:
        status = 'sent'
    elif len(has_read) == len(recipients):
        status = 'read'
    elif len(got) == len(recipients):
        status = 'delivered'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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:
A recipient whose read marker sits exactly on, or beyond, the message is not counted as having read it.

Recipients are members other than the sender whose joined_at (first visible seq, default 0) is <= sent_seq. A recipient has read the message when read[u] (their read marker) >= sent_seq; reading implies delivery. Status is "sent" with no recipients, "read" when every recipient read, "delivered" when every recipient got it, else "sent". Result {status, read_by (sorted), recipients (count)}.

split: open-access


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

N = 1
observations = []
def solve(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender and joined_at.get(u, 0) <= sent_seq]
    has_read = [u for u in recipients if read.get(u, -1) >= sent_seq]
    got = [u for u in recipients if delivered.get(u)]
    if not recipients:
        status = 'sent'
    elif len(has_read) == len(recipients):
        status = 'read'
    elif len(got) == len(recipients):
        status = 'delivered'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender and joined_at.get(u, 0) <= sent_seq]
    has_read = [u for u in recipients if read.get(u, -1) >= sent_seq]
    got = [u for u in recipients if delivered.get(u) or read.get(u, -1) > sent_seq]
    if not recipients:
        status = 'sent'
    elif len(has_read) == len(recipients):
        status = 'read'
    elif len(got) == len(recipients):
        status = 'delivered'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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:
A recipient who read the message before the delivery acknowledgement arrived keeps the message at "sent".

Recipients are members other than the sender whose joined_at (first visible seq, default 0) is <= sent_seq. A recipient has read the message when read[u] (their read marker) >= sent_seq; reading implies delivery. Status is "sent" with no recipients, "read" when every recipient read, "delivered" when every recipient got it, else "sent". Result {status, read_by (sorted), recipients (count)}.

split: open-access


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

N = 1
observations = []
def solve(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender and joined_at.get(u, 0) <= sent_seq]
    has_read = [u for u in recipients if read.get(u, -1) >= sent_seq]
    got = [u for u in recipients if delivered.get(u) or u in has_read]
    if not recipients:
        status = 'sent'
    elif len(got) == len(recipients):
        status = 'delivered'
    elif len(has_read) == len(recipients):
        status = 'read'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender and joined_at.get(u, 0) <= sent_seq]
    has_read = [u for u in recipients if read.get(u, -1) >= sent_seq]
    got = [u for u in recipients if delivered.get(u) or u in has_read]
    if not recipients:
        status = 'sent'
    elif len(has_read) >= 1:
        status = 'read'
    elif len(got) == len(recipients):
        status = 'delivered'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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:
Fully read messages are shown with delivered ticks because the delivered test runs first.

Recipients are members other than the sender whose joined_at (first visible seq, default 0) is <= sent_seq. A recipient has read the message when read[u] (their read marker) >= sent_seq; reading implies delivery. Status is "sent" with no recipients, "read" when every recipient read, "delivered" when every recipient got it, else "sent". Result {status, read_by (sorted), recipients (count)}.

split: open-access


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

N = 1
observations = []
def solve(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender and joined_at.get(u, 0) <= sent_seq]
    has_read = [u for u in recipients if read.get(u, -1) >= sent_seq]
    got = [u for u in recipients if delivered.get(u) or u in has_read]
    if recipients is None:
        status = 'sent'
    elif len(has_read) == len(recipients):
        status = 'read'
    elif len(got) == len(recipients):
        status = 'delivered'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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(sender, members, joined_at, sent_seq, delivered, read):
    recipients = [u for u in members if u != sender and joined_at.get(u, 0) <= sent_seq]
    has_read = [u for u in recipients if read.get(u, -1) >= sent_seq]
    got = [u for u in recipients if delivered.get(u) or u in has_read]
    if not members:
        status = 'sent'
    elif len(has_read) == len(recipients):
        status = 'read'
    elif len(got) == len(recipients):
        status = 'delivered'
    else:
        status = 'sent'
    return {'status': status, 'read_by': sorted(has_read), 'recipients': len(recipients)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 21}, 11, {'bo': True}, {'bo': 16}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 10}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 1, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 5, {'bo': True}, {'cy': 5}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 2: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 22}, 12, {'bo': True}, {'bo': 17}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 11}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 2, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 6, {'bo': True}, {'cy': 6}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 3: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 23}, 13, {'bo': True}, {'bo': 18}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 3, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 7, {'bo': True}, {'cy': 7}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 4: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 24}, 14, {'bo': True}, {'bo': 19}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 13}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 4, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 8, {'bo': True}, {'cy': 8}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})], 5: [('late joiner does not block read', ('al', ['al', 'bo', 'cy'], {'cy': 25}, 15, {'bo': True}, {'bo': 20}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('member joined exactly at the message', ('al', ['al', 'bo', 'cy'], {'cy': 12}, 12, {'bo': True, 'cy': True}, {'bo': 12}), {'read_by': ['bo'], 'recipients': 2, 'status': 'delivered'}), ('read marker beyond message', ('al', ['al', 'bo'], {}, 7, {}, {'bo': 14}), {'read_by': ['bo'], 'recipients': 1, 'status': 'read'}), ('read without delivery ack', ('al', ['al', 'bo', 'cy'], {}, 4, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('everyone read', ('al', ['al', 'bo', 'cy'], {}, 3, {'bo': True, 'cy': True}, {'bo': 3, 'cy': 5}), {'read_by': ['bo', 'cy'], 'recipients': 2, 'status': 'read'}), ('sender alone', ('al', ['al'], {}, 5, {}, {}), {'read_by': [], 'recipients': 0, 'status': 'sent'}), ('read exactly without ack', ('al', ['al', 'bo', 'cy'], {}, 9, {'bo': True}, {'cy': 9}), {'read_by': ['cy'], 'recipients': 2, 'status': 'delivered'}), ('partial delivery', ('al', ['al', 'bo', 'cy', 'di'], {}, 2, {'bo': True, 'cy': True}, {'bo': 1}), {'read_by': [], 'recipients': 3, 'status': 'sent'})]}
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:
A message in a conversation with no other eligible recipients is shown as read by everyone.

Recipients are members other than the sender whose joined_at (first visible seq, default 0) is <= sent_seq. A recipient has read the message when read[u] (their read marker) >= sent_seq; reading implies delivery. Status is "sent" with no recipients, "read" when every recipient read, "delivered" when every recipient got it, else "sent". Result {status, read_by (sorted), recipients (count)}.

split: open-access


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

N = 1
observations = []
def solve(events):
    rank = {'queued': 0, 'sent': 1, 'delivered': 2, 'read': 3}
    status = 'queued'
    history = ['queued']
    for _, kind in events:
        if kind == 'failed':
            nxt = 'failed' if status in ('queued', 'sent') else status
        elif kind == 'retry':
            nxt = 'queued' if status == 'failed' else status
        elif status == 'failed':
            nxt = kind if rank[kind] >= rank['delivered'] else status
        else:
            nxt = kind if rank[kind] > rank[status] else status
        if nxt != status:
            status = nxt
            history.append(status)
    return {'status': status, 'history': history}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('arrival order differs', ([[4, 'read'], [2, 'sent'], [3, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[1, 'failed'], [2, 'retry'], [3, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [3, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [4, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [5, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})], 2: [('arrival order differs', ([[5, 'read'], [3, 'sent'], [4, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[2, 'failed'], [3, 'retry'], [4, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [4, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [5, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [6, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})], 3: [('arrival order differs', ([[6, 'read'], [4, 'sent'], [5, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[3, 'failed'], [4, 'retry'], [5, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [5, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [6, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [7, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})], 4: [('arrival order differs', ([[7, 'read'], [5, 'sent'], [6, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[4, 'failed'], [5, 'retry'], [6, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [6, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [7, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [8, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})], 5: [('arrival order differs', ([[8, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[5, 'failed'], [6, 'retry'], [7, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [7, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [8, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [9, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})]}
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(events):
    rank = {'queued': 0, 'sent': 1, 'delivered': 2, 'read': 3}
    status = 'queued'
    history = ['queued']
    for _, kind in sorted(events, key=lambda e: rank.get(e[1], -1)):
        if kind == 'failed':
            nxt = 'failed' if status in ('queued', 'sent') else status
        elif kind == 'retry':
            nxt = 'queued' if status == 'failed' else status
        elif status == 'failed':
            nxt = kind if rank[kind] >= rank['delivered'] else status
        else:
            nxt = kind if rank[kind] > rank[status] else status
        if nxt != status:
            status = nxt
            history.append(status)
    return {'status': status, 'history': history}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('arrival order differs', ([[4, 'read'], [2, 'sent'], [3, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[1, 'failed'], [2, 'retry'], [3, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [3, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [4, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [5, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})], 2: [('arrival order differs', ([[5, 'read'], [3, 'sent'], [4, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[2, 'failed'], [3, 'retry'], [4, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [4, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [5, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [6, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})], 3: [('arrival order differs', ([[6, 'read'], [4, 'sent'], [5, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[3, 'failed'], [4, 'retry'], [5, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [5, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [6, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [7, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})], 4: [('arrival order differs', ([[7, 'read'], [5, 'sent'], [6, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[4, 'failed'], [5, 'retry'], [6, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [6, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [7, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [8, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})], 5: [('arrival order differs', ([[8, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'sent', 'delivered', 'read'], 'status': 'read'}), ('failure after delivery', ([[1, 'sent'], [2, 'delivered'], [3, 'failed']],), {'history': ['queued', 'sent', 'delivered'], 'status': 'delivered'}), ('failure while queued', ([[5, 'failed'], [6, 'retry'], [7, 'sent']],), {'history': ['queued', 'failed', 'queued', 'sent'], 'status': 'sent'}), ('retry after read', ([[1, 'read'], [2, 'retry']],), {'history': ['queued', 'read'], 'status': 'read'}), ('retry after delivery', ([[1, 'delivered'], [7, 'retry']],), {'history': ['queued', 'delivered'], 'status': 'delivered'}), ('late delivery after failure', ([[1, 'sent'], [2, 'failed'], [3, 'delivered']],), {'history': ['queued', 'sent', 'failed', 'delivered'], 'status': 'delivered'}), ('stale sent after failure', ([[1, 'sent'], [2, 'failed'], [8, 'sent']],), {'history': ['queued', 'sent', 'failed'], 'status': 'failed'}), ('late sent after read', ([[5, 'read'], [6, 'sent'], [7, 'delivered']],), {'history': ['queued', 'read'], 'status': 'read'}), ('failed then retried delivery', ([[2, 'failed'], [3, 'retry'], [4, 'delivered'], [9, 'failed']],), {'history': ['queued', 'failed', 'queued', 'delivered'], 'status': 'delivered'})]}
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:
Events processed in arrival order let a late "sent" or "failed" overwrite later evidence.

events are [seq, kind] with kind in queued, sent, delivered, read, failed, retry, processed in (seq, kind) order. Ranks queued<sent<delivered<read and status never regresses. failed only applies while queued or sent; retry moves failed back to queued; after a failure only delivered or read evidence (not a stale sent) replaces it. Result {status, history} where history lists every status change starting at queued.

split: open-access