# HG changeset patch # User Henry Thompson # Date 1685398499 -3600 # Node ID 40273cb7c7fc35a11ea46f814cdee9520d56aaee # Parent 68004ce5570392fb574900992751428d3e1729b1 begin trivial approach diff -r 68004ce55703 -r 40273cb7c7fc nono.py --- a/nono.py Mon May 29 22:24:53 2023 +0100 +++ b/nono.py Mon May 29 23:14:59 2023 +0100 @@ -1,19 +1,8 @@ #!/usr/bin/python3 -# Expects e.g. ^A copy from Nonograms dprint preview cols, then blank line, then rows -# rows are space-separated -# cols are one-digit-after-another, unless some 2-digit, in which case x is separator -# E.g. -# 13x1x2 -# 19 -# maps to -# 13 -# 1 1 -# 2 9 # New version, input taken from Nonograms Outer HTML plus # > fgrep 'task = ' nono10.xhtml|tr ';' '\n' | fgrep task\ = | sed 's/^.*= //'| tr -d \' # E.g. 8/5.1/2.3/2.1/4.3/3.4/2/1.1/3/5.2/2.2/2.2/1.3.2/5.1/3.1.1/2/2.3.1/7.1/1.1.2/3.2 - import sys Red='' @@ -33,9 +22,10 @@ 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 space: + for p in range(p+space,p+run): + self[p].setVal(True) + p+=1 + else: + p+=run + p+=1 + def updateHeader(self,*,maxHeight=None,r=None,pre=None): dprint('CuH',r,pre) if maxHeight is None: @@ -497,7 +501,15 @@ lines+=[str(r) for r in self.rows] return "\n".join(lines) +#=============new simple============ + def pass0(self): # do columns of empty layout + for c in self.columns: + c.pass0() + def solve(self): + self.pass0() + print(self) + return someChanged=1 while someChanged>0: self.loop+=1