예제 #1
0
 /// <summary>Initializes a lookup to map each square to its corresponding regions.</summary>
 private void InitializeLookup()
 {
     for (var index = 0; index < Lookup.Length; index++)
     {
         Lookup[index] = new SudokuRegions();
     }
     foreach (var region in Regions)
     {
         foreach (var square in region)
         {
             Lookup[square].Add(region);
         }
     }
 }
예제 #2
0
        /// <summary>Constructs a Sudoku puzzle based on its size.</summary>
        /// <param name="size">
        /// The size of a single square.
        /// </param>
        protected SudokuPuzzle(int size)
        {
            this.Size2 = size * size;

            Grid = new int[Size2, Size2];
            Regions = new SudokuRegions();
            Lookup = new SudokuRegions[Size2 * Size2];

            InitializeGrid(Size2);

            InitializeRowRegions(Size2);
            InitializeColumnRegions(Size2);
            InitializeSubSquareRegions(size);
            InitializeLookup();
            InitializeIntersected();
        }
예제 #3
0
        /// <summary>Gets the Singleton instance of 3x3 puzzle.</summary>
        private SudokuPuzzle()
        {
            const int size = 3;

            Size2 = size * size;

            Grid    = new int[Size2, Size2];
            Regions = new SudokuRegions();
            Lookup  = new SudokuRegions[Size2 * Size2];

            InitializeGrid(Size2);

            InitializeRowRegions(Size2);
            InitializeColumnRegions(Size2);
            InitializeSubSquareRegions(size);
            InitializeLookup();
            InitializeIntersected();
        }
예제 #4
0
 /// <summary>Initializes a lookup to map each square to its corresponding regions.</summary>
 protected void InitializeLookup()
 {
     for (var index = 0; index < Lookup.Length; index++)
     {
         Lookup[index] = new SudokuRegions();
     }
     foreach (var region in Regions)
     {
         foreach (var square in region)
         {
             Lookup[square].Add(region);
         }
     }
 }
예제 #5
0
 /// <summary>Creates a Sudoku region.</summary>
 public SudokuRegion(SudokuRegionType type)
 {
     RegionType  = type;
     Intersected = new SudokuRegions();
 }