(self, x=0)
| 26 | self.nfound = 0 # Instrumentation |
| 27 | |
| 28 | def solve(self, x=0): # Recursive solver |
| 29 | for y in range(self.n): |
| 30 | if self.safe(x, y): |
| 31 | self.place(x, y) |
| 32 | if x+1 == self.n: |
| 33 | self.display() |
| 34 | else: |
| 35 | self.solve(x+1) |
| 36 | self.remove(x, y) |
| 37 | |
| 38 | def safe(self, x, y): |
| 39 | return not self.row[y] and not self.up[x-y] and not self.down[x+y] |