diff --git a/dlx.py b/dlx.py --- a/dlx.py +++ b/dlx.py @@ -80,13 +80,14 @@ class Header(Column): while c is not row: c.col.cover() c=c.right - self.search(k+1) + if self.search(k+1): return True c=row.left while c is not row: c.col.uncover() c=c.left row=row.down col.uncover() + return False def chooseCol(self): c=self.right @@ -100,11 +101,14 @@ class Header(Column): return res def print(self): + res=[] for r in self._res: - print(r.col.name,end=" ") + res.append([]) + res[-1].append(r.col.name) c=r.right while c is not r: - print(c.col.name,end=" ") + res[-1].append(c.col.name) c=c.right - print() - print() + res[-1].sort(key=str) + for line in res: + print(line)