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)