Show / Hide Table of Contents

Class MagicSquares

Utility methods for working with magic squares, i.e. the sums of the values in each of their rows, columns, and (optionally) their diagonals add up to the same value.

These all require the possible values in the magic square to be unique.

Inheritance
object
MagicSquares
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 MagicSquares

Methods

| Edit this page View Source

ComputeSets(ReadOnlySpan<int>)

Computes each unique set of values of length SquareRoot(values.Length) that can be formed from the given values.

Declaration
public static HashSet<BitVector> ComputeSets(ReadOnlySpan<int> values)
Parameters
Type Name Description
ReadOnlySpan<int> values

All the possible values for the magic square. Each value must be unique.

Returns
Type Description
HashSet<BitVector>
| Edit this page View Source

ComputeSets(ReadOnlySpan<int>, int, BitVector)

Computes each unique set of values of length boxSize that can be formed from the given values.

Declaration
public static HashSet<BitVector> ComputeSets(ReadOnlySpan<int> values, int boxSize, BitVector allPossibleValues)
Parameters
Type Name Description
ReadOnlySpan<int> values

All the possible values for the magic square. Each value must be unique. Values must have length boxSize*boxSize.

int boxSize
BitVector allPossibleValues

The

Returns
Type Description
HashSet<BitVector>
| Edit this page View Source

ComputeSum(ReadOnlySpan<int>)

Computes the "sum" that each row/column/diagonal must add up to.

Declaration
public static int ComputeSum(ReadOnlySpan<int> values)
Parameters
Type Name Description
ReadOnlySpan<int> values

All the possible values for the magic square. Each value must be unique.

Returns
Type Description
int
Exceptions
Type Condition
ArgumentException

Thrown if no sum is possible.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX