SudokuSchemas

Represents a set of Sudoku schemas.

This class encapsulates a collection of SudokuSchema objects. It allows iteration over the schemas, copying the set with modified schemas, and provides standard methods for equality and string representation.

Example:

val schema1 = SudokuSchema(
puzzle = SudokuString("A1B2..."),
solution = SudokuString("1A2B..."),
difficulty = Difficulty.MEDIUM,
sudokuType = SudokuType.Sudoku4x4
)

val schema2 = SudokuSchema(
puzzle = SudokuString("B1C2..."),
solution = SudokuString("2B3C..."),
difficulty = Difficulty.HARD,
sudokuType = SudokuType.Sudoku4x4
)

// Create a SudokuSchemas with the schemas
val schemaSet = SudokuSchemas(listOf(schema1, schema2))

// Iterate over the schemas
for (schema in schemaSet) {
println(schema)
}

// Create a copy of the schema set
val copiedSchemaSet = schemaSet.copy()

See also

Constructors

Link copied to clipboard
constructor(schemas: List<SudokuSchema>)

Creates a new instance of SudokuSchemas with the provided list of schemas.

Types

Link copied to clipboard
class Builder

Builder class for constructing a SudokuSchemas with a DSL-style configuration.

Properties

Link copied to clipboard
open override val size: Int

Returns the number of schemas in this collection.

Functions

Link copied to clipboard
open operator override fun contains(element: SudokuSchema): Boolean

Checks if the specified SudokuSchema is present in the collection.

Link copied to clipboard
open override fun containsAll(elements: Collection<SudokuSchema>): Boolean

Checks if all specified SudokuSchema instances are present in the collection.

Link copied to clipboard
fun copy(schemas: List<SudokuSchema> = this.schemas): SudokuSchemas

Creates a copy of this SudokuSchemas with an optional new list of schemas.

Link copied to clipboard

Counts the number of schemas for each difficulty level.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Compares this SudokuSchemas to another object for equality.

Link copied to clipboard

Finds all SudokuSchema instances with the specified difficulty.

Link copied to clipboard

Finds all SudokuSchema instances with the specified Sudoku dimension.

Link copied to clipboard

Filters the schemas by difficulty.

Link copied to clipboard

Filters the schemas by size (dimension).

Link copied to clipboard

Gets all unique Sudoku dimensions present in this set.

Link copied to clipboard
open override fun hashCode(): Int

Computes a hash code for this SudokuSchemas.

Link copied to clipboard
open override fun isEmpty(): Boolean

Checks if the Sudoku schemas set is empty.

Link copied to clipboard
open operator override fun iterator(): Iterator<SudokuSchema>

Returns an iterator over the SudokuSchema objects in this set.

Link copied to clipboard
inline fun <T> Iterable<Iterable<T>>.mapToSudokuString(crossinline valueMapper: T.() -> Int): String

Converts an Iterable of elements to a String representation using toJEncodedCell for mapping.

Link copied to clipboard
operator fun plus(schema: SudokuSchema): SudokuSchemas

Adds a single SudokuSchema to this SudokuSchemas collection.

operator fun plus(other: SudokuSchemas): SudokuSchemas

Adds another SudokuSchemas collection to this SudokuSchemas collection.

operator fun plus(other: Collection<SudokuSchema>): SudokuSchemas

Adds a collection of SudokuSchema objects to this SudokuSchemas collection.

Link copied to clipboard
fun <T> Iterable<T>.randomItem(random: Random): T
Link copied to clipboard

Requires that there are Sudoku schemas for the given difficulty.

Link copied to clipboard

Requires that there are Sudoku schemas for the given type.

Link copied to clipboard

Converts this SudokuSchemas instance into a Builder object.

Link copied to clipboard
open override fun toString(): String

Returns a string representation of this SudokuSchemas.