示例#1
0
            static string Str(SudokuBlock b)
            {
                var n1 = new[] { "①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨" };
                var n2 = new[] { "⑴", "⑵", "⑶", "⑷", "⑸", "⑹", "⑺", "⑻", "⑼" };

                return(b.Number.HasValue
                    ? b.IsCondition
                        ? " " + b.Number
                        : b.IsUnique
                            ? n1[b.Number.Value - 1]
                            : n2[b.Number.Value - 1]
                    : "▢");
            }
示例#2
0
 public SudokuSolver(byte[][] board)
 {
     SudokuBoard = new SudokuBlock[board.Length][];
     //初始化数独的行
     for (int i = 0; i < board.Length; i++)
     {
         SudokuBoard[i] = new SudokuBlock[board[i].Length];
         //初始化每行的列
         for (int j = 0; j < board[i].Length; j++)
         {
             SudokuBoard[i][j] = new SudokuBlock(
                 board[i][j] > 0
                 , board[i][j] <= 0 ? new BitArray(board.Length) : null
                 , board[i][j] > 0 ? (byte?)board[i][j] : null
                 , (byte)i
                 , (byte)j);
         }
     }
 }
示例#3
0
 public SudokuState(SudokuSolver sudoku)
 {
     SudokuBoard = new SudokuBlock[sudoku.SudokuBoard.Length][];
     //初始化数独的行
     for (int i = 0; i < sudoku.SudokuBoard.Length; i++)
     {
         SudokuBoard[i] = new SudokuBlock[sudoku.SudokuBoard[i].Length];
         //初始化每行的列
         for (int j = 0; j < sudoku.SudokuBoard[i].Length; j++)
         {
             SudokuBoard[i][j] = new SudokuBlock(
                 sudoku.SudokuBoard[i][j].IsCondition
                 , null
                 , sudoku.SudokuBoard[i][j].Number
                 , (byte)i
                 , (byte)j);
             if (sudoku.SudokuBoard[i][j].IsUnique)
             {
                 SudokuBoard[i][j].SetUnique();
             }
         }
     }
 }