Panax Sudoku Solver

Source: Internet
Author: User

    /** 37. Sudoku Solver * 2015.12.13 by Mingyang * 1. Length standard: None * 2. Optional range: All the wood is worth the point, pick a number from 1 to 9 * 3. Take a step forward: if put in is validate, then Put * 4. Take a step back: if you put it in and the back is false, change the point back to * 5. Special case: No * 6. On repetition: none * The IsValid of this topic is difficult * row = I/3 * 3; Row < I/3 * 3 + 3*/     Public voidSolvesudoku (Char[] board) {        if(board = =NULL|| Board.length = = 0)            return;    Helper (board); }    Private BooleanHelperChar[] board) {         for(inti = 0; i < board.length; i++) {             for(intj = 0; J < Board[0].length; J + +) {                if(Board[i][j] = = '. ') {                     for(Charnum = ' 1 '; Num <= ' 9 '; num++) {//Try                        if(isValid (board, I, J, num)) {Board[i][j]=num; if(Helper (board))//this point is a temporary fit, so go to the next level .                                return true; ElseBoard[i][j]= '. ';// Fallback                        }                    }                    return false; }            }        }        return true; }    Private BooleanIsValid (Char[] board,intIintJCharc) {//Check Column         for(introw = 0; Row < 9; row++)            if(Board[row][j] = =c)return false; //Check Row         for(intcol = 0; Col < 9; col++)            if(Board[i][col] = =c)return false; //Check Block         for(introw = I/3 * 3; Row < I/3 * 3 + 3; row++)             for(intCol = J/3 * 3; Col < J/3 * 3 + 3; col++)                if(Board[row][col] = =c)return false; return true; }

Panax Sudoku Solver

Contact Us

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.