# [Leetcode] (python): 037-sudoku Solver

Source: Internet
Author: User

Source of the topic:

https://leetcode.com/problems/sudoku-solver/

Test Instructions Analysis:

This topic is the evolutionary version of the previous question. Fill out a Sudoku.

Topic Ideas:

This problem is solved directly with DFS violence. Please fill in the "*" with (1-9) directly. The complexity of time is relatively high. Note that the title requires no return value, so write a separate function to determine whether the fill can be filled after the number of fills.

Code (Python):

`1 classsolution (object):2     defIsvalue (self,board,x,y):3         #Column Meets4          forIinchRange (9):5             ifI! = X andBoard[i][y] = =Board[x][y]:6                 returnFalse7          forJinchRange (9):8             ifJ! = Y andBOARD[X][J] = =Board[x][y]:9                 returnFalseTenJ + = 1 Onem = * * (x//3); n = * * (Y//3) A          forIinchRange (3): -              forJinchRange (3): -                 if(i + M! = XorJ + N! = y) andBoard[i + m][j + N] = =Board[x][y]: the                     returnFalse -         returnTrue -     defDFS (self,board): -          forIinchRange (9): +              forJinchRange (9): -                 ifBOARD[I][J] = ='.': +                      forKinch '123456789': ABOARD[I][J] =k at                         ifSelf.isvalue (BOARD,I,J) andSelf.dfs (board): -                             returnTrue -BOARD[I][J] ='.' -                     returnFalse -         returnTrue -          in     defSolvesudoku (self, Board): -         """ to : Type BOARD:LIST[LIST[STR]] + : Rtype:void does not return anything, modify board In-place instead. -         """ the Self.dfs (board) *         `
View Code

[Leetcode] (python): 037-sudoku Solver

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.