# HG changeset patch # User Henry Thompson # Date 1754769559 14400 # Node ID 0245bc07f16c3db261445eeac345287e57d1f4ed # Parent 63e87db2bc31127af2aa5a5c8246c47001bc8c28 try to simplify Rows/Cols (do without?) by hiving off the run-counts copletely diff -r 63e87db2bc31 -r 0245bc07f16c nono.py --- a/nono.py Sat Aug 09 15:56:58 2025 -0400 +++ b/nono.py Sat Aug 09 15:59:19 2025 -0400 @@ -10,7 +10,7 @@ # By cases, wrt types of change of a cell in its runs # Change at the margin: # New fill: complete the run and discard it, kill the other end and queue it -# dead: advance margin and add fill to any internal sequences of fills (always?), queue the new fill(s) +# dead: advance margin and append a new fill to any internal sequences of fills (always?), queue the new fill(s) # Change in the middle # New dead: If deterministic, split the run in two and requeue the cell (now in two runs) # fill: If deterministic single gap at any end, kill, split, and requeue the cell (now in two runs) @@ -18,6 +18,7 @@ # Doesn't yet cover everything, e.g. killing gaps that are too small to be filled # Do we need to actually represent run-internal segments, e.g. skips and bars? +# Hypothesis: we only need Columns and Rows for printing import sys @@ -27,8 +28,7 @@ class Run: - '''What we're looking for, converted eventually into what - we've found. + '''What we're looking for, converted eventually into what we've found. "left" and "right" make sense for Rows, for Columns read "above" and "below"''' def __init__(self, n, i, j): @@ -73,9 +73,9 @@ class Vector(list): # reads top-to-bottom or left-to-right - def __init__(self, n, m): + def __init__(self, m, left, right): + self.n = n = (left.x - right.x) + 1 # size list.__init__(self, list(range(n))) - self.n = n # size self.m = m # parent NoNo self.margin0 = 0 # a run can start here, so if >0 then self[m0-1].val must be False self.marginN = n - 1 # a run can end here, so if 9 vertically :-( - self.columns = cc = [Column(n, self, i) for i in range(n)] - self.rows = rr = [Row(n, self, i) for i in range(n)] - for x in range(n): - for y in range(n): - self[x, y] = Cell(rr[y], y, cc[x], x) + self.rows = [[(self[x,y] := Cell(x,y)) for y in range(n)] for x in range(n)] # Need cells in place for the following - for row, runs in zip(rr, runsPerRow): - row.initRuns(runs) - for col, runs in zip(cc, runsPerCol): - col.initRuns(runs) - self.maxCRheight = maxCRheight = max(col.height for col in cc) + maxCRheight = 0 + for i in range(n): + self.initRuns([Cell[i,y] for y in range(n)], runsPerRow[i]) + self.initRuns([Cell[x,i] for x in range(n)], runsPerCol[i]) + maxCRheight = max(maxCRheight = max(col.height for col in cc) + self.maxCRheight = maxCRheight for c in cc: c.updateHeader(maxHeight=maxCRheight) maxRRwidth = max(row.width for row in rr)