Ejemplo n.º 1
0
 protected abstract List <SudokuSolution> Solve_BoxLineReduction(SudokuBoard a_board, bool a_all);
Ejemplo n.º 2
0
 protected abstract List <SudokuSolution> Solve_NakedQuads(SudokuBoard a_board, bool a_all);
Ejemplo n.º 3
0
 protected abstract List <SudokuSolution> Solve_PointingTriples(SudokuBoard a_board, bool a_all);
Ejemplo n.º 4
0
 protected abstract List <SudokuSolution> Solve_SinglesInUnit(SudokuBoard a_board, bool a_all);
Ejemplo n.º 5
0
 protected abstract List <SudokuSolution> Solve_HiddenTriples(SudokuBoard a_board, bool a_all);
Ejemplo n.º 6
0
 protected abstract List <SudokuSolution> Solve_WXYZWing(SudokuBoard a_board, bool a_all);
Ejemplo n.º 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)));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 9
0
 public SudokuBoard(SudokuBoard a_board)
     : this()
 {
     Cells().ForEach(cell => cell.CopyFrom(a_board[cell.Col, cell.Row]));
 }
Ejemplo n.º 10
0
 internal SudokuSolutionNode AddNode(SudokuBoard a_board, SudokuSolutionNodeState a_state, SudokuSolution a_solution)
 {
     return(AddNode(new SudokuSolutionNode(a_board, a_state, a_solution)));
 }
Ejemplo n.º 11
0
 public static SudokuSolutionNode CreateRoot(SudokuBoard a_board)
 {
     return(new SudokuSolutionNode(a_board, SudokuSolutionNodeState.State));
 }
Ejemplo n.º 12
0
 internal SudokuSolutionNode AddNode(SudokuBoard a_board, SudokuSolutionNodeState a_state)
 {
     return(AddNode(a_board, a_state, null));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 15
0
 protected abstract List <SudokuSolution> Solve_MultivalueXWing(SudokuBoard a_board, bool a_all);
Ejemplo n.º 16
0
 protected abstract List <SudokuSolution> Solve_MarkImpossibles(SudokuBoard a_board, bool a_all);
Ejemplo n.º 17
0
 protected abstract List <SudokuSolution> Solve_JellyFish(SudokuBoard a_board, bool a_all);
Ejemplo n.º 18
0
 protected abstract List <SudokuSolution> Solve_MarkSolved(SudokuBoard a_board, bool a_all);
Ejemplo n.º 19
0
 //Constructors
 public Detection(SudokuBoard sudoku)
 {
     this.sudoku = sudoku;
 }
Ejemplo n.º 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)));
        }