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) if da+db else Fraction(0)
            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: continue
            t=da/(abs(da)+abs(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:
Intersection divides by summed endpoint distances rather than their difference.

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=Fraction(int(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 and not ib: rejected=True; break
            if ia and ib: continue
            t=Fraction(round(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:
Integer conversion snaps a crossing intersection to an 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]) if i<2 else 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: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) if i<2 else b[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:
Clipping interpolates position but leaves the vertex attribute at the original 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: b=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: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point; b=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:
An entering intersection replaces the inside endpoint and retains the outside 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: a=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: continue
            t=da/(da-db)
            point=[a[i]+t*(b[i]-a[i]) for i in range(3)]
            if not ia: a=point
            else: a=point; 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 leaving intersection replaces the inside endpoint and retains the outside 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