コード例 #1
0
        static void Main(string[] args)
        {
            int[,] start =
            {
                { 8, 5, 0, 0, 0, 1, 0, 0, 6 },
                { 0, 0, 7, 0, 6, 4, 1, 0, 0 },
                { 0, 0, 4, 0, 7, 0, 5, 9, 0 },
                { 2, 0, 0, 0, 5, 6, 0, 0, 4 },
                { 6, 0, 0, 1, 0, 9, 0, 7, 0 },
                { 7, 0, 1, 0, 4, 0, 0, 0, 9 },
                { 0, 1, 0, 9, 0, 0, 4, 6, 0 },
                { 0, 9, 6, 0, 0, 8, 0, 0, 7 },
                { 0, 7, 0, 6, 0, 0, 0, 0, 1 },
            };

            puzzle = new Sodoku(start);

            Print(puzzle);

            while (!IsDone())
            {
                LowHangingFruit();
                Possibilities();
            }

            Print(puzzle, true);
        }
コード例 #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();
        }