2
def validTicTacToe(self, board: List[str]) -> bool:3
# The two criteria for a valid board are:4
# 1) num of Xs - num of Os is 0 or 15
# 2) X is not a winner if the # of moves is even, and6
# O is not a winner if the # of moves is odd.8
d = {"X": 1, "O": -1, " ": 0} # transform the 1x3 str array to a 1x9 int array10
d[ch] for ch in "".join(board)11
] # Ex: ["XOX"," X "," "] --> [1,-1,1,0,1,0,0,0,0]15
return False # <-- criterion 117
n = -3 if sm == 1 else 3 # <-- criterion 2.24
s[2] + s[5] + s[8], # the elements of the set are28
return False # the rows, cols, and diags30
return True # <-- both criteria are true