Class Boxes
Provides utilities for working with "boxes", i.e. square regions within standard Sudokus.
Inherited Members
Namespace: SudokuSpice
Assembly: SudokuSpice.dll
Syntax
public static class Boxes
Methods
| Edit this page View SourceCalculateBoxIndex(in Coordinate, int)
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 | |
| int | boxSize |
Returns
| Type | Description |
|---|---|
| int |
GetStartingBoxCoordinate(int, int)
Returns the top-left coordinate for the given box.
Declaration
public static Coordinate GetStartingBoxCoordinate(int box, int boxSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | box | |
| int | boxSize |
Returns
| Type | Description |
|---|---|
| Coordinate |
IntSquareRoot(int)
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 |
|---|---|---|
| int | toRoot |
Returns
| Type | Description |
|---|---|
| int |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
TryIntSquareRoot(int, out int)
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 |
|---|---|---|
| int | toRoot | The number to root. Should be the square of another integer. |
| int | root | Out parameter: the square root of |
Returns
| Type | Description |
|---|---|
| bool | False if |
YieldUnsetCoordsForBox(int, int, 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 |
|---|---|---|
| int | box | |
| int | boxSize | |
| IReadOnlyPuzzle | puzzle |
Returns
| Type | Description |
|---|---|
| IEnumerable<Coordinate> |