Straight python code


  • 0
    Z
            zhu=set()
        for i in xrange(9):
            for j in xrange(9):
                if board[i][j]!='.':
                    if (board[i][j],i) not in zhu and (j,board[i][j]) not in zhu and (board[i][j],i/3,j/3) not in zhu:
                        zhu.add((board[i][j],i))
                        zhu.add((j,board[i][j]))
                        zhu.add((board[i][j],i/3,j/3))
                    else:
                        return False
        return True
    

    by the way,is anyone can modify this line(if (board[i][j],i) not in zhu and (j,board[i][j]) not in zhu and (board[i][j],i/3,j/3) not in zhu), it's too long


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.