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
System.Object
MagicSquares
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 MagicSquares

Methods

| Improve this Doc View Source

ComputeSets(ReadOnlySpan<Int32>)

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
System.ReadOnlySpan<System.Int32> values

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

Returns
Type Description
System.Collections.Generic.HashSet<BitVector>
| Improve this Doc View Source

ComputeSets(ReadOnlySpan<Int32>, Int32, 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
System.ReadOnlySpan<System.Int32> values

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

System.Int32 boxSize
BitVector allPossibleValues

The

Returns
Type Description
System.Collections.Generic.HashSet<BitVector>
| Improve this Doc View Source

ComputeSum(ReadOnlySpan<Int32>)

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

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

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

Returns
Type Description
System.Int32
Exceptions
Type Condition
System.ArgumentException

Thrown if no sum is possible.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX