Esempio n. 1
0
        public bool SolveSudoku()
        {
            // while not solved
            int newSolutions = 0;

            do
            {
                newSolutions = SolverStep();
            } while (newSolutions > 0);

            double percentageDone() => Sudoku.Count(x => x != NDEF_VALUE) / (double)(ROW_ELEMENT_COUNT * ROW_ELEMENT_COUNT);

            Log.LogBuilder.AppendLine($"DONE ({percentageDone():P1})");

            Log.Heatmap = Log.Heatmap.ToDictionary(x => x.Key, x => 1.0 - x.Value / Log.Iterations);

            if (VerifySoduku() == false)
            {
                Log.LogBuilder.AppendLine("SODUKO IS NOT VALID");
                return(false);
            }

            return(percentageDone() == 1.0);
        }