Show / Hide Table of Contents

Class Boxes

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

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

Methods

| Improve this Doc View Source

CalculateBoxIndex(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
| Improve this Doc View Source

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
| Improve this Doc View Source

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

| Improve this Doc View Source

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

Returns
Type Description
System.Boolean

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

| Improve this Doc View Source

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>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX