Created
January 9, 2019 18:09
-
-
Save arpi-r/4c83bccd16e2fdb66a68434dcf809d5d to your computer and use it in GitHub Desktop.
codebuddy week9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
# @param A : tuple of strings | |
# @return an integer | |
def isValidSudoku(self, A): | |
for i in range(9): | |
ch=[0]*9 | |
for j in range(9): | |
if(A[i][j]!='.'): | |
if(ch[ord(A[i][j])-49]==1): | |
return 0 | |
ch[ord(A[i][j])-49]=1 | |
for i in range(9): | |
ch=[0]*9 | |
for j in range(9): | |
if(A[j][i]!='.'): | |
if(ch[ord(A[j][i])-49]==1): | |
return 0 | |
ch[ord(A[j][i])-49]=1 | |
for i in range(0,8,3): | |
ch=[0]*9 | |
for j in range(3): | |
for k in range(3): | |
if(A[j][k+i]!='.'): | |
if(ch[ord(A[j][k+i])-49]==1): | |
return 0 | |
ch[ord(A[j][k+i])-49]=1 | |
ch=[0]*9 | |
for j in range(3): | |
for k in range(3): | |
if(A[j+i][k]!='.'): | |
if(ch[ord(A[j+i][k])-49]==1): | |
return 0 | |
ch[ord(A[j+i][k])-49]=1 | |
return 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment