Show / Hide Table of Contents

Class Boxes

Provides utilities for working with "boxes", i.e. square regions within standard Sudokus.

Inheritance
object
Boxes
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SudokuSpice
Assembly: SudokuSpice.dll
Syntax
public static class Boxes

Methods

| Edit this page View Source

CalculateBoxIndex(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
| Edit this page View Source

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
| Edit this page View Source

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 toRoot is not the square of a whole number.

| Edit this page View Source

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 toRoot.

Returns
Type Description
bool

False if toRoot is not the square of a whole number.

| Edit this page View Source

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>
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX