コード例 #1
0
        /// <summary>
        /// Display the sudoku puzzle
        /// </summary>
        /// <param name="puzzle"></param>
        private void DisplayPuzzle(PuzzleMonolithic puzzle)
        {
            int cnt = 1;
            IEnumerable <PuzzleMonolithic.Cell> cells = puzzle.GetCells();

            foreach (var cell in cells)
            {
                Console.Write($" {cell.ToString()} ");

                if (cnt % PuzzleMonolithic.QUADRIENT_GRID_SIZE == 0 &&
                    cnt % PuzzleMonolithic.PUZZLE_GRID_SIZE != 0)
                {
                    Console.Write(" | ");
                }


                // Determine if we need a blank line
                if (cnt % PuzzleMonolithic.PUZZLE_GRID_SIZE == 0)
                {
                    Console.WriteLine();
                    if (cnt % (PuzzleMonolithic.QUADRIENT_GRID_SIZE * PuzzleMonolithic.PUZZLE_GRID_SIZE) == 0)
                    {
                        for (int i = 0; i < PuzzleMonolithic.PUZZLE_GRID_SIZE; i++)
                        {
                            Console.Write("---");
                        }

                        Console.Write("---");
                        Console.WriteLine();
                    }
                }

                cnt++;
            }
        }
コード例 #2
0
        private void LockAllCellValues(PuzzleMonolithic puzzle)
        {
            IEnumerable <PuzzleMonolithic.Cell> cells = puzzle.GetCells();

            foreach (PuzzleMonolithic.Cell cell in cells)
            {
                cell.IsLocked = true;
            }
        }
コード例 #3
0
        /// <summary>
        /// Populate each PuzzleMonolithic cell with a random value
        /// </summary>
        /// <param name="puzzle"></param>
        private void PopulateRandomValues(PuzzleMonolithic puzzle)
        {
            IEnumerable <PuzzleMonolithic.Cell> cells = puzzle.GetCells();
            Random rand = new Random();

            foreach (var cell in cells)
            {
                cell.Value = Convert.ToByte((rand.Next() % PuzzleMonolithic.MAX_VALUE) + 1);
            }
        }