FA-51686 / Raster clipping / Open access
Scanline polygon span clip: row sample top · case 01
Rows are sampled at their top edge instead of their pixel-center line.
ROOT CAUSE
Rows are sampled at their top edge instead of their pixel-center line.
VERIFIED REPAIR
Restore the specified clipping decision at row sample top. Each command is [polygon,scissor]. Rows y in the scissor rows [top,bottom) intersected with [0,size) are sampled at y+1/2. Each polygon edge is oriented bottom to top and contributes a crossing when top<=yc<bottom (half-open in y), interpolated exactly. Crossings are sorted and paired even-odd. A pair covers pixels whose centers x+1/2 satisfy xa<=x+1/2<xb, i.e. [ceil(xa-1/2),ceil(xb-1/2)), then clipped to the scissor columns [left,right) intersected with [0,size). Non-empty spans are returned as [row,start,end].
Unsuccessful approach: Sampling the lower row edge moves the error to the opposite side of the pixel.
Case contract
Each command is [polygon,scissor]. Rows y in the scissor rows [top,bottom) intersected with [0,size) are sampled at y+1/2. Each polygon edge is oriented bottom to top and contributes a crossing when top<=yc<bottom (half-open in y), interpolated exactly. Crossings are sorted and paired even-odd. A pair covers pixels whose centers x+1/2 satisfy xa<=x+1/2<xb, i.e. [ceil(xa-1/2),ceil(xb-1/2)), then clipped to the scissor columns [left,right) intersected with [0,size). Non-empty spans are returned as [row,start,end].
Why this case matters
Raster clipping decides which pixels a primitive may touch; a single wrong clip decision writes outside the target or scissor, or silently drops visible coverage.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(commands, size):
out=[]
for poly,clip in commands:
l,t,r,b=max(clip[0],0),max(clip[1],0),min(clip[2],size),min(clip[3],size)
pts=[(Fraction(x),Fraction(y)) for x,y in poly]
spans=[]
for y in range(t,b):
yc=Fraction(y)
xs=[]
for i in range(len(pts)):
(ax,ay),(bx,by)=pts[i-1],pts[i]
if ay>by: ax,ay,bx,by=bx,by,ax,ay
if ay<=yc<by:
xs.append(ax+(bx-ax)*(yc-ay)/(by-ay))
xs.sort()
for j in range(0,len(xs)-1,2):
start=math.ceil(xs[j]-Fraction(1,2))
end=math.ceil(xs[j+1]-Fraction(1,2))
start,end=max(start,l),min(end,r)
if start<end: spans.append([y,start,end])
out.append(spans)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('explicit case 0', solve([[[[1, 1], [5, 1], [5, 5], [1, 5]], [0, 0, 6, 6]]], 6), [[[1, 1, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 6, 6]]], 6), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 6, 6]]], 6), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 6, 6]]], 6), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 6, 6]]], 6), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [6, 0], [6, 6], [0, 6]], [2, 1, 4, 3]]], 6), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 6, 6]]], 6), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [8, 0], [8, 2], [-2, 2]], [0, 0, 6, 6]]], 6), [[[0, 0, 6], [1, 0, 6]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 6, 6]]], 6), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 6, 6]]], 6), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 6, 6]]], 6), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 6, 6]]], 6), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 6, 6]]], 6), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 2:
check('explicit case 0', solve([[[[1, 1], [6, 1], [6, 6], [1, 6]], [0, 0, 7, 7]]], 7), [[[1, 1, 6], [2, 1, 6], [3, 1, 6], [4, 1, 6], [5, 1, 6]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 7, 7]]], 7), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 7, 7]]], 7), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 7, 7]]], 7), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 7, 7]]], 7), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [7, 0], [7, 7], [0, 7]], [2, 1, 4, 3]]], 7), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 7, 7]]], 7), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [9, 0], [9, 2], [-2, 2]], [0, 0, 7, 7]]], 7), [[[0, 0, 7], [1, 0, 7]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 7, 7]]], 7), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 7, 7]]], 7), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 7, 7]]], 7), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 7, 7]]], 7), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 7, 7]]], 7), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 3:
check('explicit case 0', solve([[[[1, 1], [7, 1], [7, 7], [1, 7]], [0, 0, 8, 8]]], 8), [[[1, 1, 7], [2, 1, 7], [3, 1, 7], [4, 1, 7], [5, 1, 7], [6, 1, 7]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 8, 8]]], 8), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 8, 8]]], 8), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 8, 8]]], 8), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 8, 8]]], 8), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [8, 0], [8, 8], [0, 8]], [2, 1, 4, 3]]], 8), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 8, 8]]], 8), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [10, 0], [10, 2], [-2, 2]], [0, 0, 8, 8]]], 8), [[[0, 0, 8], [1, 0, 8]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 8, 8]]], 8), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 8, 8]]], 8), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 8, 8]]], 8), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 8, 8]]], 8), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 8, 8]]], 8), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 4:
check('explicit case 0', solve([[[[1, 1], [8, 1], [8, 8], [1, 8]], [0, 0, 9, 9]]], 9), [[[1, 1, 8], [2, 1, 8], [3, 1, 8], [4, 1, 8], [5, 1, 8], [6, 1, 8], [7, 1, 8]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 9, 9]]], 9), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 9, 9]]], 9), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 9, 9]]], 9), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 9, 9]]], 9), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [9, 0], [9, 9], [0, 9]], [2, 1, 4, 3]]], 9), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 9, 9]]], 9), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [11, 0], [11, 2], [-2, 2]], [0, 0, 9, 9]]], 9), [[[0, 0, 9], [1, 0, 9]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 9, 9]]], 9), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 9, 9]]], 9), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 9, 9]]], 9), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 9, 9]]], 9), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 9, 9]]], 9), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 5:
check('explicit case 0', solve([[[[1, 1], [9, 1], [9, 9], [1, 9]], [0, 0, 10, 10]]], 10), [[[1, 1, 9], [2, 1, 9], [3, 1, 9], [4, 1, 9], [5, 1, 9], [6, 1, 9], [7, 1, 9], [8, 1, 9]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 10, 10]]], 10), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 10, 10]]], 10), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 10, 10]]], 10), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 10, 10]]], 10), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [10, 0], [10, 10], [0, 10]], [2, 1, 4, 3]]], 10), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 10, 10]]], 10), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [12, 0], [12, 2], [-2, 2]], [0, 0, 10, 10]]], 10), [[[0, 0, 10], [1, 0, 10]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 10, 10]]], 10), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 10, 10]]], 10), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 10, 10]]], 10), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 10, 10]]], 10), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 10, 10]]], 10), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit case 0 | [[[1, 1, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]] | [[[1, 1, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]] | Passed |
| explicit case 1 | [[[1, 1, 2], [1, 4, 5], [2, 1, 3], [2, 3, 5], [3, 1, 5], [4, 1, 5]]] | [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]] | Failed |
| explicit case 2 | [[[1, 0, 1], [2, 0, 3], [3, 0, 3], [4, 0, 1]]] | [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]] | Failed |
| explicit case 3 | [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]] | [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]] | Passed |
| explicit case 4 | [[[0, 1, 4], [1, 1, 4]]] | [[[0, 1, 4], [1, 1, 4]]] | Passed |
| explicit case 5 | [[[1, 2, 4], [2, 2, 4]]] | [[[1, 2, 4], [2, 2, 4]]] | Passed |
| explicit case 6 | [[[2, 1, 2], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]] | [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]] | Failed |
| explicit case 7 | [[[0, 0, 6], [1, 0, 6]]] | [[[0, 0, 6], [1, 0, 6]]] | Passed |
| explicit case 8 | [[]] | [[]] | Passed |
| explicit case 9 | [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]] | [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]] | Passed |
| explicit case 10 | [[[0, 1, 2], [1, 1, 2]]] | [[[0, 1, 2], [1, 1, 2]]] | Passed |
| explicit case 11 | [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]] | [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]] | Passed |
| explicit case 12 | [[[0, 0, 5], [1, 0, 5], [2, 0, 3], [2, 3, 5], [3, 0, 2], [3, 4, 5]]] | [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]] | Failed |
SHA-256 / beec39d3603935ae6d8c4d8fe7671e017a0f5855e174e8af282694eb8678c915
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(commands, size):
out=[]
for poly,clip in commands:
l,t,r,b=max(clip[0],0),max(clip[1],0),min(clip[2],size),min(clip[3],size)
pts=[(Fraction(x),Fraction(y)) for x,y in poly]
spans=[]
for y in range(t,b):
yc=Fraction(y+1)
xs=[]
for i in range(len(pts)):
(ax,ay),(bx,by)=pts[i-1],pts[i]
if ay>by: ax,ay,bx,by=bx,by,ax,ay
if ay<=yc<by:
xs.append(ax+(bx-ax)*(yc-ay)/(by-ay))
xs.sort()
for j in range(0,len(xs)-1,2):
start=math.ceil(xs[j]-Fraction(1,2))
end=math.ceil(xs[j+1]-Fraction(1,2))
start,end=max(start,l),min(end,r)
if start<end: spans.append([y,start,end])
out.append(spans)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('explicit case 0', solve([[[[1, 1], [5, 1], [5, 5], [1, 5]], [0, 0, 6, 6]]], 6), [[[1, 1, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 6, 6]]], 6), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 6, 6]]], 6), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 6, 6]]], 6), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 6, 6]]], 6), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [6, 0], [6, 6], [0, 6]], [2, 1, 4, 3]]], 6), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 6, 6]]], 6), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [8, 0], [8, 2], [-2, 2]], [0, 0, 6, 6]]], 6), [[[0, 0, 6], [1, 0, 6]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 6, 6]]], 6), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 6, 6]]], 6), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 6, 6]]], 6), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 6, 6]]], 6), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 6, 6]]], 6), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 2:
check('explicit case 0', solve([[[[1, 1], [6, 1], [6, 6], [1, 6]], [0, 0, 7, 7]]], 7), [[[1, 1, 6], [2, 1, 6], [3, 1, 6], [4, 1, 6], [5, 1, 6]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 7, 7]]], 7), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 7, 7]]], 7), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 7, 7]]], 7), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 7, 7]]], 7), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [7, 0], [7, 7], [0, 7]], [2, 1, 4, 3]]], 7), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 7, 7]]], 7), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [9, 0], [9, 2], [-2, 2]], [0, 0, 7, 7]]], 7), [[[0, 0, 7], [1, 0, 7]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 7, 7]]], 7), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 7, 7]]], 7), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 7, 7]]], 7), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 7, 7]]], 7), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 7, 7]]], 7), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 3:
check('explicit case 0', solve([[[[1, 1], [7, 1], [7, 7], [1, 7]], [0, 0, 8, 8]]], 8), [[[1, 1, 7], [2, 1, 7], [3, 1, 7], [4, 1, 7], [5, 1, 7], [6, 1, 7]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 8, 8]]], 8), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 8, 8]]], 8), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 8, 8]]], 8), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 8, 8]]], 8), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [8, 0], [8, 8], [0, 8]], [2, 1, 4, 3]]], 8), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 8, 8]]], 8), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [10, 0], [10, 2], [-2, 2]], [0, 0, 8, 8]]], 8), [[[0, 0, 8], [1, 0, 8]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 8, 8]]], 8), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 8, 8]]], 8), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 8, 8]]], 8), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 8, 8]]], 8), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 8, 8]]], 8), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 4:
check('explicit case 0', solve([[[[1, 1], [8, 1], [8, 8], [1, 8]], [0, 0, 9, 9]]], 9), [[[1, 1, 8], [2, 1, 8], [3, 1, 8], [4, 1, 8], [5, 1, 8], [6, 1, 8], [7, 1, 8]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 9, 9]]], 9), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 9, 9]]], 9), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 9, 9]]], 9), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 9, 9]]], 9), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [9, 0], [9, 9], [0, 9]], [2, 1, 4, 3]]], 9), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 9, 9]]], 9), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [11, 0], [11, 2], [-2, 2]], [0, 0, 9, 9]]], 9), [[[0, 0, 9], [1, 0, 9]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 9, 9]]], 9), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 9, 9]]], 9), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 9, 9]]], 9), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 9, 9]]], 9), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 9, 9]]], 9), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 5:
check('explicit case 0', solve([[[[1, 1], [9, 1], [9, 9], [1, 9]], [0, 0, 10, 10]]], 10), [[[1, 1, 9], [2, 1, 9], [3, 1, 9], [4, 1, 9], [5, 1, 9], [6, 1, 9], [7, 1, 9], [8, 1, 9]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 10, 10]]], 10), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 10, 10]]], 10), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 10, 10]]], 10), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 10, 10]]], 10), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [10, 0], [10, 10], [0, 10]], [2, 1, 4, 3]]], 10), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 10, 10]]], 10), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [12, 0], [12, 2], [-2, 2]], [0, 0, 10, 10]]], 10), [[[0, 0, 10], [1, 0, 10]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 10, 10]]], 10), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 10, 10]]], 10), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 10, 10]]], 10), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 10, 10]]], 10), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 10, 10]]], 10), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit case 0 | [[[0, 1, 5], [1, 1, 5], [2, 1, 5], [3, 1, 5]]] | [[[1, 1, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]] | Failed |
| explicit case 1 | [[[0, 1, 2], [0, 4, 5], [1, 1, 3], [1, 3, 5], [2, 1, 5], [3, 1, 5]]] | [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]] | Failed |
| explicit case 2 | [[[0, 0, 1], [1, 0, 3], [2, 0, 3], [3, 0, 1]]] | [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]] | Failed |
| explicit case 3 | [[[0, 0, 3], [1, 0, 3]]] | [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]] | Failed |
| explicit case 4 | [[[0, 1, 4]]] | [[[0, 1, 4], [1, 1, 4]]] | Failed |
| explicit case 5 | [[[1, 2, 4], [2, 2, 4]]] | [[[1, 2, 4], [2, 2, 4]]] | Passed |
| explicit case 6 | [[[1, 1, 2], [1, 3, 4], [2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 4]]] | [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]] | Failed |
| explicit case 7 | [[[0, 0, 6]]] | [[[0, 0, 6], [1, 0, 6]]] | Failed |
| explicit case 8 | [[]] | [[]] | Passed |
| explicit case 9 | [[[0, 1, 2], [1, 1, 3], [2, 1, 4]]] | [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]] | Failed |
| explicit case 10 | [[[0, 1, 2]]] | [[[0, 1, 2], [1, 1, 2]]] | Failed |
| explicit case 11 | [[[0, 1, 4], [1, 1, 4], [2, 1, 4]]] | [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]] | Failed |
| explicit case 12 | [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5]]] | [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]] | Failed |
SHA-256 / 5a234fbdfcfff367c03d1cbe825fee7909da160c607bd8d983c14db63c0068a6
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(commands, size):
out=[]
for poly,clip in commands:
l,t,r,b=max(clip[0],0),max(clip[1],0),min(clip[2],size),min(clip[3],size)
pts=[(Fraction(x),Fraction(y)) for x,y in poly]
spans=[]
for y in range(t,b):
yc=y+Fraction(1,2)
xs=[]
for i in range(len(pts)):
(ax,ay),(bx,by)=pts[i-1],pts[i]
if ay>by: ax,ay,bx,by=bx,by,ax,ay
if ay<=yc<by:
xs.append(ax+(bx-ax)*(yc-ay)/(by-ay))
xs.sort()
for j in range(0,len(xs)-1,2):
start=math.ceil(xs[j]-Fraction(1,2))
end=math.ceil(xs[j+1]-Fraction(1,2))
start,end=max(start,l),min(end,r)
if start<end: spans.append([y,start,end])
out.append(spans)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
check('explicit case 0', solve([[[[1, 1], [5, 1], [5, 5], [1, 5]], [0, 0, 6, 6]]], 6), [[[1, 1, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 6, 6]]], 6), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 6, 6]]], 6), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 6, 6]]], 6), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 6, 6]]], 6), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [6, 0], [6, 6], [0, 6]], [2, 1, 4, 3]]], 6), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 6, 6]]], 6), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [8, 0], [8, 2], [-2, 2]], [0, 0, 6, 6]]], 6), [[[0, 0, 6], [1, 0, 6]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 6, 6]]], 6), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 6, 6]]], 6), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 6, 6]]], 6), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 6, 6]]], 6), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 6, 6]]], 6), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 2:
check('explicit case 0', solve([[[[1, 1], [6, 1], [6, 6], [1, 6]], [0, 0, 7, 7]]], 7), [[[1, 1, 6], [2, 1, 6], [3, 1, 6], [4, 1, 6], [5, 1, 6]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 7, 7]]], 7), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 7, 7]]], 7), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 7, 7]]], 7), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 7, 7]]], 7), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [7, 0], [7, 7], [0, 7]], [2, 1, 4, 3]]], 7), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 7, 7]]], 7), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [9, 0], [9, 2], [-2, 2]], [0, 0, 7, 7]]], 7), [[[0, 0, 7], [1, 0, 7]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 7, 7]]], 7), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 7, 7]]], 7), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 7, 7]]], 7), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 7, 7]]], 7), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 7, 7]]], 7), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 3:
check('explicit case 0', solve([[[[1, 1], [7, 1], [7, 7], [1, 7]], [0, 0, 8, 8]]], 8), [[[1, 1, 7], [2, 1, 7], [3, 1, 7], [4, 1, 7], [5, 1, 7], [6, 1, 7]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 8, 8]]], 8), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 8, 8]]], 8), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 8, 8]]], 8), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 8, 8]]], 8), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [8, 0], [8, 8], [0, 8]], [2, 1, 4, 3]]], 8), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 8, 8]]], 8), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [10, 0], [10, 2], [-2, 2]], [0, 0, 8, 8]]], 8), [[[0, 0, 8], [1, 0, 8]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 8, 8]]], 8), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 8, 8]]], 8), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 8, 8]]], 8), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 8, 8]]], 8), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 8, 8]]], 8), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 4:
check('explicit case 0', solve([[[[1, 1], [8, 1], [8, 8], [1, 8]], [0, 0, 9, 9]]], 9), [[[1, 1, 8], [2, 1, 8], [3, 1, 8], [4, 1, 8], [5, 1, 8], [6, 1, 8], [7, 1, 8]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 9, 9]]], 9), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 9, 9]]], 9), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 9, 9]]], 9), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 9, 9]]], 9), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [9, 0], [9, 9], [0, 9]], [2, 1, 4, 3]]], 9), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 9, 9]]], 9), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [11, 0], [11, 2], [-2, 2]], [0, 0, 9, 9]]], 9), [[[0, 0, 9], [1, 0, 9]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 9, 9]]], 9), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 9, 9]]], 9), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 9, 9]]], 9), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 9, 9]]], 9), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 9, 9]]], 9), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
if N == 5:
check('explicit case 0', solve([[[[1, 1], [9, 1], [9, 9], [1, 9]], [0, 0, 10, 10]]], 10), [[[1, 1, 9], [2, 1, 9], [3, 1, 9], [4, 1, 9], [5, 1, 9], [6, 1, 9], [7, 1, 9], [8, 1, 9]]])
check('explicit case 1', solve([[[[1, 0], [3, '5/2'], [5, 0], [5, 5], [1, 5]], [0, 0, 10, 10]]], 10), [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]])
check('explicit case 2', solve([[[[0, '1/2'], [4, '5/2'], [0, '9/2']], [0, 0, 10, 10]]], 10), [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]])
check('explicit case 3', solve([[[['1/2', 0], ['7/2', 0], ['7/2', 3], ['1/2', 3]], [0, 0, 10, 10]]], 10), [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]])
check('explicit case 4', solve([[[['3/2', 0], ['9/2', 0], ['9/2', 2], ['3/2', 2]], [0, 0, 10, 10]]], 10), [[[0, 1, 4], [1, 1, 4]]])
check('explicit case 5', solve([[[[0, 0], [10, 0], [10, 10], [0, 10]], [2, 1, 4, 3]]], 10), [[[1, 2, 4], [2, 2, 4]]])
check('explicit case 6', solve([[[[0, 0], [1, 4], [2, 0], [3, 4], [4, 0], [4, 5], [0, 5]], [0, 0, 10, 10]]], 10), [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]])
check('explicit case 7', solve([[[[-2, 0], [12, 0], [12, 2], [-2, 2]], [0, 0, 10, 10]]], 10), [[[0, 0, 10], [1, 0, 10]]])
check('explicit case 8', solve([[[[0, 0], [2, 0], [2, 2], [0, 2]], [3, 0, 10, 10]]], 10), [[]])
check('explicit case 9', solve([[[[1, 0], [5, 4], [1, 4]], [0, 0, 10, 10]]], 10), [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]])
check('explicit case 10', solve([[[['1/4', 0], ['5/2', 0], ['5/2', 2], ['1/4', 2]], [1, 0, 10, 10]]], 10), [[[0, 1, 2], [1, 1, 2]]])
check('explicit case 11', solve([[[[4, 1], [4, 4], [1, 4], [1, 1]], [0, 0, 10, 10]]], 10), [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]])
check('explicit case 12', solve([[[[0, 0], [5, 0], [5, 4], [3, '3/2'], [1, 4], [0, 4]], [0, 0, 10, 10]]], 10), [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| explicit case 0 | [[[1, 1, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]] | [[[1, 1, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]] | Passed |
| explicit case 1 | [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]] | [[[1, 1, 2], [1, 4, 5], [2, 1, 5], [3, 1, 5], [4, 1, 5]]] | Passed |
| explicit case 2 | [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]] | [[[1, 0, 2], [2, 0, 4], [3, 0, 2]]] | Passed |
| explicit case 3 | [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]] | [[[0, 0, 3], [1, 0, 3], [2, 0, 3]]] | Passed |
| explicit case 4 | [[[0, 1, 4], [1, 1, 4]]] | [[[0, 1, 4], [1, 1, 4]]] | Passed |
| explicit case 5 | [[[1, 2, 4], [2, 2, 4]]] | [[[1, 2, 4], [2, 2, 4]]] | Passed |
| explicit case 6 | [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]] | [[[2, 0, 1], [2, 1, 3], [2, 3, 4], [3, 0, 1], [3, 1, 3], [3, 3, 4], [4, 0, 4]]] | Passed |
| explicit case 7 | [[[0, 0, 6], [1, 0, 6]]] | [[[0, 0, 6], [1, 0, 6]]] | Passed |
| explicit case 8 | [[]] | [[]] | Passed |
| explicit case 9 | [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]] | [[[1, 1, 2], [2, 1, 3], [3, 1, 4]]] | Passed |
| explicit case 10 | [[[0, 1, 2], [1, 1, 2]]] | [[[0, 1, 2], [1, 1, 2]]] | Passed |
| explicit case 11 | [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]] | [[[1, 1, 4], [2, 1, 4], [3, 1, 4]]] | Passed |
| explicit case 12 | [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]] | [[[0, 0, 5], [1, 0, 3], [1, 3, 5], [2, 0, 2], [2, 4, 5], [3, 0, 1]]] | Passed |
SHA-256 / 711b1a6a7773b7911b36539d16025d30d3aa9f00b98844921c0cd2ce19658a0a
Verification & scope
Exact integer/rational arithmetic on small stipulated fixtures models the clipping decision only; no memory layout, GPU pipeline, graphics API or standards conformance is claimed. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:45:21.313706+00:00.
Case digest / ccb3f0b54aa9a14c949d1b2e9e04497710f409ee0bae5adc6f80a2e89877231b