Class Boxes
Provides utilities for working with "boxes", i.e. square regions within standard Sudokus.
Inheritance
Inherited Members
Namespace: SudokuSpice
Assembly: SudokuSpice.dll
Syntax
public static class Boxes
Methods
| Improve this Doc View SourceCalculateBoxIndex(Coordinate, Int32)
Calculate the zero-based box-index of the given coordinate, starting at the top-left.
Declaration
public static int CalculateBoxIndex(in Coordinate c, int boxSize)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | c | |
System.Int32 | boxSize |
Returns
Type | Description |
---|---|
System.Int32 |
GetStartingBoxCoordinate(Int32, Int32)
Returns the top-left coordinate for the given box.
Declaration
public static Coordinate GetStartingBoxCoordinate(int box, int boxSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | box | |
System.Int32 | boxSize |
Returns
Type | Description |
---|---|
Coordinate |
IntSquareRoot(Int32)
Calculates the square root of a number. Only works for integers that have integer square roots.
This is useful for determining the standard box-size for a puzzle (i.e.
toRoot
would be the size of the puzzle, and the result would be the
size of each box.
Declaration
public static int IntSquareRoot(int toRoot)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | toRoot |
Returns
Type | Description |
---|---|
System.Int32 |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if |
TryIntSquareRoot(Int32, out Int32)
Calculates the square root of a number. Only works for integers that have integer square roots.
This is useful for determining the standard box-size for a puzzle (i.e.
toRoot
would be the size of the puzzle, and
root
would be the size of each box).
Declaration
public static bool TryIntSquareRoot(int toRoot, out int root)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | toRoot | The number to root. Should be the square of another integer. |
System.Int32 | root | Out parameter: the square root of |
Returns
Type | Description |
---|---|
System.Boolean | False if |
YieldUnsetCoordsForBox(Int32, Int32, IReadOnlyPuzzle)
Yields an enumerable of coordinates for all the unset squares in the given box.
Declaration
public static IEnumerable<Coordinate> YieldUnsetCoordsForBox(int box, int boxSize, IReadOnlyPuzzle puzzle)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | box | |
System.Int32 | boxSize | |
IReadOnlyPuzzle | puzzle |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coordinate> |