Пример #1
0
 protected abstract List <SudokuSolution> Solve_BoxLineReduction(SudokuBoard a_board, bool a_all);
Пример #2
0
 protected abstract List <SudokuSolution> Solve_NakedQuads(SudokuBoard a_board, bool a_all);
Пример #3
0
 protected abstract List <SudokuSolution> Solve_PointingTriples(SudokuBoard a_board, bool a_all);
Пример #4
0
 protected abstract List <SudokuSolution> Solve_SinglesInUnit(SudokuBoard a_board, bool a_all);
Пример #5
0
 protected abstract List <SudokuSolution> Solve_HiddenTriples(SudokuBoard a_board, bool a_all);
Пример #6
0
 protected abstract List <SudokuSolution> Solve_WXYZWing(SudokuBoard a_board, bool a_all);
Пример #7
0
 public static SudokuSolution Rotate(this SudokuSolution a_sol, SudokuBoard a_board)
 {
     return(new SudokuSolution(a_sol.Type, Rotate(a_sol.Removed, a_board), Rotate(a_sol.Stayed, a_board),
                               Rotate(a_sol.Solved, a_board), from unit in a_sol.ColorUnits
                               select Rotate(unit, a_board)));
 }
Пример #8
0
        private static SudokuBoard LoadFromText(string a_str)
        {
            a_str = a_str.Replace(System.Environment.NewLine, System.Environment.NewLine.Substring(0, 1));
            List <string> lines = a_str.Split(System.Environment.NewLine[0]).ToList();

            for (int i = lines.Count - 1; i >= 0; i--)
            {
                lines[i] = lines[i].Replace(" ", "");
                if (lines[i].IndexOfAny(new char[] { ']', '[', '-', '+', '*' }) != -1)
                {
                    lines.RemoveAt(i);
                }
                else if (lines[i].Length == 0)
                {
                    lines.RemoveAt(i);
                }
            }

            if (lines.Count == 1)
            {
                string str = lines[0];

                if (str.Length == 9 * 9)
                {
                    lines.Clear();

                    for (int i = 0; i < 9; i++)
                    {
                        lines.Add(str.Substring(i * 9, 9));
                    }
                }
            }

            for (int i = lines.Count - 1; i >= 0; i--)
            {
                lines[i] = lines[i].Replace(" |", "");
                lines[i] = lines[i].Replace("|", "");
                lines[i] = lines[i].Replace(" ", ".");
            }

            for (int i = lines.Count - 1; i >= 0; i--)
            {
                if (lines[i].Length != SIZE)
                {
                    lines.RemoveAt(i);
                }
            }

            if (lines.Count != SIZE)
            {
                return(null);
            }

            SudokuBoard board = new SudokuBoard();

            (from cell in board.Cells()
             where lines[cell.Row][cell.Col] != '.'
             select cell).ForEach(cell =>
                                  cell[Int32.Parse(new string(new char[] { lines[cell.Row][cell.Col] })) - 1].State =
                                      SudokuNumberState.sudokucellstateManualEntered);

            if (!board.Check())
            {
                return(null);
            }

            return(board);
        }
Пример #9
0
 public SudokuBoard(SudokuBoard a_board)
     : this()
 {
     Cells().ForEach(cell => cell.CopyFrom(a_board[cell.Col, cell.Row]));
 }
Пример #10
0
 internal SudokuSolutionNode AddNode(SudokuBoard a_board, SudokuSolutionNodeState a_state, SudokuSolution a_solution)
 {
     return(AddNode(new SudokuSolutionNode(a_board, a_state, a_solution)));
 }
Пример #11
0
 public static SudokuSolutionNode CreateRoot(SudokuBoard a_board)
 {
     return(new SudokuSolutionNode(a_board, SudokuSolutionNodeState.State));
 }
Пример #12
0
 internal SudokuSolutionNode AddNode(SudokuBoard a_board, SudokuSolutionNodeState a_state)
 {
     return(AddNode(a_board, a_state, null));
 }
Пример #13
0
        private static IEnumerable <SudokuNumber> Rotate(IEnumerable <SudokuNumber> a_list, SudokuBoard a_board)
        {
            var list = from num in a_list
                       select Rotate(num, a_board);

            return(from num in list
                   orderby num.Row, num.Col
                   select num);
        }
Пример #14
0
        private static IEnumerable <SudokuCell> Rotate(IEnumerable <SudokuCell> a_list, SudokuBoard a_board)
        {
            var list = from cell in a_list
                       select GetRotatedCell(a_board, cell);

            return(from cell in list
                   orderby cell.Row, cell.Col
                   select cell);
        }
Пример #15
0
 protected abstract List <SudokuSolution> Solve_MultivalueXWing(SudokuBoard a_board, bool a_all);
Пример #16
0
 protected abstract List <SudokuSolution> Solve_MarkImpossibles(SudokuBoard a_board, bool a_all);
Пример #17
0
 protected abstract List <SudokuSolution> Solve_JellyFish(SudokuBoard a_board, bool a_all);
Пример #18
0
 protected abstract List <SudokuSolution> Solve_MarkSolved(SudokuBoard a_board, bool a_all);
Пример #19
0
 //Constructors
 public Detection(SudokuBoard sudoku)
 {
     this.sudoku = sudoku;
 }
Пример #20
0
        public static SudokuIntermediateSolution Rotate(this SudokuIntermediateSolution a_inter_sol)
        {
            SudokuBoard before = Rotate(a_inter_sol.Before);

            return(new SudokuIntermediateSolution(before, Rotate(a_inter_sol.After), Rotate(a_inter_sol.Solution, before)));
        }