Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move early bailouts to top of file

  • Loading branch information...
commit f47fe62cb85899b4a33f5123d6d790b039ed901c 1 parent f55ce53
@apauley authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 sudoku.py
View
5 sudoku.py
@@ -61,10 +61,11 @@ def eliminate(values, square, digit):
if digit not in values[square]:
return values ## Already eliminated
values[square] = values[square].replace(digit, '')
- ## (1) If a square is reduced to one value d2, then eliminate d2 from the peers.
if len(values[square]) == 0:
return False ## Contradiction: removed last value
- elif len(values[square]) == 1:
+
+ ## (1) If a square is reduced to one value d2, then eliminate d2 from the peers.
+ if len(values[square]) == 1:
d2 = values[square]
if not all(eliminate(values, s2, d2) for s2 in peers[square]):
return False
Please sign in to comment.
Something went wrong with that request. Please try again.