/// <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); } } }
/// <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(); }
/// <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(); }
/// <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); } } }
/// <summary>Creates a Sudoku region.</summary> public SudokuRegion(SudokuRegionType type) { RegionType = type; Intersected = new SudokuRegions(); }