Use a program to solve Sudoku

Source: Internet
Author: User

Sudoku(Sudoku: In my memory, this game is also called jiugongge. It may be wrong. It should be called Sudoku)

), I suddenly remembered that last year, because it took a foreign scholar three months to study a Sudoku question with only one answer on Weibo, and then I was so enthusiastic that, it took three minutes to write a program to solve the problem.

Each row, each column, and each nine cells contain 1-9 numbers and are not repeated.. Then we can formulate the process and logic for solving the problem according to this rule.

   _x = , _y =  TextBox[,] _tbs =  TextBox[_x, _y];

 

      count = [] indexs = <> numbers =  ( i = ; i < _x; ++ ( j = ; j < _y; ++ (.IsNullOrEmpty(_tbs[i, j].Text.Trim()) || !.TryParse(_tbs[i, j].Text.Trim(),  ns = (ns.Count ==    (ns.Count <==  [=     (numbers ==   tb = _tbs[indexs[], indexs[= numbers[  (numbers.Count > =   IList<> GetNums( x,      cells =  List<TextBox> xstart = x /  * = y /  *  ( i = xstart, iend = xstart + ; i < iend; ++ ( j = ystart, yend = ystart + ; j < yend; ++ nums =  List<> ( num = ; num <= ; ++ (nums.Contains(num))  isIn =          ( index = ; index < _y; ++ (index != y &&                !.IsNullOrEmpty(_tbs[x, index].Text.Trim()) &&                .TryParse(_tbs[x, index].Text.Trim(),  val) &&===  (isIn)          ( index = ; index < _x; ++ (index != x &&                !.IsNullOrEmpty(_tbs[index, y].Text.Trim()) &&                .TryParse(_tbs[index, y].Text.Trim(),  val) &&===  (isIn)          tb = ( c  (c != tb &&                !.IsNullOrEmpty(c.Text.Trim()) &&                .TryParse(c.Text.Trim(),  val) &&===  (isIn) 

 

 

 

Related Article

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.