Skip to content

Instantly share code, notes, and snippets.

@arpi-r
Created January 9, 2019 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arpi-r/4c83bccd16e2fdb66a68434dcf809d5d to your computer and use it in GitHub Desktop.
Save arpi-r/4c83bccd16e2fdb66a68434dcf809d5d to your computer and use it in GitHub Desktop.
codebuddy week9
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