# HG changeset patch # User Henry S. Thompson # Date 1583870167 0 # Node ID a56d5285575b2c4cbf73653229c2d13ba3420e1b # Parent bd1db1ed4c2514e1553f32d2c0ef7f4b1a077428 drafted Vector.checkNew, still need found0 and foundN diff -r bd1db1ed4c25 -r a56d5285575b nono.py --- a/nono.py Mon Mar 09 17:39:38 2020 +0000 +++ b/nono.py Tue Mar 10 19:56:07 2020 +0000 @@ -25,7 +25,20 @@ def __init__(self,n,m,runs): list.__init__(self,list(range(n))) self.n=n - self.runs=runs + 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 self.marginO and self[s-1].val is True: + s-=1 + f=pos # finish index of our run + while fmargin0+1: + if self[s-1].val is None: + self[s-1].setVal(False) + if s>margin0+2 and self[s-2].val is True: + dprint('n2') + self.checkNew(s-2) # I think@@ + self.foundN(s) # pull in the finish margin at least to s-2 + if changed: + self.resetAllRuns() + + def marginal(self,rng,l): + g=0 # length of a gap + for i in rng: + if self[i].val is True: + return False + if self[i].val is False: + g=0 + else: + # None + g+=1 + if g==l: + return False + return True + class Row(Vector): def __init__(self,n,m,runs,pos,dprintWidth): Vector.__init__(self,n,m,runs) @@ -228,15 +301,18 @@ def setVal(self,v): if v is True: if self.val is False: - dprint("Warning: x -> * at %s,%s"%(self.x,self.y)) + print("Warning: x -> * at %s,%s"%(self.x,self.y),file=sys.stderr) elif self.val is True: # No-op return + self.val=v + self.row.checkNew(self.x) + self.column.checkNew(self.y) # @@ check row/col completed else: if self.val is not None: - dprint("Warning: %s -> %s at %s,%s"%(self.val,v,self.x,self.y)) - self.val=v + print("Warning: %s -> %s at %s,%s"%(self.val,v,self.x,self.y),file=sys.stderr) + self.val=v class Nono(dict): # 0,0 is upper left, so increasing y goes _downwards_, to match the standard layout