예제 #1
0
        public static void LowHangingFruit()
        {
            bool hasChanged = true;

            while (hasChanged)
            {
                hasChanged = false;
                for (int i = 0; i < 9; i++)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        if (puzzle.Get(i, j) == 0)
                        {
                            List <int> missingNUmbers = puzzle.GetNumbersMissingFromEveryDemension(i, j);

                            if (missingNUmbers.Count == 1)
                            {
                                puzzle.Put(i, j, missingNUmbers[0]);
                                possibilities[i, j] = null;
                                hasChanged          = true;
                            }
                            else
                            {
                                possibilities[i, j] = missingNUmbers;
                            }
                        }
                        else
                        {
                            possibilities[i, j] = null;
                        }
                    }
                }
            }
        }
예제 #2
0
        public static void Print(Sodoku puzzle, bool done = false)
        {
            string[] output = new string[9];

            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    output[i] += puzzle.Get(i, j) + ", ";
                }
            }

            foreach (string row in output)
            {
                Console.WriteLine(row);
            }
            Console.WriteLine("");

            if (done)
            {
                Console.WriteLine("Done");
            }
            Console.ReadKey();
        }