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

N = 1
observations = []
def solve(commands, size):
    out=[]
    for events,rule,inverse in commands:
        deltas={}
        for x,delta in events: deltas[x]=deltas.get(x,0)+delta
        winding=sum(delta for x,delta in deltas.items() if x<0)
        covered=[]
        for x in range(size):
            winding=deltas.get(x,0)
            if rule=='nonzero': inside=winding!=0
            elif rule=='odd': inside=abs(winding)%2==1
            elif rule=='positive': inside=winding>0
            elif rule=='negative': inside=winding<0
            else: inside=abs(winding)>=2
            if inside ^ inverse: covered.append(x)
        out.append(covered)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 4), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 4), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 4), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 4), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 4), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 4), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 4), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 4), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 4), [[2, 3]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 4), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 4), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 4), [[]])
if N == 2:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 5), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 5), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 5), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 5), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 5), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 5), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 5), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 5), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 5), [[2, 3, 4]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 5), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 5), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 5), [[]])
if N == 3:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 6), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 6), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 6), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 6), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 6), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 6), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 6), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 6), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 6), [[2, 3, 4, 5]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 6), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 6), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 6), [[]])
if N == 4:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 7), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 7), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 7), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 7), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 7), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 7), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 7), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 7), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 7), [[2, 3, 4, 5, 6]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 7), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 7), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 7), [[]])
if N == 5:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 8), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 8), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 8), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 8), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 8), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 8), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 8), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 8), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 8), [[2, 3, 4, 5, 6, 7]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 8), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 8), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 8), [[]])
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(commands, size):
    out=[]
    for events,rule,inverse in commands:
        deltas={}
        for x,delta in events: deltas[x]=deltas.get(x,0)+delta
        winding=sum(delta for x,delta in deltas.items() if x<0)
        covered=[]
        for x in range(size):
            winding=deltas.get(x,winding)
            if rule=='nonzero': inside=winding!=0
            elif rule=='odd': inside=abs(winding)%2==1
            elif rule=='positive': inside=winding>0
            elif rule=='negative': inside=winding<0
            else: inside=abs(winding)>=2
            if inside ^ inverse: covered.append(x)
        out.append(covered)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 4), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 4), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 4), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 4), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 4), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 4), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 4), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 4), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 4), [[2, 3]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 4), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 4), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 4), [[]])
if N == 2:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 5), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 5), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 5), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 5), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 5), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 5), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 5), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 5), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 5), [[2, 3, 4]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 5), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 5), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 5), [[]])
if N == 3:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 6), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 6), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 6), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 6), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 6), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 6), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 6), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 6), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 6), [[2, 3, 4, 5]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 6), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 6), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 6), [[]])
if N == 4:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 7), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 7), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 7), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 7), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 7), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 7), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 7), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 7), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 7), [[2, 3, 4, 5, 6]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 7), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 7), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 7), [[]])
if N == 5:
    check('explicit sequence 0', solve([[[[0, 1], [0, 1], [2, -2]], 'nonzero', False]], 8), [[0, 1]])
    check('explicit sequence 1', solve([[[[-3, 1], [2, -1]], 'nonzero', False]], 8), [[0, 1]])
    check('explicit sequence 2', solve([[[[0, 1], [2, -1]], 'nonzero', False]], 8), [[0, 1]])
    check('explicit sequence 3', solve([[[[0, -1], [2, 1]], 'nonzero', False]], 8), [[0, 1]])
    check('explicit sequence 4', solve([[[[0, 3], [2, -3]], 'odd', False]], 8), [[0, 1]])
    check('explicit sequence 5', solve([[[[0, 2], [2, -2]], 'positive', False]], 8), [[0, 1]])
    check('explicit sequence 6', solve([[[[0, -2], [2, 2]], 'negative', False]], 8), [[0, 1]])
    check('explicit sequence 7', solve([[[[0, -3], [2, 3]], 'double', False]], 8), [[0, 1]])
    check('explicit sequence 8', solve([[[[0, 1], [2, -1]], 'nonzero', True]], 8), [[2, 3, 4, 5, 6, 7]])
    check('explicit sequence 9', solve([[[[0, 1], [1, 1], [3, -2]], 'nonzero', False]], 8), [[0, 1, 2]])
    check('explicit sequence 10', solve([[[[0, 1], [0, -1]], 'nonzero', False]], 8), [[]])
    check('explicit sequence 11', solve([[[], 'odd', False]], 8), [[]])
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:
Winding is recomputed from each local crossing rather than carried across the span.

Signed crossing events occur before their integer sample coordinate. For each finite target sample, sum all event deltas at or to its left, including events outside the left target edge. Fill rules are nonzero, odd, positive, negative, or magnitude-at-least-two. Inverse filling complements the result inside the target. Zero deltas are inert and coincident events add.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    from fractions import Fraction
    out=[]
    for first,last,planes in commands:
        a=list(map(Fraction,first)); b=list(map(Fraction,last))
        original_a=list(a); original_b=list(b)
        rejected=False
        for plane in planes:
            def distance(p):
                if plane=='left': return p[0]+size*p[1]
                if plane=='right': return size*p[1]-p[0]
                return p[1]-1
            da=distance(a); db=distance(b)
            ia=da>=0; ib=db>=0
            if not ia or not ib: rejected=True; break
            if ia and ib: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point
            else: b=point
        out.append(None if rejected else [[str(v) for v in a],[str(v) for v in b]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 4), [[['-4', '1', '8'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 4), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 4), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 4), [[['-4', '1', '8'], ['4', '1', '16']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 4), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 4), [[['0', '1', '12'], ['6', '3/2', '18']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 4), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 4), [[['0', '1', '12'], ['40/9', '10/9', '40/3']]])
if N == 2:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 5), [[['-5', '1', '7'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 5), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 5), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 5), [[['-5', '1', '7'], ['5', '1', '17']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 5), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 5), [[['0', '1', '12'], ['60/7', '12/7', '144/7']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 5), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 5), [[['0', '1', '12'], ['40/7', '8/7', '96/7']]])
if N == 3:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 6), [[['-6', '1', '6'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 6), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 6), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 6), [[['-6', '1', '6'], ['6', '1', '18']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 6), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 6), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 6), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 6), [[['0', '1', '12'], ['120/17', '20/17', '240/17']]])
if N == 4:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 7), [[['-7', '1', '5'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 7), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 7), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 7), [[['-7', '1', '5'], ['7', '1', '19']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 7), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 7), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 7), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 7), [[['0', '1', '12'], ['280/33', '40/33', '160/11']]])
if N == 5:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 8), [[['-8', '1', '4'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 8), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 8), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 8), [[['-8', '1', '4'], ['8', '1', '20']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 8), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 8), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 8), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 8), [[['0', '1', '12'], ['10', '5/4', '15']]])
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(commands, size):
    from fractions import Fraction
    out=[]
    for first,last,planes in commands:
        a=list(map(Fraction,first)); b=list(map(Fraction,last))
        original_a=list(a); original_b=list(b)
        rejected=False
        for plane in planes:
            def distance(p):
                if plane=='left': return p[0]+size*p[1]
                if plane=='right': return size*p[1]-p[0]
                return p[1]-1
            da=distance(a); db=distance(b)
            ia=da>=0; ib=db>=0
            if (not ia or not ib) and da!=0 and db!=0: rejected=True; break
            if ia and ib: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point
            else: b=point
        out.append(None if rejected else [[str(v) for v in a],[str(v) for v in b]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 4), [[['-4', '1', '8'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 4), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 4), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 4), [[['-4', '1', '8'], ['4', '1', '16']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 4), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 4), [[['0', '1', '12'], ['6', '3/2', '18']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 4), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 4), [[['0', '1', '12'], ['40/9', '10/9', '40/3']]])
if N == 2:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 5), [[['-5', '1', '7'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 5), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 5), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 5), [[['-5', '1', '7'], ['5', '1', '17']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 5), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 5), [[['0', '1', '12'], ['60/7', '12/7', '144/7']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 5), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 5), [[['0', '1', '12'], ['40/7', '8/7', '96/7']]])
if N == 3:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 6), [[['-6', '1', '6'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 6), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 6), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 6), [[['-6', '1', '6'], ['6', '1', '18']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 6), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 6), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 6), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 6), [[['0', '1', '12'], ['120/17', '20/17', '240/17']]])
if N == 4:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 7), [[['-7', '1', '5'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 7), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 7), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 7), [[['-7', '1', '5'], ['7', '1', '19']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 7), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 7), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 7), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 7), [[['0', '1', '12'], ['280/33', '40/33', '160/11']]])
if N == 5:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 8), [[['-8', '1', '4'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 8), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 8), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 8), [[['-8', '1', '4'], ['8', '1', '20']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 8), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 8), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 8), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 8), [[['0', '1', '12'], ['10', '5/4', '15']]])
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 crossing a clip plane is rejected when only one endpoint is outside.

Clip ordered segments in homogeneous (x,w,u) coordinates against requested left x+w>=0, right w-x>=0 and eye w>=1 halfspaces. Interpolate every component at intersections before perspective division; retain endpoint order. Output exact rational strings, or null for rejected segments. The integer surface size scales horizontal halfspaces.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    from fractions import Fraction
    out=[]
    for first,last,planes in commands:
        a=list(map(Fraction,first)); b=list(map(Fraction,last))
        original_a=list(a); original_b=list(b)
        rejected=False
        for plane in planes:
            def distance(p):
                if plane=='left': return p[0]+size*p[1]
                if plane=='right': return size*p[1]-p[0]
                return p[1]-1
            da=distance(a); db=distance(b)
            ia=da>=0; ib=db>=0
            if not ia and not ib: rejected=False; break
            if ia and ib: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point
            else: b=point
        out.append(None if rejected else [[str(v) for v in a],[str(v) for v in b]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 4), [[['-4', '1', '8'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 4), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 4), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 4), [[['-4', '1', '8'], ['4', '1', '16']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 4), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 4), [[['0', '1', '12'], ['6', '3/2', '18']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 4), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 4), [[['0', '1', '12'], ['40/9', '10/9', '40/3']]])
if N == 2:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 5), [[['-5', '1', '7'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 5), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 5), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 5), [[['-5', '1', '7'], ['5', '1', '17']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 5), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 5), [[['0', '1', '12'], ['60/7', '12/7', '144/7']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 5), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 5), [[['0', '1', '12'], ['40/7', '8/7', '96/7']]])
if N == 3:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 6), [[['-6', '1', '6'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 6), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 6), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 6), [[['-6', '1', '6'], ['6', '1', '18']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 6), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 6), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 6), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 6), [[['0', '1', '12'], ['120/17', '20/17', '240/17']]])
if N == 4:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 7), [[['-7', '1', '5'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 7), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 7), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 7), [[['-7', '1', '5'], ['7', '1', '19']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 7), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 7), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 7), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 7), [[['0', '1', '12'], ['280/33', '40/33', '160/11']]])
if N == 5:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 8), [[['-8', '1', '4'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 8), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 8), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 8), [[['-8', '1', '4'], ['8', '1', '20']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 8), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 8), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 8), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 8), [[['0', '1', '12'], ['10', '5/4', '15']]])
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(commands, size):
    from fractions import Fraction
    out=[]
    for first,last,planes in commands:
        a=list(map(Fraction,first)); b=list(map(Fraction,last))
        original_a=list(a); original_b=list(b)
        rejected=False
        for plane in planes:
            def distance(p):
                if plane=='left': return p[0]+size*p[1]
                if plane=='right': return size*p[1]-p[0]
                return p[1]-1
            da=distance(a); db=distance(b)
            ia=da>=0; ib=db>=0
            if not ia and not ib: rejected=da<db; break
            if ia and ib: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point
            else: b=point
        out.append(None if rejected else [[str(v) for v in a],[str(v) for v in b]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 4), [[['-4', '1', '8'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 4), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 4), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 4), [[['-4', '1', '8'], ['4', '1', '16']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 4), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 4), [[['0', '1', '12'], ['6', '3/2', '18']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 4), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 4), [[['0', '1', '12'], ['40/9', '10/9', '40/3']]])
if N == 2:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 5), [[['-5', '1', '7'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 5), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 5), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 5), [[['-5', '1', '7'], ['5', '1', '17']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 5), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 5), [[['0', '1', '12'], ['60/7', '12/7', '144/7']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 5), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 5), [[['0', '1', '12'], ['40/7', '8/7', '96/7']]])
if N == 3:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 6), [[['-6', '1', '6'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 6), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 6), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 6), [[['-6', '1', '6'], ['6', '1', '18']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 6), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 6), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 6), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 6), [[['0', '1', '12'], ['120/17', '20/17', '240/17']]])
if N == 4:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 7), [[['-7', '1', '5'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 7), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 7), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 7), [[['-7', '1', '5'], ['7', '1', '19']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 7), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 7), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 7), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 7), [[['0', '1', '12'], ['280/33', '40/33', '160/11']]])
if N == 5:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 8), [[['-8', '1', '4'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 8), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 8), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 8), [[['-8', '1', '4'], ['8', '1', '20']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 8), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 8), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 8), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 8), [[['0', '1', '12'], ['10', '5/4', '15']]])
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:
Segments entirely outside a halfspace are returned unchanged.

Clip ordered segments in homogeneous (x,w,u) coordinates against requested left x+w>=0, right w-x>=0 and eye w>=1 halfspaces. Interpolate every component at intersections before perspective division; retain endpoint order. Output exact rational strings, or null for rejected segments. The integer surface size scales horizontal halfspaces.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    from fractions import Fraction
    out=[]
    for first,last,planes in commands:
        a=list(map(Fraction,first)); b=list(map(Fraction,last))
        original_a=list(a); original_b=list(b)
        rejected=False
        for plane in planes:
            def distance(p):
                if plane=='left': return p[0]+size*p[1]
                if plane=='right': return size*p[1]-p[0]
                return p[1]-1
            da=distance(a); db=distance(b)
            ia=da>=0; ib=db>=0
            if not ia and not ib: rejected=True; break
            if ia or ib: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point
            else: b=point
        out.append(None if rejected else [[str(v) for v in a],[str(v) for v in b]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 4), [[['-4', '1', '8'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 4), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 4), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 4), [[['-4', '1', '8'], ['4', '1', '16']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 4), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 4), [[['0', '1', '12'], ['6', '3/2', '18']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 4), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 4), [[['0', '1', '12'], ['40/9', '10/9', '40/3']]])
if N == 2:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 5), [[['-5', '1', '7'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 5), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 5), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 5), [[['-5', '1', '7'], ['5', '1', '17']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 5), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 5), [[['0', '1', '12'], ['60/7', '12/7', '144/7']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 5), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 5), [[['0', '1', '12'], ['40/7', '8/7', '96/7']]])
if N == 3:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 6), [[['-6', '1', '6'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 6), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 6), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 6), [[['-6', '1', '6'], ['6', '1', '18']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 6), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 6), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 6), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 6), [[['0', '1', '12'], ['120/17', '20/17', '240/17']]])
if N == 4:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 7), [[['-7', '1', '5'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 7), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 7), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 7), [[['-7', '1', '5'], ['7', '1', '19']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 7), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 7), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 7), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 7), [[['0', '1', '12'], ['280/33', '40/33', '160/11']]])
if N == 5:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 8), [[['-8', '1', '4'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 8), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 8), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 8), [[['-8', '1', '4'], ['8', '1', '20']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 8), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 8), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 8), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 8), [[['0', '1', '12'], ['10', '5/4', '15']]])
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(commands, size):
    from fractions import Fraction
    out=[]
    for first,last,planes in commands:
        a=list(map(Fraction,first)); b=list(map(Fraction,last))
        original_a=list(a); original_b=list(b)
        rejected=False
        for plane in planes:
            def distance(p):
                if plane=='left': return p[0]+size*p[1]
                if plane=='right': return size*p[1]-p[0]
                return p[1]-1
            da=distance(a); db=distance(b)
            ia=da>=0; ib=db>=0
            if not ia and not ib: rejected=True; break
            if ia and ib: break
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point
            else: b=point
        out.append(None if rejected else [[str(v) for v in a],[str(v) for v in b]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 4), [[['-4', '1', '8'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 4), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 4), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 4), [[['-4', '1', '8'], ['4', '1', '16']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 4), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 4), [[['0', '1', '12'], ['6', '3/2', '18']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 4), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 4), [[['0', '1', '12'], ['40/9', '10/9', '40/3']]])
if N == 2:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 5), [[['-5', '1', '7'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 5), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 5), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 5), [[['-5', '1', '7'], ['5', '1', '17']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 5), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 5), [[['0', '1', '12'], ['60/7', '12/7', '144/7']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 5), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 5), [[['0', '1', '12'], ['40/7', '8/7', '96/7']]])
if N == 3:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 6), [[['-6', '1', '6'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 6), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 6), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 6), [[['-6', '1', '6'], ['6', '1', '18']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 6), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 6), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 6), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 6), [[['0', '1', '12'], ['120/17', '20/17', '240/17']]])
if N == 4:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 7), [[['-7', '1', '5'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 7), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 7), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 7), [[['-7', '1', '5'], ['7', '1', '19']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 7), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 7), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 7), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 7), [[['0', '1', '12'], ['280/33', '40/33', '160/11']]])
if N == 5:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 8), [[['-8', '1', '4'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 8), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 8), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 8), [[['-8', '1', '4'], ['8', '1', '20']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 8), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 8), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 8), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 8), [[['0', '1', '12'], ['10', '5/4', '15']]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The all-inside fast path accepts a segment with one exterior endpoint.

Clip ordered segments in homogeneous (x,w,u) coordinates against requested left x+w>=0, right w-x>=0 and eye w>=1 halfspaces. Interpolate every component at intersections before perspective division; retain endpoint order. Output exact rational strings, or null for rejected segments. The integer surface size scales horizontal halfspaces.

split: open-access


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

N = 1
observations = []
def solve(commands, size):
    from fractions import Fraction
    out=[]
    for first,last,planes in commands:
        a=list(map(Fraction,first)); b=list(map(Fraction,last))
        original_a=list(a); original_b=list(b)
        rejected=False
        for plane in planes:
            def distance(p):
                if plane=='left': return p[0]+size*p[1]
                if plane=='right': return size*p[1]-p[0]
                return p[1]-1
            da=distance(a); db=distance(b)
            ia=da>0; ib=db>0
            if not ia and not ib: rejected=True; break
            if ia and ib: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point
            else: b=point
        out.append(None if rejected else [[str(v) for v in a],[str(v) for v in b]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 4), [[['-4', '1', '8'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 4), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 4), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 4), [[['-4', '1', '8'], ['4', '1', '16']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 4), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 4), [[['0', '1', '12'], ['6', '3/2', '18']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 4), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 4), [[['0', '1', '12'], ['40/9', '10/9', '40/3']]])
if N == 2:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 5), [[['-5', '1', '7'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 5), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 5), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 5), [[['-5', '1', '7'], ['5', '1', '17']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 5), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 5), [[['0', '1', '12'], ['60/7', '12/7', '144/7']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 5), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 5), [[['0', '1', '12'], ['40/7', '8/7', '96/7']]])
if N == 3:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 6), [[['-6', '1', '6'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 6), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 6), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 6), [[['-6', '1', '6'], ['6', '1', '18']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 6), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 6), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 6), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 6), [[['0', '1', '12'], ['120/17', '20/17', '240/17']]])
if N == 4:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 7), [[['-7', '1', '5'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 7), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 7), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 7), [[['-7', '1', '5'], ['7', '1', '19']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 7), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 7), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 7), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 7), [[['0', '1', '12'], ['280/33', '40/33', '160/11']]])
if N == 5:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 8), [[['-8', '1', '4'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 8), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 8), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 8), [[['-8', '1', '4'], ['8', '1', '20']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 8), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 8), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 8), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 8), [[['0', '1', '12'], ['10', '5/4', '15']]])
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(commands, size):
    from fractions import Fraction
    out=[]
    for first,last,planes in commands:
        a=list(map(Fraction,first)); b=list(map(Fraction,last))
        original_a=list(a); original_b=list(b)
        rejected=False
        for plane in planes:
            def distance(p):
                if plane=='left': return p[0]+size*p[1]
                if plane=='right': return size*p[1]-p[0]
                return p[1]-1
            da=distance(a); db=distance(b)
            ia=da>=0; ib=(db>=0 if da>=0 else db>0)
            if not ia and not ib: rejected=True; break
            if ia and ib: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point
            else: b=point
        out.append(None if rejected else [[str(v) for v in a],[str(v) for v in b]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 4), [[['-4', '1', '8'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 4), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 4), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 4), [[['-4', '1', '8'], ['4', '1', '16']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 4), [[['0', '1', '0'], ['4', '1', '4']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 4), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 4), [[['0', '1', '12'], ['6', '3/2', '18']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 4), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 4), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 4), [[['0', '1', '12'], ['40/9', '10/9', '40/3']]])
if N == 2:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 5), [[['-5', '1', '7'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 5), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 5), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 5), [[['-5', '1', '7'], ['5', '1', '17']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 5), [[['0', '1', '0'], ['5', '1', '5']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 5), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 5), [[['0', '1', '12'], ['60/7', '12/7', '144/7']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 5), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 5), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 5), [[['0', '1', '12'], ['40/7', '8/7', '96/7']]])
if N == 3:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 6), [[['-6', '1', '6'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 6), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 6), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 6), [[['-6', '1', '6'], ['6', '1', '18']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 6), [[['0', '1', '0'], ['6', '1', '6']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 6), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 6), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 6), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 6), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 6), [[['0', '1', '12'], ['120/17', '20/17', '240/17']]])
if N == 4:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 7), [[['-7', '1', '5'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 7), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 7), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 7), [[['-7', '1', '5'], ['7', '1', '19']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 7), [[['0', '1', '0'], ['7', '1', '7']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 7), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 7), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 7), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 7), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 7), [[['0', '1', '12'], ['280/33', '40/33', '160/11']]])
if N == 5:
    check('explicit sequence 0', solve([[[-12, 1, 0], [0, 1, 12], ['left']]], 8), [[['-8', '1', '4'], ['0', '1', '12']]])
    check('explicit sequence 1', solve([[[0, 1, 0], [12, 1, 12], ['right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 2', solve([[[-20, 1, 0], [-15, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 3', solve([[[-4, 1, 0], [-8, 2, 8], ['left']]], 8), [[['-4', '1', '0'], ['-8', '2', '8']]])
    check('explicit sequence 4', solve([[[0, 0, 0], [0, 2, 10], ['eye']]], 8), [[['0', '1', '5'], ['0', '2', '10']]])
    check('explicit sequence 5', solve([[[-12, 1, 0], [12, 1, 24], ['left', 'right']]], 8), [[['-8', '1', '4'], ['8', '1', '20']]])
    check('explicit sequence 6', solve([[[0, 1, 0], [12, 1, 12], ['left', 'right']]], 8), [[['0', '1', '0'], ['8', '1', '8']]])
    check('explicit sequence 7', solve([[[0, 1, 0], [1, 1, 1], ['eye', 'left', 'right']]], 8), [[['0', '1', '0'], ['1', '1', '1']]])
    check('explicit sequence 8', solve([[[-12, 0, 0], [12, 2, 24], ['left', 'right', 'eye']]], 8), [[['0', '1', '12'], ['12', '2', '24']]])
    check('explicit sequence 9', solve([[[-15, 1, 0], [-20, 1, 5], ['left']]], 8), [None])
    check('explicit sequence 10', solve([[[0, 0, 0], [0, 1, 1], ['eye']]], 8), [[['0', '1', '1'], ['0', '1', '1']]])
    check('explicit sequence 11', solve([[[-40, 0, 0], [40, 2, 24], ['right', 'eye']]], 8), [[['0', '1', '12'], ['10', '5/4', '15']]])
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:
Segments lying exactly on a clip plane are rejected as outside.

Clip ordered segments in homogeneous (x,w,u) coordinates against requested left x+w>=0, right w-x>=0 and eye w>=1 halfspaces. Interpolate every component at intersections before perspective division; retain endpoint order. Output exact rational strings, or null for rejected segments. The integer surface size scales horizontal halfspaces.

split: open-access