# LeetCode 36: Valid Sudoku

## 题目

Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:

1. Each row must contain the digits 1-9 without repetition.
2. Each column must contain the digits 1-9 without repetition.
3. Each of the 9 3x3 sub-boxes of the grid must contain the digits 1-9 without repetition.

## 解法

《编程珠玑》一书中第三章“数据决定程序结构”强调了数据结构对程序编写的重要性，这个题目同样如此。

## 实现

class Solution:
def isValidSudoku(self, board):
seen = set()
for i in range(9):
for j in range(9):
e = board[i][j]
if e != '.':
r = e + 'in row' + str(i)
c = e + 'in col' + str(j)
b = e + 'in blk' + str(i // 3) + str(j // 3)
if r in seen or c in seen or b in seen:
return False
else: