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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n-1]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('implicit-offset-next-byte fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('implicit-offset-next-byte fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('implicit-offset-next-byte fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('implicit-offset-next-byte fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('implicit-offset-next-byte fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('implicit-offset-next-byte fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('implicit-offset-next-byte fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('implicit-offset-next-byte fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('implicit-offset-next-byte fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('implicit-offset-next-byte fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('implicit-offset-next-byte fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-next-byte fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('implicit-offset-next-byte fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
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 segment playlist resolves byte-range tags into per-segment Range values: an offsetless sub-range starts at the byte after the previous sub-range.

x is a list of playlist lines. Lines are trimmed; blank lines skipped; every other line starting with # is a tag or comment. #EXT-X-BYTERANGE:n[@o] (ASCII decimals) applies only to the next URI line. Without @o the range continues at the byte after the immediately previous segment, which must be a sub-range of the same URI string; otherwise null. A URI without a byte-range tag is a whole-resource segment [uri,null] and breaks any continuation chain. Zero-length sub-ranges and malformed tags return null. Return [uri,inclusive bytes=a-b or null] rows.

split: open-access


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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('implicit-offset-same-uri fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('implicit-offset-same-uri fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('implicit-offset-same-uri fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('implicit-offset-same-uri fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('implicit-offset-same-uri fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('implicit-offset-same-uri fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
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(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0].split('?')[0]!=line.split('?')[0]: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('implicit-offset-same-uri fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('implicit-offset-same-uri fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('implicit-offset-same-uri fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('implicit-offset-same-uri fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('implicit-offset-same-uri fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-same-uri fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('implicit-offset-same-uri fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
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 segment playlist resolves byte-range tags into per-segment Range values: an offsetless sub-range cannot continue a different resource.

x is a list of playlist lines. Lines are trimmed; blank lines skipped; every other line starting with # is a tag or comment. #EXT-X-BYTERANGE:n[@o] (ASCII decimals) applies only to the next URI line. Without @o the range continues at the byte after the immediately previous segment, which must be a sub-range of the same URI string; otherwise null. A URI without a byte-range tag is a whole-resource segment [uri,null] and breaks any continuation chain. Zero-length sub-ranges and malformed tags return null. Return [uri,inclusive bytes=a-b or null] rows.

split: open-access


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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is not None and prev[0]!=line: return None
                    o=prev[1] if prev else 0
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('implicit-offset-first-segment fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('implicit-offset-first-segment fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('implicit-offset-first-segment fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('implicit-offset-first-segment fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('implicit-offset-first-segment fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('implicit-offset-first-segment fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is not None and prev[0]!=line or prev is None and out: return None
                    o=prev[1] if prev else 0
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('implicit-offset-first-segment fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('implicit-offset-first-segment fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('implicit-offset-first-segment fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('implicit-offset-first-segment fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('implicit-offset-first-segment fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('implicit-offset-first-segment fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('implicit-offset-first-segment fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
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 segment playlist resolves byte-range tags into per-segment Range values: an offsetless sub-range without a preceding sub-range is invalid rather than starting at zero.

x is a list of playlist lines. Lines are trimmed; blank lines skipped; every other line starting with # is a tag or comment. #EXT-X-BYTERANGE:n[@o] (ASCII decimals) applies only to the next URI line. Without @o the range continues at the byte after the immediately previous segment, which must be a sub-range of the same URI string; otherwise null. A URI without a byte-range tag is a whole-resource segment [uri,null] and breaks any continuation chain. Zero-length sub-ranges and malformed tags return null. Return [uri,inclusive bytes=a-b or null] rows.

split: open-access


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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pass
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('byterange-one-shot fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('byterange-one-shot fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('byterange-one-shot fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('byterange-one-shot fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('byterange-one-shot fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('byterange-one-shot fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=[pending[0],None] if pending else None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('byterange-one-shot fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('byterange-one-shot fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('byterange-one-shot fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('byterange-one-shot fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('byterange-one-shot fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('byterange-one-shot fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('byterange-one-shot fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
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 segment playlist resolves byte-range tags into per-segment Range values: a byte-range tag applies only to the next segment URI.

x is a list of playlist lines. Lines are trimmed; blank lines skipped; every other line starting with # is a tag or comment. #EXT-X-BYTERANGE:n[@o] (ASCII decimals) applies only to the next URI line. Without @o the range continues at the byte after the immediately previous segment, which must be a sub-range of the same URI string; otherwise null. A URI without a byte-range tag is a whole-resource segment [uri,null] and breaks any continuation chain. Zero-length sub-ranges and malformed tags return null. Return [uri,inclusive bytes=a-b or null] rows.

split: open-access


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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                pass
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full-segment-resets-chain fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('full-segment-resets-chain fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('full-segment-resets-chain fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('full-segment-resets-chain fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('full-segment-resets-chain fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('full-segment-resets-chain fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None if prev and prev[0]!=line else prev
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('full-segment-resets-chain fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('full-segment-resets-chain fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('full-segment-resets-chain fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('full-segment-resets-chain fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('full-segment-resets-chain fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('full-segment-resets-chain fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('full-segment-resets-chain fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
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 segment playlist resolves byte-range tags into per-segment Range values: a whole-resource segment breaks the implicit offset chain.

x is a list of playlist lines. Lines are trimmed; blank lines skipped; every other line starting with # is a tag or comment. #EXT-X-BYTERANGE:n[@o] (ASCII decimals) applies only to the next URI line. Without @o the range continues at the byte after the immediately previous segment, which must be a sub-range of the same URI string; otherwise null. A URI without a byte-range tag is a whole-resource segment [uri,null] and breaks any continuation chain. Zero-length sub-ranges and malformed tags return null. Return [uri,inclusive bytes=a-b or null] rows.

split: open-access


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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n<0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero-length-subrange fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('zero-length-subrange fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('zero-length-subrange fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('zero-length-subrange fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('zero-length-subrange fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('zero-length-subrange fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0 and not out: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('zero-length-subrange fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('zero-length-subrange fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('zero-length-subrange fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('zero-length-subrange fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('zero-length-subrange fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('zero-length-subrange fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('zero-length-subrange fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
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 segment playlist resolves byte-range tags into per-segment Range values: a zero-byte sub-range cannot be expressed as an inclusive Range.

x is a list of playlist lines. Lines are trimmed; blank lines skipped; every other line starting with # is a tag or comment. #EXT-X-BYTERANGE:n[@o] (ASCII decimals) applies only to the next URI line. Without @o the range continues at the byte after the immediately previous segment, which must be a sub-range of the same URI string; otherwise null. A URI without a byte-range tag is a whole-resource segment [uri,null] and breaks any continuation chain. Zero-length sub-ranges and malformed tags return null. Return [uri,inclusive bytes=a-b or null] rows.

split: open-access


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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('crlf-lines fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('crlf-lines fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('crlf-lines fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('crlf-lines fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('crlf-lines fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('crlf-lines fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.rstrip('\n')
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('crlf-lines fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('crlf-lines fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('crlf-lines fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('crlf-lines fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('crlf-lines fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('crlf-lines fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('crlf-lines fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
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 segment playlist resolves byte-range tags into per-segment Range values: carriage returns from CRLF playlists are trimmed before parsing.

x is a list of playlist lines. Lines are trimmed; blank lines skipped; every other line starting with # is a tag or comment. #EXT-X-BYTERANGE:n[@o] (ASCII decimals) applies only to the next URI line. Without @o the range continues at the byte after the immediately previous segment, which must be a sub-range of the same URI string; otherwise null. A URI without a byte-range tag is a whole-resource segment [uri,null] and breaks any continuation chain. Zero-length sub-ranges and malformed tags return null. Return [uri,inclusive bytes=a-b or null] rows.

split: open-access


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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#EXT'):
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('non-uri-tags fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('non-uri-tags fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('non-uri-tags fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('non-uri-tags fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('non-uri-tags fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('non-uri-tags fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    out=[]
    pending=None
    prev=None
    for raw in x:
        line=raw.strip()
        if not line: continue
        if line.startswith('#EXT-X-BYTERANGE:'):
            n,at,o=line[17:].partition('@')
            if not n.isdigit() or (at and not o.isdigit()): return None
            pending=[int(n),int(o) if at else None]
        elif line.startswith('#') and ':' in line:
            continue
        else:
            if pending is None:
                out.append([line,None])
                prev=None
            else:
                n,o=pending
                if o is None:
                    if prev is None or prev[0]!=line: return None
                    o=prev[1]
                if n==0: return None
                out.append([line,'bytes=%d-%d'%(o,o+n-1)])
                prev=[line,o+n]
            pending=None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('non-uri-tags fixture 0', json.loads(json.dumps(solve(['#EXTM3U','#EXTINF:1,','#EXT-X-BYTERANGE:100@0','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:50','a.ts','#EXTINF:1,','#EXT-X-BYTERANGE:25','a.ts']))), json.loads(json.dumps([['a.ts','bytes=0-99'],['a.ts','bytes=100-149'],['a.ts','bytes=150-174']])))
check('non-uri-tags fixture 1', json.loads(json.dumps(solve(['#EXTM3U','# generated by tool','#EXT-X-BYTERANGE:10@5','b.ts']))), json.loads(json.dumps([['b.ts','bytes=5-14']])))
check('non-uri-tags fixture 2', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','#EXT-X-BYTERANGE:10','b.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 3', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts?v=1','#EXT-X-BYTERANGE:10','a.ts?v=2']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 4', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 5', json.loads(json.dumps(solve(['full.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 6', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','a.ts','#EXT-X-BYTERANGE:10','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 7', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@0','a.ts','b.ts']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['b.ts',None]])))
check('non-uri-tags fixture 8', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:0@0','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 9', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:5@0','a.ts','#EXT-X-BYTERANGE:0','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 10', json.loads(json.dumps(solve(['#EXTM3U\r\n','#EXT-X-BYTERANGE:10@0\r\n','a.ts\r\n','#EXT-X-BYTERANGE:4\r\n','a.ts\r\n']))), json.loads(json.dumps([['a.ts','bytes=0-9'],['a.ts','bytes=10-13']])))
check('non-uri-tags fixture 11', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:1x@0','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 12', json.loads(json.dumps(solve(['#EXT-X-BYTERANGE:10@','a.ts']))), json.loads(json.dumps(None)))
check('non-uri-tags fixture 13', json.loads(json.dumps(solve(['','#EXT-X-BYTERANGE:3@7','   ','c.ts']))), json.loads(json.dumps([['c.ts','bytes=7-9']])))
check('non-uri-tags fixture 14', json.loads(json.dumps(solve(["#EXT-X-BYTERANGE:%d@0"%N,'a.ts',"#EXT-X-BYTERANGE:%d"%N,'a.ts']))), json.loads(json.dumps([['a.ts',"bytes=0-%d"%(N-1)],['a.ts',"bytes=%d-%d"%(N,2*N-1)]])))
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 segment playlist resolves byte-range tags into per-segment Range values: comment and tag lines are never treated as segment URIs.

x is a list of playlist lines. Lines are trimmed; blank lines skipped; every other line starting with # is a tag or comment. #EXT-X-BYTERANGE:n[@o] (ASCII decimals) applies only to the next URI line. Without @o the range continues at the byte after the immediately previous segment, which must be a sub-range of the same URI string; otherwise null. A URI without a byte-range tag is a whole-resource segment [uri,null] and breaks any continuation chain. Zero-length sub-ranges and malformed tags return null. Return [uri,inclusive bytes=a-b or null] rows.

split: open-access


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

N = 1
observations = []
def solve(x):
    sizes=x['parts']
    total=sum(sizes)
    starts=[]
    acc=0
    for s in sizes:
        starts.append(acc)
        acc+=s
    q=x['query']
    if q[0]=='part':
        n=q[1]
        if not 0<=n<=len(sizes) or sizes[n-1]==0: return [416,'bytes */%d'%total]
        a=starts[n-1]
        return [206,'bytes %d-%d/%d'%(a,a+sizes[n-1]-1,total)]
    a,b=q[1],q[2]
    if not 0<=a<=b<total: return [416,'bytes */%d'%total]
    out=[]
    for i,s in enumerate(sizes):
        lo=max(a,starts[i])
        hi=min(b,starts[i]+s-1)
        if lo<=hi: out.append([i+1,lo-starts[i],hi-lo+1])
    return [206,out]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('part-number-domain fixture 0', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',2]}))), json.loads(json.dumps([206,'bytes 5-7/12'])))
check('part-number-domain fixture 1', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',3]}))), json.loads(json.dumps([206,'bytes 8-11/12'])))
check('part-number-domain fixture 2', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',0]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-number-domain fixture 3', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',-1]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-number-domain fixture 4', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',4]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-number-domain fixture 5', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['part',2]}))), json.loads(json.dumps([416,'bytes */9'])))
check('part-number-domain fixture 6', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',3,9]}))), json.loads(json.dumps([206,[[1,3,2],[2,0,3],[3,0,2]]])))
check('part-number-domain fixture 7', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[2,0,1]]])))
check('part-number-domain fixture 8', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',5,7]}))), json.loads(json.dumps([206,[[2,0,3]]])))
check('part-number-domain fixture 9', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,12]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-number-domain fixture 10', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,11]}))), json.loads(json.dumps([206,[[1,0,5],[2,0,3],[3,0,4]]])))
check('part-number-domain fixture 11', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[3,0,1]]])))
check('part-number-domain fixture 12', json.loads(json.dumps(solve({'parts':[],'query':['part',1]}))), json.loads(json.dumps([416,'bytes */0'])))
check('part-number-domain fixture 13', json.loads(json.dumps(solve({'parts':[N,N],'query':['part',2]}))), json.loads(json.dumps([206,"bytes %d-%d/%d"%(N,2*N-1,2*N)])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    sizes=x['parts']
    total=sum(sizes)
    starts=[]
    acc=0
    for s in sizes:
        starts.append(acc)
        acc+=s
    q=x['query']
    if q[0]=='part':
        n=q[1]
        if not n<=len(sizes) or sizes[n-1]==0: return [416,'bytes */%d'%total]
        a=starts[n-1]
        return [206,'bytes %d-%d/%d'%(a,a+sizes[n-1]-1,total)]
    a,b=q[1],q[2]
    if not 0<=a<=b<total: return [416,'bytes */%d'%total]
    out=[]
    for i,s in enumerate(sizes):
        lo=max(a,starts[i])
        hi=min(b,starts[i]+s-1)
        if lo<=hi: out.append([i+1,lo-starts[i],hi-lo+1])
    return [206,out]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('part-number-domain fixture 0', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',2]}))), json.loads(json.dumps([206,'bytes 5-7/12'])))
check('part-number-domain fixture 1', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',3]}))), json.loads(json.dumps([206,'bytes 8-11/12'])))
check('part-number-domain fixture 2', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',0]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-number-domain fixture 3', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',-1]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-number-domain fixture 4', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',4]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-number-domain fixture 5', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['part',2]}))), json.loads(json.dumps([416,'bytes */9'])))
check('part-number-domain fixture 6', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',3,9]}))), json.loads(json.dumps([206,[[1,3,2],[2,0,3],[3,0,2]]])))
check('part-number-domain fixture 7', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[2,0,1]]])))
check('part-number-domain fixture 8', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',5,7]}))), json.loads(json.dumps([206,[[2,0,3]]])))
check('part-number-domain fixture 9', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,12]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-number-domain fixture 10', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,11]}))), json.loads(json.dumps([206,[[1,0,5],[2,0,3],[3,0,4]]])))
check('part-number-domain fixture 11', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[3,0,1]]])))
check('part-number-domain fixture 12', json.loads(json.dumps(solve({'parts':[],'query':['part',1]}))), json.loads(json.dumps([416,'bytes */0'])))
check('part-number-domain fixture 13', json.loads(json.dumps(solve({'parts':[N,N],'query':['part',2]}))), json.loads(json.dumps([206,"bytes %d-%d/%d"%(N,2*N-1,2*N)])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An object store maps upload part numbers and byte ranges onto stored parts: part numbers are one-based and positive.

x has stored part sizes in order and a query. ["part",n] (1-based) returns [206,bytes a-b/total] for that part, or [416,bytes */total] when n is outside 1..count or the part is empty. ["range",a,b] with inclusive bounds returns [416,bytes */total] unless 0<=a<=b<total; otherwise [206,rows] where each intersecting nonempty part yields [part-number,offset-within-part,count] in part order.

split: open-access


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

N = 1
observations = []
def solve(x):
    sizes=x['parts']
    total=sum(sizes)
    starts=[]
    acc=0
    for s in sizes:
        acc+=s
        starts.append(acc)
    q=x['query']
    if q[0]=='part':
        n=q[1]
        if not 1<=n<=len(sizes) or sizes[n-1]==0: return [416,'bytes */%d'%total]
        a=starts[n-1]
        return [206,'bytes %d-%d/%d'%(a,a+sizes[n-1]-1,total)]
    a,b=q[1],q[2]
    if not 0<=a<=b<total: return [416,'bytes */%d'%total]
    out=[]
    for i,s in enumerate(sizes):
        lo=max(a,starts[i])
        hi=min(b,starts[i]+s-1)
        if lo<=hi: out.append([i+1,lo-starts[i],hi-lo+1])
    return [206,out]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('part-prefix-offset fixture 0', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',2]}))), json.loads(json.dumps([206,'bytes 5-7/12'])))
check('part-prefix-offset fixture 1', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',3]}))), json.loads(json.dumps([206,'bytes 8-11/12'])))
check('part-prefix-offset fixture 2', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',0]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-prefix-offset fixture 3', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',-1]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-prefix-offset fixture 4', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',4]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-prefix-offset fixture 5', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['part',2]}))), json.loads(json.dumps([416,'bytes */9'])))
check('part-prefix-offset fixture 6', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',3,9]}))), json.loads(json.dumps([206,[[1,3,2],[2,0,3],[3,0,2]]])))
check('part-prefix-offset fixture 7', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[2,0,1]]])))
check('part-prefix-offset fixture 8', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',5,7]}))), json.loads(json.dumps([206,[[2,0,3]]])))
check('part-prefix-offset fixture 9', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,12]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-prefix-offset fixture 10', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,11]}))), json.loads(json.dumps([206,[[1,0,5],[2,0,3],[3,0,4]]])))
check('part-prefix-offset fixture 11', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[3,0,1]]])))
check('part-prefix-offset fixture 12', json.loads(json.dumps(solve({'parts':[],'query':['part',1]}))), json.loads(json.dumps([416,'bytes */0'])))
check('part-prefix-offset fixture 13', json.loads(json.dumps(solve({'parts':[N,N],'query':['part',2]}))), json.loads(json.dumps([206,"bytes %d-%d/%d"%(N,2*N-1,2*N)])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    sizes=x['parts']
    total=sum(sizes)
    starts=[]
    acc=0
    for s in sizes:
        starts.append(acc)
        acc=s
    q=x['query']
    if q[0]=='part':
        n=q[1]
        if not 1<=n<=len(sizes) or sizes[n-1]==0: return [416,'bytes */%d'%total]
        a=starts[n-1]
        return [206,'bytes %d-%d/%d'%(a,a+sizes[n-1]-1,total)]
    a,b=q[1],q[2]
    if not 0<=a<=b<total: return [416,'bytes */%d'%total]
    out=[]
    for i,s in enumerate(sizes):
        lo=max(a,starts[i])
        hi=min(b,starts[i]+s-1)
        if lo<=hi: out.append([i+1,lo-starts[i],hi-lo+1])
    return [206,out]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('part-prefix-offset fixture 0', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',2]}))), json.loads(json.dumps([206,'bytes 5-7/12'])))
check('part-prefix-offset fixture 1', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',3]}))), json.loads(json.dumps([206,'bytes 8-11/12'])))
check('part-prefix-offset fixture 2', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',0]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-prefix-offset fixture 3', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',-1]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-prefix-offset fixture 4', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',4]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-prefix-offset fixture 5', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['part',2]}))), json.loads(json.dumps([416,'bytes */9'])))
check('part-prefix-offset fixture 6', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',3,9]}))), json.loads(json.dumps([206,[[1,3,2],[2,0,3],[3,0,2]]])))
check('part-prefix-offset fixture 7', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[2,0,1]]])))
check('part-prefix-offset fixture 8', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',5,7]}))), json.loads(json.dumps([206,[[2,0,3]]])))
check('part-prefix-offset fixture 9', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,12]}))), json.loads(json.dumps([416,'bytes */12'])))
check('part-prefix-offset fixture 10', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,11]}))), json.loads(json.dumps([206,[[1,0,5],[2,0,3],[3,0,4]]])))
check('part-prefix-offset fixture 11', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[3,0,1]]])))
check('part-prefix-offset fixture 12', json.loads(json.dumps(solve({'parts':[],'query':['part',1]}))), json.loads(json.dumps([416,'bytes */0'])))
check('part-prefix-offset fixture 13', json.loads(json.dumps(solve({'parts':[N,N],'query':['part',2]}))), json.loads(json.dumps([206,"bytes %d-%d/%d"%(N,2*N-1,2*N)])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An object store maps upload part numbers and byte ranges onto stored parts: a part begins at the sum of all earlier part sizes.

x has stored part sizes in order and a query. ["part",n] (1-based) returns [206,bytes a-b/total] for that part, or [416,bytes */total] when n is outside 1..count or the part is empty. ["range",a,b] with inclusive bounds returns [416,bytes */total] unless 0<=a<=b<total; otherwise [206,rows] where each intersecting nonempty part yields [part-number,offset-within-part,count] in part order.

split: open-access


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

N = 1
observations = []
def solve(x):
    sizes=x['parts']
    total=sum(sizes)
    starts=[]
    acc=0
    for s in sizes:
        starts.append(acc)
        acc+=s
    q=x['query']
    if q[0]=='part':
        n=q[1]
        if not 1<=n<=len(sizes): return [416,'bytes */%d'%total]
        a=starts[n-1]
        return [206,'bytes %d-%d/%d'%(a,a+sizes[n-1]-1,total)]
    a,b=q[1],q[2]
    if not 0<=a<=b<total: return [416,'bytes */%d'%total]
    out=[]
    for i,s in enumerate(sizes):
        lo=max(a,starts[i])
        hi=min(b,starts[i]+s-1)
        if lo<=hi: out.append([i+1,lo-starts[i],hi-lo+1])
    return [206,out]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty-part-unsatisfiable fixture 0', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',2]}))), json.loads(json.dumps([206,'bytes 5-7/12'])))
check('empty-part-unsatisfiable fixture 1', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',3]}))), json.loads(json.dumps([206,'bytes 8-11/12'])))
check('empty-part-unsatisfiable fixture 2', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',0]}))), json.loads(json.dumps([416,'bytes */12'])))
check('empty-part-unsatisfiable fixture 3', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',-1]}))), json.loads(json.dumps([416,'bytes */12'])))
check('empty-part-unsatisfiable fixture 4', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',4]}))), json.loads(json.dumps([416,'bytes */12'])))
check('empty-part-unsatisfiable fixture 5', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['part',2]}))), json.loads(json.dumps([416,'bytes */9'])))
check('empty-part-unsatisfiable fixture 6', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',3,9]}))), json.loads(json.dumps([206,[[1,3,2],[2,0,3],[3,0,2]]])))
check('empty-part-unsatisfiable fixture 7', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[2,0,1]]])))
check('empty-part-unsatisfiable fixture 8', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',5,7]}))), json.loads(json.dumps([206,[[2,0,3]]])))
check('empty-part-unsatisfiable fixture 9', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,12]}))), json.loads(json.dumps([416,'bytes */12'])))
check('empty-part-unsatisfiable fixture 10', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,11]}))), json.loads(json.dumps([206,[[1,0,5],[2,0,3],[3,0,4]]])))
check('empty-part-unsatisfiable fixture 11', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[3,0,1]]])))
check('empty-part-unsatisfiable fixture 12', json.loads(json.dumps(solve({'parts':[],'query':['part',1]}))), json.loads(json.dumps([416,'bytes */0'])))
check('empty-part-unsatisfiable fixture 13', json.loads(json.dumps(solve({'parts':[N,N],'query':['part',2]}))), json.loads(json.dumps([206,"bytes %d-%d/%d"%(N,2*N-1,2*N)])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    sizes=x['parts']
    total=sum(sizes)
    starts=[]
    acc=0
    for s in sizes:
        starts.append(acc)
        acc+=s
    q=x['query']
    if q[0]=='part':
        n=q[1]
        if not 1<=n<=len(sizes) or total==0: return [416,'bytes */%d'%total]
        a=starts[n-1]
        return [206,'bytes %d-%d/%d'%(a,a+sizes[n-1]-1,total)]
    a,b=q[1],q[2]
    if not 0<=a<=b<total: return [416,'bytes */%d'%total]
    out=[]
    for i,s in enumerate(sizes):
        lo=max(a,starts[i])
        hi=min(b,starts[i]+s-1)
        if lo<=hi: out.append([i+1,lo-starts[i],hi-lo+1])
    return [206,out]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('empty-part-unsatisfiable fixture 0', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',2]}))), json.loads(json.dumps([206,'bytes 5-7/12'])))
check('empty-part-unsatisfiable fixture 1', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',3]}))), json.loads(json.dumps([206,'bytes 8-11/12'])))
check('empty-part-unsatisfiable fixture 2', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',0]}))), json.loads(json.dumps([416,'bytes */12'])))
check('empty-part-unsatisfiable fixture 3', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',-1]}))), json.loads(json.dumps([416,'bytes */12'])))
check('empty-part-unsatisfiable fixture 4', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',4]}))), json.loads(json.dumps([416,'bytes */12'])))
check('empty-part-unsatisfiable fixture 5', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['part',2]}))), json.loads(json.dumps([416,'bytes */9'])))
check('empty-part-unsatisfiable fixture 6', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',3,9]}))), json.loads(json.dumps([206,[[1,3,2],[2,0,3],[3,0,2]]])))
check('empty-part-unsatisfiable fixture 7', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[2,0,1]]])))
check('empty-part-unsatisfiable fixture 8', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',5,7]}))), json.loads(json.dumps([206,[[2,0,3]]])))
check('empty-part-unsatisfiable fixture 9', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,12]}))), json.loads(json.dumps([416,'bytes */12'])))
check('empty-part-unsatisfiable fixture 10', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,11]}))), json.loads(json.dumps([206,[[1,0,5],[2,0,3],[3,0,4]]])))
check('empty-part-unsatisfiable fixture 11', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[3,0,1]]])))
check('empty-part-unsatisfiable fixture 12', json.loads(json.dumps(solve({'parts':[],'query':['part',1]}))), json.loads(json.dumps([416,'bytes */0'])))
check('empty-part-unsatisfiable fixture 13', json.loads(json.dumps(solve({'parts':[N,N],'query':['part',2]}))), json.loads(json.dumps([206,"bytes %d-%d/%d"%(N,2*N-1,2*N)])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An object store maps upload part numbers and byte ranges onto stored parts: an empty stored part has no satisfiable byte range.

x has stored part sizes in order and a query. ["part",n] (1-based) returns [206,bytes a-b/total] for that part, or [416,bytes */total] when n is outside 1..count or the part is empty. ["range",a,b] with inclusive bounds returns [416,bytes */total] unless 0<=a<=b<total; otherwise [206,rows] where each intersecting nonempty part yields [part-number,offset-within-part,count] in part order.

split: open-access


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

N = 1
observations = []
def solve(x):
    sizes=x['parts']
    total=sum(sizes)
    starts=[]
    acc=0
    for s in sizes:
        starts.append(acc)
        acc+=s
    q=x['query']
    if q[0]=='part':
        n=q[1]
        if not 1<=n<=len(sizes) or sizes[n-1]==0: return [416,'bytes */%d'%total]
        a=starts[n-1]
        return [206,'bytes %d-%d/%d'%(a,a+sizes[n-1]-1,total)]
    a,b=q[1],q[2]
    if not 0<=a<=b<total: return [416,'bytes */%d'%total]
    out=[]
    for i,s in enumerate(sizes):
        lo=starts[i]
        hi=min(b,starts[i]+s-1)
        if lo<=hi: out.append([i+1,lo-starts[i],hi-lo+1])
    return [206,out]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('overlap-lower-bound fixture 0', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',2]}))), json.loads(json.dumps([206,'bytes 5-7/12'])))
check('overlap-lower-bound fixture 1', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',3]}))), json.loads(json.dumps([206,'bytes 8-11/12'])))
check('overlap-lower-bound fixture 2', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',0]}))), json.loads(json.dumps([416,'bytes */12'])))
check('overlap-lower-bound fixture 3', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',-1]}))), json.loads(json.dumps([416,'bytes */12'])))
check('overlap-lower-bound fixture 4', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',4]}))), json.loads(json.dumps([416,'bytes */12'])))
check('overlap-lower-bound fixture 5', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['part',2]}))), json.loads(json.dumps([416,'bytes */9'])))
check('overlap-lower-bound fixture 6', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',3,9]}))), json.loads(json.dumps([206,[[1,3,2],[2,0,3],[3,0,2]]])))
check('overlap-lower-bound fixture 7', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[2,0,1]]])))
check('overlap-lower-bound fixture 8', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',5,7]}))), json.loads(json.dumps([206,[[2,0,3]]])))
check('overlap-lower-bound fixture 9', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,12]}))), json.loads(json.dumps([416,'bytes */12'])))
check('overlap-lower-bound fixture 10', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,11]}))), json.loads(json.dumps([206,[[1,0,5],[2,0,3],[3,0,4]]])))
check('overlap-lower-bound fixture 11', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[3,0,1]]])))
check('overlap-lower-bound fixture 12', json.loads(json.dumps(solve({'parts':[],'query':['part',1]}))), json.loads(json.dumps([416,'bytes */0'])))
check('overlap-lower-bound fixture 13', json.loads(json.dumps(solve({'parts':[N,N],'query':['part',2]}))), json.loads(json.dumps([206,"bytes %d-%d/%d"%(N,2*N-1,2*N)])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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

N = 1
observations = []
def solve(x):
    sizes=x['parts']
    total=sum(sizes)
    starts=[]
    acc=0
    for s in sizes:
        starts.append(acc)
        acc+=s
    q=x['query']
    if q[0]=='part':
        n=q[1]
        if not 1<=n<=len(sizes) or sizes[n-1]==0: return [416,'bytes */%d'%total]
        a=starts[n-1]
        return [206,'bytes %d-%d/%d'%(a,a+sizes[n-1]-1,total)]
    a,b=q[1],q[2]
    if not 0<=a<=b<total: return [416,'bytes */%d'%total]
    out=[]
    for i,s in enumerate(sizes):
        lo=a
        hi=min(b,starts[i]+s-1)
        if lo<=hi: out.append([i+1,lo-starts[i],hi-lo+1])
    return [206,out]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('overlap-lower-bound fixture 0', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',2]}))), json.loads(json.dumps([206,'bytes 5-7/12'])))
check('overlap-lower-bound fixture 1', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',3]}))), json.loads(json.dumps([206,'bytes 8-11/12'])))
check('overlap-lower-bound fixture 2', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',0]}))), json.loads(json.dumps([416,'bytes */12'])))
check('overlap-lower-bound fixture 3', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',-1]}))), json.loads(json.dumps([416,'bytes */12'])))
check('overlap-lower-bound fixture 4', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['part',4]}))), json.loads(json.dumps([416,'bytes */12'])))
check('overlap-lower-bound fixture 5', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['part',2]}))), json.loads(json.dumps([416,'bytes */9'])))
check('overlap-lower-bound fixture 6', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',3,9]}))), json.loads(json.dumps([206,[[1,3,2],[2,0,3],[3,0,2]]])))
check('overlap-lower-bound fixture 7', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[2,0,1]]])))
check('overlap-lower-bound fixture 8', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',5,7]}))), json.loads(json.dumps([206,[[2,0,3]]])))
check('overlap-lower-bound fixture 9', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,12]}))), json.loads(json.dumps([416,'bytes */12'])))
check('overlap-lower-bound fixture 10', json.loads(json.dumps(solve({'parts':[5,3,4],'query':['range',0,11]}))), json.loads(json.dumps([206,[[1,0,5],[2,0,3],[3,0,4]]])))
check('overlap-lower-bound fixture 11', json.loads(json.dumps(solve({'parts':[5,0,4],'query':['range',4,5]}))), json.loads(json.dumps([206,[[1,4,1],[3,0,1]]])))
check('overlap-lower-bound fixture 12', json.loads(json.dumps(solve({'parts':[],'query':['part',1]}))), json.loads(json.dumps([416,'bytes */0'])))
check('overlap-lower-bound fixture 13', json.loads(json.dumps(solve({'parts':[N,N],'query':['part',2]}))), json.loads(json.dumps([206,"bytes %d-%d/%d"%(N,2*N-1,2*N)])))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
An object store maps upload part numbers and byte ranges onto stored parts: a part intersection begins at the later of range start and part start.

x has stored part sizes in order and a query. ["part",n] (1-based) returns [206,bytes a-b/total] for that part, or [416,bytes */total] when n is outside 1..count or the part is empty. ["range",a,b] with inclusive bounds returns [416,bytes */total] unless 0<=a<=b<total; otherwise [206,rows] where each intersecting nonempty part yields [part-number,offset-within-part,count] in part order.

split: open-access