Ejemplo n.º 1
0
        public static void Call()
        {
            input = hell;
            // input = Hardest;

            if (sData == null)
            {
                sData = new SDataSet();
            }
            sData.Reset();
            Random r = new Random();

            Console.WriteLine("resetting solver...");

            sData.Permutations = SolverHelper.Permute(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });

            Console.WriteLine($"Possible line solutions: {sData.Permutations.Count}");
            Console.WriteLine($"Possible line length: {sData.Permutations[0].Count}");
            Console.WriteLine($"Check count at {1}: {sData.Permutations.Where(x => x[0] == 1).Count()}");

            Console.WriteLine("Reading sudoku input...");
            sData.ReadSudokuData(input, Dimension.Line);
            sData.ReadSudokuData(input, Dimension.Colum);
            sData.ReadSudokuData(input, Dimension.Block);

            Console.WriteLine("Converted to Sudoku data set model.");
            Console.WriteLine("------------------------------");

            if (Solve() == false)
            {
                Console.WriteLine("------------------------------ NOT SOLVED ");
            }

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public static void Call()
        {
            input = Hardest;
            if (sData == null)
            {
                sData = new SDataSet();
            }
            sData.Reset();
            Random r = new Random();

            Console.WriteLine("resetting solver...");

            sData.Permutations = SolverHelper.Permute(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });

            if (showDebug)
            {
                Console.WriteLine($"Possible line solutions: {sData.Permutations.Count}");
            }
            if (showDebug)
            {
                Console.WriteLine($"Possible line length: {sData.Permutations[0].Count}");
            }
            if (showDebug)
            {
                Console.WriteLine($"Check count at {1}: {sData.Permutations.Where(x => x[0] == 1).Count()}");
            }

            Console.WriteLine("Reading sudoku input...");
            sData.ReadSudokuData(input, Dimension.Line);
            sData.ReadSudokuData(input, Dimension.Colum);
            sData.ReadSudokuData(input, Dimension.Block);

            if (showDebug)
            {
                Console.WriteLine("Converted to Sudoku data set model.");
            }
            if (showDebug)
            {
                Console.WriteLine("------------------------------");
            }
            if (showDebug)
            {
                Console.WriteLine("Calculating possible permutations...");
            }

            sData.GetPermutations();

            if (showDebug)
            {
                Console.WriteLine("Permutations calculated.");
            }
            if (showDebug)
            {
                Console.WriteLine("------------------------------");
            }


            int[] li;
            int[] ci;
            int[] bi;



            for (int o = 0; o < 10; o++)
            {
                for (int i = 0; i < 81; i++)
                {
                    sData.CheckISValid(i);
                }
            }



            for (int i = 0; i < 9; i++)
            {
                Console.WriteLine($"==============================================");
                Console.WriteLine($"Y: {i} ==" +
                                  $" li: {sData.sdLines[i].possiblePermutations.Count()}," +
                                  $" ci: {sData.sdCols[i].possiblePermutations.Count()}," +
                                  $" bi: {sData.sdBlocks[i].possiblePermutations.Count()}");

                for (int u = 1; u < 10; u++)
                {
                    Console.WriteLine($"Checking {u}, Count: {sData.sdBlocks[i].possiblePermutations.Count(x => x[0] == u)}");
                }
            }



            Console.ReadLine();
        }