Skip to content

Commit a661b27

Browse files
committed
Update valid sedoku after solving it again
1 parent 31d92af commit a661b27

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

.pylintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ init-hook="import sys; sys.path.append('./')"
33
ignore=tests
44

55
[MESSAGES CONTROL]
6-
disable=C0111, # missing-docstring
6+
disable=C0103, # invalid-name
7+
C0111, # missing-docstring
8+
C0200, # consider-using-enumerate
79
C0301, # line-too-long
810
R0903, # too-few-public-methods
911

src/leetcode/medium/valid-sedoku/valid_sedoku.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,35 @@
4444

4545
from typing import List
4646

47+
4748
def isValidSudoku(board: List[List[str]]) -> bool:
4849
prevSeen = {
49-
"rows": { num: {} for num in range(len(board)) },
50-
"columns": { num: {} for num in range(len(board[0])) }
50+
"rows": {num: {} for num in range(len(board))},
51+
"columns": {num: {} for num in range(len(board[0]))}
5152
}
5253
buckets = [[{} for _ in range(3)] for _ in range(3)]
53-
54+
5455
for y in range(len(board)):
5556
for x in range(len(board[y])):
5657
currentNum = board[y][x]
57-
58-
if (currentNum == "."):
58+
59+
if currentNum == ".":
5960
continue
60-
61+
6162
if currentNum in prevSeen["rows"][y]:
6263
return False
6364
if currentNum in prevSeen["columns"][x]:
6465
return False
65-
66+
6667
prevSeen["rows"][y][currentNum] = True
6768
prevSeen["columns"][x][currentNum] = True
68-
69+
6970
bucketY = y // 3
7071
bucketX = x // 3
71-
72+
7273
if currentNum in buckets[bucketY][bucketX]:
7374
return False
74-
75+
7576
buckets[bucketY][bucketX][currentNum] = True
76-
77-
return True
77+
78+
return True

0 commit comments

Comments
 (0)