diff --git a/demo/src/main/kotlin/dev/teogor/sudoklify/demo/gen/impl/SudokuDecoderImpl.kt b/demo/src/main/kotlin/dev/teogor/sudoklify/demo/gen/impl/SudokuDecoderImpl.kt index 75becbf..910edc7 100644 --- a/demo/src/main/kotlin/dev/teogor/sudoklify/demo/gen/impl/SudokuDecoderImpl.kt +++ b/demo/src/main/kotlin/dev/teogor/sudoklify/demo/gen/impl/SudokuDecoderImpl.kt @@ -18,7 +18,7 @@ package dev.teogor.sudoklify.demo.gen.impl import dev.teogor.sudoklify.common.types.Board import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType +import dev.teogor.sudoklify.common.types.SudokuType import dev.teogor.sudoklify.core.io.toSudokuIntArray import dev.teogor.sudoklify.core.solver.SudokuSolver import dev.teogor.sudoklify.core.util.toBoard @@ -36,11 +36,11 @@ fun main() { val sudokuPuzzle = getParsedPuzzle(sudokuPuzzleFile) val sudokuSolved = getParsedPuzzle(sudokuSolvedFile) val difficulty = Difficulty.VERY_HARD - val gameType = GameType.TwentyFiveDigits + val sudokuType = SudokuType.Sudoku25x25 val validPuzzles = comparePuzzles( - puzzle = sudokuPuzzle.toBoard(gameType), - solution = sudokuSolved.toBoard(gameType), + puzzle = sudokuPuzzle.toBoard(sudokuType), + solution = sudokuSolved.toBoard(sudokuType), ) if (validPuzzles) { File(outputFile) write { @@ -50,7 +50,7 @@ fun main() { appendLine(" puzzle = \"$sudokuPuzzle\",") appendLine(" solution = \"$sudokuSolved\",") appendLine(" difficulty = Difficulty.${difficulty.name},") - appendLine(" gameType = GameType.${gameType.name},") + appendLine(" gameType = GameType.${sudokuType.name},") appendLine("),") }.also { write(it) } } @@ -61,7 +61,7 @@ fun main() { val originalSize = rootDigitsSeeds.size val uniquesSize = rootDigitsSeeds.distinctBy { it.solution }.size - println("Original array contains $originalSize Sudoku puzzles for $gameType.") + println("Original array contains $originalSize Sudoku puzzles for $sudokuType.") if (originalSize != uniquesSize) { println("Duplicates detected! Unique seeds: $uniquesSize") } @@ -78,18 +78,18 @@ fun main() { println() val puzzle = sixteenDigitsSeeds.random() - val sudokuSolver = SudokuSolver(sudokuPuzzle.toSudokuIntArray(gameType), gameType) + val sudokuSolver = SudokuSolver(sudokuPuzzle.toSudokuIntArray(sudokuType), sudokuType) val solution = sudokuSolver.solve() println("solution=$solution") puzzle.puzzle - .toSudokuIntArray(GameType.SixteenDigits) + .toSudokuIntArray(SudokuType.Sudoku16x16) .also { it[0].forEach { cell -> print("${if (cell == 0) "/" else cell} ") } } println() puzzle.solution - .toSudokuIntArray(GameType.SixteenDigits) + .toSudokuIntArray(SudokuType.Sudoku16x16) .also { it[0].forEach { cell -> print("$cell ") } } diff --git a/docs/sudoku-type.md b/docs/sudoku-type.md new file mode 100644 index 0000000..d6af82c --- /dev/null +++ b/docs/sudoku-type.md @@ -0,0 +1,344 @@ +# Sudoku Type Documentation + +This document aims to provide a comprehensive overview of the `SudokuType` class present in +the `dev.teogor.sudoklify.common.types` package. This class serves as a foundation for representing +various Sudoku puzzle sizes and their associated properties. + +## **Key Features** + +* **Encapsulated Grid Size:** Each `SudokuType` object encapsulates the grid size + information (`width` and `height`) through its `gridSize` property. This ensures clarity and + consistency in representing different Sudoku variations. +* **Derived Properties:** Several properties provide convenient access to derived information based + on the grid size, such as `digits` (total number of cells), `cells` (total cells in the + grid), `isSquare` (whether the grid is square), `width`, and `height`. +* **Human-Readable Name:** Each `SudokuType` object holds a `name` property, presenting a + user-friendly representation like "4x4" for clarity and easy identification. +* **Dedicated Objects:** Individual objects represent common Sudoku sizes, + including `Sudoku4x4`, `Sudoku6x6`, `Sudoku9x9`, and many more, offering convenient access to + specific grid dimensions. +* **`Unspecified` Object:** To handle cases where the Sudoku size is unknown or unspecified, + an `Unspecified` object exists within the class. + +## **Working with Sudoku Types** + +### Benefits of Using SudokuType + +* **Type Safety:** Enforces correct grid size representation and prevents errors or unexpected + behavior. +* **Clarity and Maintainability:** Improves code readability and simplifies maintenance thanks to + well-defined types and properties. +* **Flexibility:** Accommodates various Sudoku sizes while ensuring consistency and ease of use. + +### **Creating Sudoku Types** + +#### 1. **Accessing Existing Objects** + +Utilize the predefined objects like `Sudoku4x4` or `Sudoku9x9` for commonly used sizes: + +```kotlin +val puzzle4x4: SudokuType = SudokuType.Sudoku4x4 +val puzzle9x9: SudokuType = SudokuType.Sudoku9x9 +``` + +#### 2. **Creating a Custom Objects** + +For unsupported sizes, create a new instance using the `GridSize` constructor and assign it to a +variable of type `SudokuType`: + +```kotlin +val customSize: SudokuType = SudokuType(GridSize(5, 8)) +println("Custom Sudoku size: ${customSize}") +``` + +### Utilizing `SudokuType` Properties + +Directly access various properties available on any `SudokuType` object to gain insights into the +grid size and structure. These properties offer convenient ways to work with different Sudoku +variations. + +#### 1. `SudokuType.width` and `SudokuType.height` + +- **Description:** These properties directly represent the dimensions of the Sudoku grid, providing + the width and height in individual integer values. +- **Use Cases:** + * Determine the total number of cells in the grid (`width * height`). + * Calculate the size of individual boxes within the grid (`boxWidth = width / boxCount`, + where `boxCount` is the number of boxes horizontally or vertically). + * Create a visual representation of the grid based on its dimensions. +- **Example:** + +```kotlin +val puzzleSize = SudokuType.Sudoku6x6 +println("Grid size: ${puzzleSize.width}x${puzzleSize.height}") // Output: Grid size: 6x6 +``` + +- **Use Cases:** + - Determine the total number of rows and columns in the grid. + - Define constraints for placing elements based on grid dimensions. + - Calculate box sizes within the grid (using `boxWidth` and `boxHeight`). + +#### 2. `SudokuType.digits` + +- **Description:** This property represents the total number of digits used in the Sudoku puzzle, + calculated as `width * height`. +- **Use Cases:** + * Validate the number of digits present in a puzzle to ensure it adheres to Sudoku rules. + * Determine the permissible range of values that can be used in each cell (typically 1 + to `digits`). + * Calculate the number of unique values needed in a solved puzzle (`digits * digits`). +- **Example:** + +```kotlin +val puzzleCells = SudokuType.Sudoku9x9.digits +println("Total cells: $puzzleCells") // Output: Total cells: 81 +``` + +#### 3. `SudokuType.cells` + +- **Description:** This property provides the total number of cells in the Sudoku grid, calculated + as `digits * digits`. +- **Use Cases:** + * Iterate through all cells in the grid using loops or indexing based on `cells`. + * Check if a specific cell index falls within the valid range (0 to `cells - 1`). + * Determine the completion status of a puzzle by counting filled cells. + +```kotlin +val puzzle = SudokuType.Sudoku9x9 // 9x9 Sudoku with 81 cells + +// Iterate through all cells using a loop: +for (cellIndex in 0.. ([[Ljava/lang/String;[[Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;)V + public fun ([[Ljava/lang/String;[[Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;)V public final fun component1 ()[[Ljava/lang/String; public final fun component2 ()[[Ljava/lang/String; public final fun component3 ()Ldev/teogor/sudoklify/common/types/Difficulty; - public final fun component4 ()Ldev/teogor/sudoklify/common/types/GameType; - public final fun copy ([[Ljava/lang/String;[[Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;)Ldev/teogor/sudoklify/common/model/Sudoku; - public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/model/Sudoku;[[Ljava/lang/String;[[Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;ILjava/lang/Object;)Ldev/teogor/sudoklify/common/model/Sudoku; + public final fun component4 ()Ldev/teogor/sudoklify/common/types/SudokuType; + public final fun copy ([[Ljava/lang/String;[[Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;)Ldev/teogor/sudoklify/common/model/Sudoku; + public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/model/Sudoku;[[Ljava/lang/String;[[Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;ILjava/lang/Object;)Ldev/teogor/sudoklify/common/model/Sudoku; public fun equals (Ljava/lang/Object;)Z public final fun getDifficulty ()Ldev/teogor/sudoklify/common/types/Difficulty; - public final fun getGameType ()Ldev/teogor/sudoklify/common/types/GameType; public final fun getPuzzle ()[[Ljava/lang/String; public final fun getSolution ()[[Ljava/lang/String; + public final fun getSudokuType ()Ldev/teogor/sudoklify/common/types/SudokuType; public fun hashCode ()I public fun toString ()Ljava/lang/String; } public final class dev/teogor/sudoklify/common/model/SudokuBlueprint { - public fun (Ljava/lang/String;Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;)V + public fun (Ljava/lang/String;Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ljava/lang/String; public final fun component3 ()Ldev/teogor/sudoklify/common/types/Difficulty; - public final fun component4 ()Ldev/teogor/sudoklify/common/types/GameType; - public final fun copy (Ljava/lang/String;Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;)Ldev/teogor/sudoklify/common/model/SudokuBlueprint; - public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/model/SudokuBlueprint;Ljava/lang/String;Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;ILjava/lang/Object;)Ldev/teogor/sudoklify/common/model/SudokuBlueprint; + public final fun component4 ()Ldev/teogor/sudoklify/common/types/SudokuType; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;)Ldev/teogor/sudoklify/common/model/SudokuBlueprint; + public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/model/SudokuBlueprint;Ljava/lang/String;Ljava/lang/String;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;ILjava/lang/Object;)Ldev/teogor/sudoklify/common/model/SudokuBlueprint; public fun equals (Ljava/lang/Object;)Z public final fun getDifficulty ()Ldev/teogor/sudoklify/common/types/Difficulty; - public final fun getGameType ()Ldev/teogor/sudoklify/common/types/GameType; public final fun getPuzzle ()Ljava/lang/String; public final fun getSolution ()Ljava/lang/String; + public final fun getSudokuType ()Ldev/teogor/sudoklify/common/types/SudokuType; public fun hashCode ()I public fun toString ()Ljava/lang/String; } public final class dev/teogor/sudoklify/common/model/SudokuParams { - public fun ([Ldev/teogor/sudoklify/common/model/SudokuBlueprint;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/Seed;Ldev/teogor/sudoklify/common/types/GameType;)V + public fun ([Ldev/teogor/sudoklify/common/model/SudokuBlueprint;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/Seed;Ldev/teogor/sudoklify/common/types/SudokuType;)V public final fun component1 ()[Ldev/teogor/sudoklify/common/model/SudokuBlueprint; public final fun component2 ()Ldev/teogor/sudoklify/common/types/Difficulty; public final fun component3 ()Ldev/teogor/sudoklify/common/types/Seed; - public final fun component4 ()Ldev/teogor/sudoklify/common/types/GameType; - public final fun copy ([Ldev/teogor/sudoklify/common/model/SudokuBlueprint;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/Seed;Ldev/teogor/sudoklify/common/types/GameType;)Ldev/teogor/sudoklify/common/model/SudokuParams; - public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/model/SudokuParams;[Ldev/teogor/sudoklify/common/model/SudokuBlueprint;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/Seed;Ldev/teogor/sudoklify/common/types/GameType;ILjava/lang/Object;)Ldev/teogor/sudoklify/common/model/SudokuParams; + public final fun component4 ()Ldev/teogor/sudoklify/common/types/SudokuType; + public final fun copy ([Ldev/teogor/sudoklify/common/model/SudokuBlueprint;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/Seed;Ldev/teogor/sudoklify/common/types/SudokuType;)Ldev/teogor/sudoklify/common/model/SudokuParams; + public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/model/SudokuParams;[Ldev/teogor/sudoklify/common/model/SudokuBlueprint;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/Seed;Ldev/teogor/sudoklify/common/types/SudokuType;ILjava/lang/Object;)Ldev/teogor/sudoklify/common/model/SudokuParams; public fun equals (Ljava/lang/Object;)Z public final fun getDifficulty ()Ldev/teogor/sudoklify/common/types/Difficulty; - public final fun getGameType ()Ldev/teogor/sudoklify/common/types/GameType; public final fun getSeed ()Ldev/teogor/sudoklify/common/types/Seed; public final fun getSeeds ()[Ldev/teogor/sudoklify/common/model/SudokuBlueprint; + public final fun getSudokuType ()Ldev/teogor/sudoklify/common/types/SudokuType; public fun hashCode ()I public fun toString ()Ljava/lang/String; } public final class dev/teogor/sudoklify/common/model/SudokuPuzzle { - public fun (Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;Ldev/teogor/sudoklify/common/types/Seed;Ljava/util/List;Ljava/util/List;Ljava/util/List;)V - public synthetic fun (Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;Ldev/teogor/sudoklify/common/types/Seed;Ljava/util/List;Ljava/util/List;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;Ldev/teogor/sudoklify/common/types/Seed;Ljava/util/List;Ljava/util/List;Ljava/util/List;)V + public synthetic fun (Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;Ldev/teogor/sudoklify/common/types/Seed;Ljava/util/List;Ljava/util/List;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/teogor/sudoklify/common/types/Difficulty; - public final fun component2 ()Ldev/teogor/sudoklify/common/types/GameType; + public final fun component2 ()Ldev/teogor/sudoklify/common/types/SudokuType; public final fun component3 ()Ldev/teogor/sudoklify/common/types/Seed; public final fun component4 ()Ljava/util/List; public final fun component5 ()Ljava/util/List; public final fun component6 ()Ljava/util/List; - public final fun copy (Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;Ldev/teogor/sudoklify/common/types/Seed;Ljava/util/List;Ljava/util/List;Ljava/util/List;)Ldev/teogor/sudoklify/common/model/SudokuPuzzle; - public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/model/SudokuPuzzle;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/GameType;Ldev/teogor/sudoklify/common/types/Seed;Ljava/util/List;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)Ldev/teogor/sudoklify/common/model/SudokuPuzzle; + public final fun copy (Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;Ldev/teogor/sudoklify/common/types/Seed;Ljava/util/List;Ljava/util/List;Ljava/util/List;)Ldev/teogor/sudoklify/common/model/SudokuPuzzle; + public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/model/SudokuPuzzle;Ldev/teogor/sudoklify/common/types/Difficulty;Ldev/teogor/sudoklify/common/types/SudokuType;Ldev/teogor/sudoklify/common/types/Seed;Ljava/util/List;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)Ldev/teogor/sudoklify/common/model/SudokuPuzzle; public fun equals (Ljava/lang/Object;)Z public final fun getDifficulty ()Ldev/teogor/sudoklify/common/types/Difficulty; - public final fun getGameType ()Ldev/teogor/sudoklify/common/types/GameType; public final fun getGivens ()Ljava/util/List; public final fun getHints ()Ljava/util/List; public final fun getSeed ()Ldev/teogor/sudoklify/common/types/Seed; public final fun getSolution ()Ljava/util/List; + public final fun getSudokuType ()Ldev/teogor/sudoklify/common/types/SudokuType; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -131,6 +131,27 @@ public final class dev/teogor/sudoklify/common/model/SudokuSolution { public fun toString ()Ljava/lang/String; } +public final class dev/teogor/sudoklify/common/types/BoxCoordinates { + public fun (IIII)V + public final fun component1 ()I + public final fun component2 ()I + public final fun component3 ()I + public final fun component4 ()I + public final fun copy (IIII)Ldev/teogor/sudoklify/common/types/BoxCoordinates; + public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/types/BoxCoordinates;IIIIILjava/lang/Object;)Ldev/teogor/sudoklify/common/types/BoxCoordinates; + public fun equals (Ljava/lang/Object;)Z + public final fun getBottomRight ()Lkotlin/Pair; + public final fun getBottomRightCol ()I + public final fun getBottomRightRow ()I + public final fun getHeight ()I + public final fun getTopLeft ()Lkotlin/Pair; + public final fun getTopLeftCol ()I + public final fun getTopLeftRow ()I + public final fun getWidth ()I + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + public final class dev/teogor/sudoklify/common/types/Difficulty : java/lang/Enum { public static final field EASY Ldev/teogor/sudoklify/common/types/Difficulty; public static final field HARD Ldev/teogor/sudoklify/common/types/Difficulty; @@ -187,3 +208,115 @@ public final class dev/teogor/sudoklify/common/types/Seed$Random : dev/teogor/su public fun ()V } +public abstract class dev/teogor/sudoklify/common/types/SudokuType { + public synthetic fun (Ldev/teogor/sudoklify/common/types/SudokuType$GridSize;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getBoxHeight ()I + public final fun getBoxWidth ()I + public final fun getCells ()I + public final fun getDigits ()I + public final fun getGridSize ()Ldev/teogor/sudoklify/common/types/SudokuType$GridSize; + public final fun getHeight ()I + public final fun getName ()Ljava/lang/String; + public final fun getWidth ()I + public final fun isSquare ()Z + public final fun toString ()Ljava/lang/String; +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$GridSize { + public fun (II)V + public final fun component1 ()I + public final fun component2 ()I + public final fun copy (II)Ldev/teogor/sudoklify/common/types/SudokuType$GridSize; + public static synthetic fun copy$default (Ldev/teogor/sudoklify/common/types/SudokuType$GridSize;IIILjava/lang/Object;)Ldev/teogor/sudoklify/common/types/SudokuType$GridSize; + public fun equals (Ljava/lang/Object;)Z + public final fun getHeight ()I + public final fun getWidth ()I + public fun hashCode ()I + public final fun isSquare ()Z + public fun toString ()Ljava/lang/String; +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku10x10 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku10x10; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku12x12 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku12x12; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku15x15 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku15x15; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku16x16 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku16x16; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku25x25 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku25x25; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku36x36 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku36x36; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku49x49 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku49x49; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku4x4 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku4x4; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku64x64 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku64x64; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku6x6 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku6x6; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku81x81 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku81x81; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku8x8 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku8x8; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Sudoku9x9 : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Sudoku9x9; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + +public final class dev/teogor/sudoklify/common/types/SudokuType$Unspecified : dev/teogor/sudoklify/common/types/SudokuType { + public static final field INSTANCE Ldev/teogor/sudoklify/common/types/SudokuType$Unspecified; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I +} + diff --git a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/Sudoku.kt b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/Sudoku.kt index 8e47fb6..358e45f 100644 --- a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/Sudoku.kt +++ b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/Sudoku.kt @@ -18,13 +18,13 @@ package dev.teogor.sudoklify.common.model import dev.teogor.sudoklify.common.types.Board import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType +import dev.teogor.sudoklify.common.types.SudokuType data class Sudoku( val puzzle: Board, val solution: Board, val difficulty: Difficulty, - val gameType: GameType, + val sudokuType: SudokuType, ) { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -35,7 +35,7 @@ data class Sudoku( if (!puzzle.contentDeepEquals(other.puzzle)) return false if (!solution.contentDeepEquals(other.solution)) return false if (difficulty != other.difficulty) return false - if (gameType != other.gameType) return false + if (sudokuType != other.sudokuType) return false return true } @@ -44,7 +44,7 @@ data class Sudoku( var result = puzzle.contentDeepHashCode() result = 31 * result + solution.contentDeepHashCode() result = 31 * result + difficulty.hashCode() - result = 31 * result + gameType.hashCode() + result = 31 * result + sudokuType.hashCode() return result } } diff --git a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuBlueprint.kt b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuBlueprint.kt index 66eaea0..df0138f 100644 --- a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuBlueprint.kt +++ b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuBlueprint.kt @@ -17,9 +17,9 @@ package dev.teogor.sudoklify.common.model import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.types.PuzzleString import dev.teogor.sudoklify.common.types.SolutionString +import dev.teogor.sudoklify.common.types.SudokuType /** * Represents a blueprint for generating Sudoku puzzles. @@ -27,11 +27,11 @@ import dev.teogor.sudoklify.common.types.SolutionString * @property puzzle The puzzle layout as a [PuzzleString]. * @property solution The solution layout as a [SolutionString]. * @property difficulty The difficulty level of the Sudoku puzzle. - * @property gameType The type of the Sudoku grid. + * @property sudokuType The type of the Sudoku puzzle. */ data class SudokuBlueprint( val puzzle: PuzzleString, val solution: SolutionString, val difficulty: Difficulty, - val gameType: GameType, + val sudokuType: SudokuType, ) diff --git a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuParams.kt b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuParams.kt index 26fb5c6..2298d5e 100644 --- a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuParams.kt +++ b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuParams.kt @@ -17,8 +17,8 @@ package dev.teogor.sudoklify.common.model import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.types.Seed +import dev.teogor.sudoklify.common.types.SudokuType /** * Data class representing parameters for configuring a Sudoku puzzle generator. @@ -26,11 +26,11 @@ import dev.teogor.sudoklify.common.types.Seed * @property seeds The seeds to be used. * @property difficulty The difficulty level of the Sudoku puzzle. * @property seed The seed for generating random numbers. - * @property gameType The type of the Sudoku grid. + * @property sudokuType The type of the Sudoku puzzle. */ data class SudokuParams( val seeds: Array, val difficulty: Difficulty, val seed: Seed, - val gameType: GameType, + val sudokuType: SudokuType, ) diff --git a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuPuzzle.kt b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuPuzzle.kt index 933ddb4..8526dad 100644 --- a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuPuzzle.kt +++ b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/model/SudokuPuzzle.kt @@ -17,12 +17,12 @@ package dev.teogor.sudoklify.common.model import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.types.Seed +import dev.teogor.sudoklify.common.types.SudokuType data class SudokuPuzzle( val difficulty: Difficulty, - val gameType: GameType, + val sudokuType: SudokuType, val seed: Seed, val givens: List, val solution: List>, diff --git a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/BoxCoordinates.kt b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/BoxCoordinates.kt new file mode 100644 index 0000000..1f38216 --- /dev/null +++ b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/BoxCoordinates.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2024 Teogor (Teodor Grigor) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.teogor.sudoklify.common.types + +/** + * Data class representing the coordinates of a box in a Sudoku grid. + * + * @property topLeftRow The row index of the top-left cell in the box. + * @property topLeftCol The column index of the top-left cell in the box. + * @property bottomRightRow The row index of the bottom-right cell in the box. + * @property bottomRightCol The column index of the bottom-right cell in the box. + * + * @property width The width of the box (number of columns). + * @property height The height of the box (number of rows). + * + * @property topLeft A tuple representing the top-left cell coordinates (row, col). + * @property bottomRight A tuple representing the bottom-right cell coordinates (row, col). + */ +data class BoxCoordinates( + val topLeftRow: Int, + val topLeftCol: Int, + val bottomRightRow: Int, + val bottomRightCol: Int, +) { + val width: Int get() = bottomRightCol - topLeftCol + 1 + val height: Int get() = bottomRightRow - topLeftRow + 1 + + val topLeft: Pair + get() = topLeftRow to topLeftCol + val bottomRight: Pair + get() = (bottomRightRow + height - 1) to (bottomRightCol + width - 1) +} diff --git a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/GameType.kt b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/GameType.kt index 402e486..f5b127e 100644 --- a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/GameType.kt +++ b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/GameType.kt @@ -27,6 +27,14 @@ package dev.teogor.sudoklify.common.types * The `GameType` enum also includes a `cells` property that returns the total number of cells in the * puzzle, and an `isSquare` property that returns whether the puzzle is a square. */ +@Deprecated( + message = "GameType is deprecated, use SudokuType instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType", + "dev.teogor.sudoklify.common.types.SudokuType", + ), +) enum class GameType( val gridHeight: Int, val gridWidth: Int, @@ -34,71 +42,183 @@ enum class GameType( /** * The unspecified game type. */ + @Deprecated( + message = "GameType.Unspecified is deprecated, use SudokuType.Unspecified instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Unspecified", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) Unspecified(0, 0), /** * The 4x4 game type. */ + @Deprecated( + message = "GameType.FourDigits is deprecated, use SudokuType.Sudoku4x4 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku4x4", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) FourDigits(2, 2), /** * The 6x6 game type. */ + @Deprecated( + message = "GameType.SixDigits is deprecated, use SudokuType.Sudoku6x6 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku6x6", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) SixDigits(2, 3), /** * The 8x8 game type. */ + @Deprecated( + message = "GameType.EightDigits is deprecated, use SudokuType.Sudoku8x8 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku8x8", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) EightDigits(2, 4), /** * The 9x9 game type. */ + @Deprecated( + message = "GameType.NineDigits is deprecated, use SudokuType.Sudoku9x9 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku9x9", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) NineDigits(3, 3), /** * The 10x10 game type. */ + @Deprecated( + message = "GameType.TenDigits is deprecated, use SudokuType.Sudoku10x10 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku10x10", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) TenDigits(2, 5), /** * The 12x12 game type. */ + @Deprecated( + message = "GameType.TwelveDigits is deprecated, use SudokuType.Sudoku12x12 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku12x12", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) TwelveDigits(3, 4), /** * The 15x15 game type. */ + @Deprecated( + message = "GameType.FifteenDigits is deprecated, use SudokuType.Sudoku15x15 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku15x15", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) FifteenDigits(3, 5), /** * The 16x16 game type. */ + @Deprecated( + message = "GameType.SixteenDigits is deprecated, use SudokuType.Sudoku16x16 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku16x16", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) SixteenDigits(4, 4), /** * The 25x25 game type. */ + @Deprecated( + message = "GameType.TwentyFiveDigits is deprecated, use SudokuType.Sudoku25x25 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku25x25", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) TwentyFiveDigits(5, 5), /** * The 36x36 game type. */ + @Deprecated( + message = "GameType.ThirtySixDigits is deprecated, use SudokuType.Sudoku36x36 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku36x36", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) ThirtySixDigits(6, 6), /** * The 49x49 game type. */ + @Deprecated( + message = "GameType.FortyNineDigits is deprecated, use SudokuType.Sudoku49x49 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku49x49", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) FortyNineDigits(7, 7), /** * The 64x64 game type. */ + @Deprecated( + message = "GameType.SixtyFourDigits is deprecated, use SudokuType.Sudoku64x64 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku64x64", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) SixtyFourDigits(8, 8), /** * The 81x81 game type. */ + @Deprecated( + message = "GameType.EightyOneDigits is deprecated, use SudokuType.Sudoku81x81 instead.", + replaceWith = + ReplaceWith( + expression = "SudokuType.Sudoku81x81", + "dev.teogor.sudoklify.common.types.SudokuType", + ), + ) EightyOneDigits(9, 9), ; diff --git a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/Seed.kt b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/Seed.kt index c3fc30e..d58050b 100644 --- a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/Seed.kt +++ b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/Seed.kt @@ -97,6 +97,7 @@ sealed class Seed( * greater. */ override fun compareTo(other: Seed): Int { + println("compareTo") return when (this) { is Random -> { if (other is Random) 0 else 1 diff --git a/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/SudokuType.kt b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/SudokuType.kt new file mode 100644 index 0000000..2bf3d11 --- /dev/null +++ b/sudoklify-common/src/main/kotlin/dev/teogor/sudoklify/common/types/SudokuType.kt @@ -0,0 +1,193 @@ +/* + * Copyright 2024 Teogor (Teodor Grigor) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.teogor.sudoklify.common.types + +/** + * Sealed class representing different Sudoku types with varying grid sizes. + * + * @property gridSize The size of the Sudoku grid (width and height). + * + * @property digits The total number of digits used in the Sudoku (width * height). + * @property cells The total number of cells in the Sudoku (digits squared). + * @property isSquare Whether the grid size is square (width == height). + * @property width The width of the Sudoku grid. + * @property height The height of the Sudoku grid. + * @property boxWidth The width of a single box in the grid. + * @property boxHeight The height of a single box in the grid. + * @property name A human-readable name for the Sudoku type (e.g., "4x4"). + */ +sealed class SudokuType( + val gridSize: GridSize, +) { + /** + * The total number of digits used in the Sudoku (width * height). + */ + val digits: Int = gridSize.width * gridSize.height + + /** + * The total number of cells in the Sudoku (digits squared). + */ + val cells: Int = digits * digits + + /** + * Whether the grid size is square (width == height). + */ + val isSquare: Boolean = gridSize.isSquare + + /** + * The width of the Sudoku grid. + */ + val width: Int = digits + + /** + * The height of the Sudoku grid. + */ + val height: Int = digits + + /** + * The width of a single box in the grid. + */ + val boxWidth: Int = gridSize.width + + /** + * The height of a single box in the grid. + */ + val boxHeight: Int = gridSize.height + + /** + * A human-readable name for the Sudoku type (e.g., "4x4"). + */ + val name: String = "${width}x$height" + + /** + * Returns a string representation of the Sudoku type. + */ + final override fun toString(): String = "$width x $height ($digits digits)" + + /** + * Data class representing the size of a Sudoku grid. + * + * @property width The width of the grid. + * @property height The height of the grid. + * + * @property isSquare Whether the grid size is square (width == height). + */ + data class GridSize( + val width: Int, + val height: Int, + ) { + val isSquare: Boolean = width == height + } + + /** + * Companion object used to represent an unspecified Sudoku type. + */ + data object Unspecified : SudokuType( + gridSize = GridSize(0, 0), + ) + + /** + * Object representing a 4x4 Sudoku type. + */ + data object Sudoku4x4 : SudokuType( + gridSize = GridSize(2, 2), + ) + + /** + * Object representing a 6x6 Sudoku type. + */ + data object Sudoku6x6 : SudokuType( + gridSize = GridSize(2, 3), + ) + + /** + * Object representing a 8x8 Sudoku type. + */ + data object Sudoku8x8 : SudokuType( + gridSize = GridSize(2, 4), + ) + + /** + * Object representing a 9x9 Sudoku type. + */ + data object Sudoku9x9 : SudokuType( + gridSize = GridSize(3, 3), + ) + + /** + * Object representing a 10x10 Sudoku type. + */ + data object Sudoku10x10 : SudokuType( + gridSize = GridSize(2, 5), + ) + + /** + * Object representing a 12x12 Sudoku type. + */ + data object Sudoku12x12 : SudokuType( + gridSize = GridSize(3, 4), + ) + + /** + * Object representing a 15x15 Sudoku type. + */ + data object Sudoku15x15 : SudokuType( + gridSize = GridSize(3, 5), + ) + + /** + * Object representing a 16x16 Sudoku type. + */ + data object Sudoku16x16 : SudokuType( + gridSize = GridSize(4, 4), + ) + + /** + * Object representing a 25x25 Sudoku type. + */ + data object Sudoku25x25 : SudokuType( + gridSize = GridSize(5, 5), + ) + + /** + * Object representing a 36x36 Sudoku type. + */ + data object Sudoku36x36 : SudokuType( + gridSize = GridSize(6, 6), + ) + + /** + * Object representing a 49x49 Sudoku type. + */ + data object Sudoku49x49 : SudokuType( + gridSize = GridSize(7, 7), + ) + + /** + * Object representing a 64x64 Sudoku type. + */ + data object Sudoku64x64 : SudokuType( + gridSize = GridSize(8, 8), + ) + + /** + * Object representing a 81x81 Sudoku type. + */ + data object Sudoku81x81 : SudokuType( + gridSize = GridSize(9, 9), + ) +} diff --git a/sudoklify-core/api/sudoklify-core.api b/sudoklify-core/api/sudoklify-core.api index ca9ab90..afc7e8a 100644 --- a/sudoklify-core/api/sudoklify-core.api +++ b/sudoklify-core/api/sudoklify-core.api @@ -5,10 +5,10 @@ public final class dev/teogor/sudoklify/core/generation/ParamsBuilder { public final class dev/teogor/sudoklify/core/generation/ParamsBuilderKt { public static final fun difficulty (Ldev/teogor/sudoklify/core/generation/ParamsBuilder;Lkotlin/jvm/functions/Function0;)V - public static final fun gameType (Ldev/teogor/sudoklify/core/generation/ParamsBuilder;Lkotlin/jvm/functions/Function0;)V public static final fun seed (Ldev/teogor/sudoklify/core/generation/ParamsBuilder;Lkotlin/jvm/functions/Function0;)V public static final fun seeds (Ldev/teogor/sudoklify/core/generation/ParamsBuilder;Lkotlin/jvm/functions/Function0;)V public static final fun sudokuParamsBuilder (Lkotlin/jvm/functions/Function1;)Ldev/teogor/sudoklify/common/model/SudokuParams; + public static final fun sudokuType (Ldev/teogor/sudoklify/core/generation/ParamsBuilder;Lkotlin/jvm/functions/Function0;)V } public final class dev/teogor/sudoklify/core/generation/SudokuGeneratorKt { @@ -17,7 +17,7 @@ public final class dev/teogor/sudoklify/core/generation/SudokuGeneratorKt { } public final class dev/teogor/sudoklify/core/io/BoardSerializationKt { - public static final fun decodeAsBoard (Ljava/lang/String;Ldev/teogor/sudoklify/common/types/GameType;Lkotlin/jvm/functions/Function1;)Ljava/util/List; + public static final fun decodeAsBoard (Ljava/lang/String;Ldev/teogor/sudoklify/common/types/SudokuType;Lkotlin/jvm/functions/Function1;)Ljava/util/List; public static final fun encodeAsString (Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/lang/String; public static final fun generateTokenMap (I)Ljava/util/Map; public static final fun toNumber (Ljava/lang/String;)I @@ -25,16 +25,16 @@ public final class dev/teogor/sudoklify/core/io/BoardSerializationKt { } public final class dev/teogor/sudoklify/core/io/SudokuParser { - public fun (Ljava/lang/String;Ldev/teogor/sudoklify/common/types/GameType;)V + public fun (Ljava/lang/String;Ldev/teogor/sudoklify/common/types/SudokuType;)V public final fun toIntArray ()[[I } public final class dev/teogor/sudoklify/core/io/SudokuParserKt { - public static final fun toSudokuIntArray (Ljava/lang/String;Ldev/teogor/sudoklify/common/types/GameType;)[[I + public static final fun toSudokuIntArray (Ljava/lang/String;Ldev/teogor/sudoklify/common/types/SudokuType;)[[I } public final class dev/teogor/sudoklify/core/solver/SudokuSolver { - public fun ([[ILdev/teogor/sudoklify/common/types/GameType;)V + public fun ([[ILdev/teogor/sudoklify/common/types/SudokuType;)V public final fun solve ()Ldev/teogor/sudoklify/common/model/SudokuSolution; } @@ -65,7 +65,7 @@ public final class dev/teogor/sudoklify/core/tokenizer/Tokenizer$SingleDigitToke public final class dev/teogor/sudoklify/core/util/BoardConversionsKt { public static final fun toBoard (Ljava/lang/String;I)[[Ljava/lang/String; - public static final fun toBoard (Ljava/lang/String;Ldev/teogor/sudoklify/common/types/GameType;)[[Ljava/lang/String; + public static final fun toBoard (Ljava/lang/String;Ldev/teogor/sudoklify/common/types/SudokuType;)[[Ljava/lang/String; public static final fun toSequenceString ([[Ljava/lang/String;)Ljava/lang/String; } diff --git a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/generation/ParamsBuilder.kt b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/generation/ParamsBuilder.kt index 0ece8ca..d7bea2a 100644 --- a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/generation/ParamsBuilder.kt +++ b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/generation/ParamsBuilder.kt @@ -19,8 +19,8 @@ package dev.teogor.sudoklify.core.generation import dev.teogor.sudoklify.common.model.SudokuBlueprint import dev.teogor.sudoklify.common.model.SudokuParams import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.types.Seed +import dev.teogor.sudoklify.common.types.SudokuType import dev.teogor.sudoklify.ktx.createSeed /** @@ -30,7 +30,7 @@ class ParamsBuilder { private var seeds: Array = emptyArray() private var difficulty: Difficulty = Difficulty.EASY private var seed: Seed = createSeed(0) - private var gameType: GameType = GameType.Unspecified + private var sudokuType: SudokuType = SudokuType.Unspecified /** * Set the difficulty level of the Sudoku puzzle. @@ -55,10 +55,10 @@ class ParamsBuilder { /** * Set the type of the Sudoku grid. - * @param gameType The type to set. + * @param sudokuType The type to set. * @return This builder instance for chaining. */ - internal fun setGameType(gameType: GameType) = apply { this.gameType = gameType } + internal fun setSudokuType(sudokuType: SudokuType) = apply { this.sudokuType = sudokuType } /** * Build and return a [SudokuParams] instance using the configured settings. @@ -71,7 +71,7 @@ class ParamsBuilder { seeds, difficulty, seed, - gameType, + sudokuType, ) } @@ -111,6 +111,6 @@ fun ParamsBuilder.seed(block: () -> Seed) { * Set the type of the Sudoku grid using a lambda. * @param block Lambda providing the type. */ -fun ParamsBuilder.gameType(block: () -> GameType) { - setGameType(block()) +fun ParamsBuilder.sudokuType(block: () -> SudokuType) { + setSudokuType(block()) } diff --git a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/generation/SudokuGenerator.kt b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/generation/SudokuGenerator.kt index 897b4bf..0e1d404 100644 --- a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/generation/SudokuGenerator.kt +++ b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/generation/SudokuGenerator.kt @@ -22,10 +22,10 @@ import dev.teogor.sudoklify.common.model.SudokuParams import dev.teogor.sudoklify.common.model.SudokuPuzzle import dev.teogor.sudoklify.common.types.Board import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.types.Layout import dev.teogor.sudoklify.common.types.Seed import dev.teogor.sudoklify.common.types.SudokuString +import dev.teogor.sudoklify.common.types.SudokuType import dev.teogor.sudoklify.common.types.TokenMap import dev.teogor.sudoklify.core.io.toToken import dev.teogor.sudoklify.core.tokenizer.Tokenizer @@ -39,28 +39,27 @@ import kotlin.random.Random internal class SudokuGenerator internal constructor( private val seeds: Array, private val seed: Seed, - private val gameType: GameType, + private val sudokuType: SudokuType, private val difficulty: Difficulty, ) { private val random: Random = seed.toRandom() - private val boxDigits = gameType.gridHeight * gameType.gridWidth - private val totalDigits = boxDigits * boxDigits + private val boxDigits = sudokuType.digits private val baseLayout: Layout = generateBaseLayout() private val tokenizer: Tokenizer = Tokenizer.create(boxDigits) @Deprecated( message = """ This constructor is deprecated. Use the primary constructor - `SudokuGenerator(seeds, seed, gameType, difficulty)` instead. + `SudokuGenerator(seeds, seed, sudokuType, difficulty)` instead. """, - replaceWith = ReplaceWith("SudokuGenerator(seeds, seed, gameType, difficulty)"), + replaceWith = ReplaceWith("SudokuGenerator(seeds, seed, sudokuType, difficulty)"), ) internal constructor( seeds: Array, random: Random, - gameType: GameType, + sudokuType: SudokuType, difficulty: Difficulty, - ) : this(seeds, createSeed(0L), gameType, difficulty) + ) : this(seeds, createSeed(0L), sudokuType, difficulty) private fun generateBaseLayout(): Layout { return Array(boxDigits) { i -> @@ -76,7 +75,7 @@ internal class SudokuGenerator internal constructor( val puzzle = getSequence(layout, seed.puzzle.toSequenceString(), tokenMap) val solution = getSequence(layout, seed.solution.toSequenceString(), tokenMap) - return Sudoku(puzzle, solution, seed.difficulty, gameType) + return Sudoku(puzzle, solution, seed.difficulty, sudokuType) } internal fun createPuzzle(): SudokuPuzzle { @@ -89,7 +88,7 @@ internal class SudokuGenerator internal constructor( return SudokuPuzzle( difficulty = seed.difficulty, - gameType = seed.gameType, + sudokuType = seed.sudokuType, seed = this.seed, givens = puzzle @@ -198,10 +197,10 @@ internal class SudokuGenerator internal constructor( val randomItem = getRandomItem(getSeedsByDifficulty(getSeedsBySize(seeds, boxDigits), difficulty)) return Sudoku( - puzzle = randomItem.puzzle.toBoard(gameType), - solution = randomItem.solution.toBoard(gameType), + puzzle = randomItem.puzzle.toBoard(sudokuType), + solution = randomItem.solution.toBoard(sudokuType), difficulty = randomItem.difficulty, - gameType = randomItem.gameType, + sudokuType = randomItem.sudokuType, ) } @@ -218,7 +217,7 @@ internal class SudokuGenerator internal constructor( size: Int, ): Array = seeds.filter { seed -> - seed.gameType.gridWidth * seed.gameType.gridHeight == size + seed.sudokuType.digits == size }.toTypedArray() private fun getRandomItem(items: Array): SudokuBlueprint = @@ -246,7 +245,7 @@ fun SudokuParams.generateSudoku(): Sudoku { return SudokuGenerator( seeds = seeds, random = seed.toRandom(), - gameType = gameType, + sudokuType = sudokuType, difficulty = difficulty, ).composeSudokuPuzzle() } @@ -264,14 +263,14 @@ fun SudokuParams.generateSudoku(): Sudoku { * * @see Difficulty * @see Seed - * @see GameType + * @see SudokuType * @see SudokuPuzzle */ fun SudokuParams.createPuzzle(): SudokuPuzzle { return SudokuGenerator( seeds = seeds, seed = seed, - gameType = gameType, + sudokuType = sudokuType, difficulty = difficulty, ).createPuzzle() } diff --git a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/io/BoardSerialization.kt b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/io/BoardSerialization.kt index f09f28a..f810ade 100644 --- a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/io/BoardSerialization.kt +++ b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/io/BoardSerialization.kt @@ -16,7 +16,7 @@ package dev.teogor.sudoklify.core.io -import dev.teogor.sudoklify.common.types.GameType +import dev.teogor.sudoklify.common.types.SudokuType import dev.teogor.sudoklify.common.types.Token import dev.teogor.sudoklify.common.types.TokenMap @@ -105,14 +105,14 @@ inline fun List>.encodeAsString(crossinline valueMapper: T.() -> Int * cell values. * * @receiver The string representation of the grid. - * @param gameType The game type, providing information about the expected board + * @param sudokuType The sudoku type, providing information about the expected board * size. * @param valueMapper A function to map each decoded integer to its corresponding * cell value. * @return The decoded board as a list of lists. */ inline fun String.decodeAsBoard( - gameType: GameType, + sudokuType: SudokuType, crossinline valueMapper: Int.() -> T, ): List> { val regex = Regex("([A-I][a-z]+)|-|[A-I]") @@ -120,7 +120,7 @@ inline fun String.decodeAsBoard( val matchedTokens = ArrayList() matches.forEach { matchedTokens.add(it.value) } return matchedTokens - .chunked(gameType.cells) + .chunked(sudokuType.cells) .map { row -> row.map { valueMapper(it.toNumber()) } } } diff --git a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/io/SudokuParser.kt b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/io/SudokuParser.kt index 497e5e3..1e2b9c6 100644 --- a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/io/SudokuParser.kt +++ b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/io/SudokuParser.kt @@ -16,22 +16,22 @@ package dev.teogor.sudoklify.core.io -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.types.SudokuString +import dev.teogor.sudoklify.common.types.SudokuType import dev.teogor.sudoklify.core.util.toBoard /** * A class responsible for parsing and manipulating Sudoku puzzle strings. * * @param puzzle The Sudoku puzzle string to parse. - * @param gameType The game type of the Sudoku puzzle (e.g., 4x4, 9x9). + * @param sudokuType The sudoku type of the Sudoku puzzle (e.g., 4x4, 9x9). */ class SudokuParser( puzzle: String, - gameType: GameType, + sudokuType: SudokuType, ) { - private val puzzleBoard = puzzle.toBoard(gameType) - private val boxDigits = gameType.cells + private val puzzleBoard = puzzle.toBoard(sudokuType) + private val boxDigits = sudokuType.cells /** * Converts the Sudoku puzzle string into a numerical representation. @@ -62,16 +62,16 @@ class SudokuParser( /** * Converts the provided Sudoku puzzle string into a 2D integer array representation. - * This method utilizes a `SudokuParser` object internally to handle the parsing and + * This method utilizes a [SudokuParser] object internally to handle the parsing and * conversion process. * - * @param gameType The game type of the Sudoku puzzle (e.g., 4x4, 9x9). + * @param sudokuType The sudoku type of the Sudoku puzzle (e.g., 4x4, 9x9). * * @return A 2D array of integers representing the parsed Sudoku puzzle. * - * @throws IllegalArgumentException if the provided Sudoku puzzle string is invalid. + * @throws [IllegalArgumentException] if the provided Sudoku puzzle string is invalid. */ -fun SudokuString.toSudokuIntArray(gameType: GameType): Array { - val parser = SudokuParser(this, gameType) +fun SudokuString.toSudokuIntArray(sudokuType: SudokuType): Array { + val parser = SudokuParser(this, sudokuType) return parser.toIntArray() } diff --git a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/solver/SudokuSolver.kt b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/solver/SudokuSolver.kt index bd47270..11328f6 100644 --- a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/solver/SudokuSolver.kt +++ b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/solver/SudokuSolver.kt @@ -17,9 +17,12 @@ package dev.teogor.sudoklify.core.solver import dev.teogor.sudoklify.common.model.SudokuSolution -import dev.teogor.sudoklify.common.types.GameType +import dev.teogor.sudoklify.common.types.SudokuType -class SudokuSolver(private val grid: Array, private val gameType: GameType) { +class SudokuSolver( + private val grid: Array, + private val sudokuType: SudokuType, +) { private val steps: ArrayList> = ArrayList() private var stepCount = 0 @@ -66,7 +69,7 @@ class SudokuSolver(private val grid: Array, private val gameType: Game for (row in grid.indices) { for (col in grid[row].indices) { if (grid[row][col] == 0) { - for (num in 1..gameType.cells) { + for (num in 1..sudokuType.cells) { if (isValid(grid, row, col, num)) { grid[row][col] = num steps.add(Pair(row, col)) @@ -92,14 +95,14 @@ class SudokuSolver(private val grid: Array, private val gameType: Game col: Int, num: Int, ): Boolean { - for (i in 0 until gameType.cells) { + for (i in 0 until sudokuType.cells) { if (grid[row][i] == num || grid[i][col] == num) return false } - val rowStart = (row / gameType.gridHeight) * gameType.gridHeight - val colStart = (col / gameType.gridWidth) * gameType.gridWidth - for (i in rowStart until rowStart + gameType.gridHeight) { - for (j in colStart until colStart + gameType.gridWidth) { + val rowStart = (row / sudokuType.height) * sudokuType.height + val colStart = (col / sudokuType.width) * sudokuType.width + for (i in rowStart until rowStart + sudokuType.height) { + for (j in colStart until colStart + sudokuType.width) { if (grid[i][j] == num) return false } } diff --git a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/util/BoardConversions.kt b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/util/BoardConversions.kt index c25ec52..89b2a2b 100644 --- a/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/util/BoardConversions.kt +++ b/sudoklify-core/src/main/kotlin/dev/teogor/sudoklify/core/util/BoardConversions.kt @@ -17,8 +17,8 @@ package dev.teogor.sudoklify.core.util import dev.teogor.sudoklify.common.types.Board -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.types.SudokuString +import dev.teogor.sudoklify.common.types.SudokuType /** * Converts a `Board` object to a Sudoku string representation. @@ -39,7 +39,7 @@ fun Board.toSequenceString(): SudokuString = * * @return A `Board` representing the Sudoku puzzle. */ -@Deprecated("Use the `toBoard(gameType: GameType)` function instead.") +@Deprecated("Use the `toBoard(sudokuType: SudokuType)` function instead.") fun SudokuString.toBoard(boxDigits: Int): Board { return chunked(boxDigits) .map { chunk -> chunk.map { it.toString() }.toTypedArray() } @@ -50,18 +50,18 @@ fun SudokuString.toBoard(boxDigits: Int): Board { * Converts a `SudokuString` to a list of lists of strings, representing * the Sudoku puzzle in a more granular format. * - * @param gameType The game type, which determines the size of the Sudoku + * @param sudokuType The sudoku type, which determines the size of the Sudoku * puzzle. * * @return A list of lists of strings representing the Sudoku puzzle. */ -fun SudokuString.toBoard(gameType: GameType): Board { +fun SudokuString.toBoard(sudokuType: SudokuType): Board { val regex = Regex("([A-I][a-z]+)|-|[A-I]") val matches = regex.findAll(this) val matchedTokens = ArrayList() matches.forEach { matchedTokens.add(it.value) } return matchedTokens - .chunked(gameType.gridWidth * gameType.gridWidth) + .chunked(sudokuType.digits) .map { row -> row.map { it }.toTypedArray() } .toTypedArray() } diff --git a/sudoklify-ktx/api/sudoklify-ktx.api b/sudoklify-ktx/api/sudoklify-ktx.api index 9230f81..25d09a1 100644 --- a/sudoklify-ktx/api/sudoklify-ktx.api +++ b/sudoklify-ktx/api/sudoklify-ktx.api @@ -12,3 +12,19 @@ public final class dev/teogor/sudoklify/ktx/SeedExtensionsKt { public static final fun toSeed (J)Ldev/teogor/sudoklify/common/types/Seed; } +public final class dev/teogor/sudoklify/ktx/SudokuTypeExtensionsKt { + public static final fun areCellsInSameBox (Ldev/teogor/sudoklify/common/types/SudokuType;II)Z + public static final fun areCellsInSameBox (Ldev/teogor/sudoklify/common/types/SudokuType;IIII)Z + public static final fun areCellsInSameColumn (Ldev/teogor/sudoklify/common/types/SudokuType;II)Z + public static final fun areCellsInSameRow (Ldev/teogor/sudoklify/common/types/SudokuType;II)Z + public static final fun areCellsRelated (Ldev/teogor/sudoklify/common/types/SudokuType;IIII)Z + public static final fun getAllDigits (Ldev/teogor/sudoklify/common/types/SudokuType;)Ljava/util/List; + public static final fun getBoxCoordinates (Ldev/teogor/sudoklify/common/types/SudokuType;II)Ldev/teogor/sudoklify/common/types/BoxCoordinates; + public static final fun getBoxIndex (Ldev/teogor/sudoklify/common/types/SudokuType;II)I + public static final fun getCellBoxColumnIndex (Ldev/teogor/sudoklify/common/types/SudokuType;I)I + public static final fun getCellBoxRowIndex (Ldev/teogor/sudoklify/common/types/SudokuType;I)I + public static final fun getCellColumnIndex (Ldev/teogor/sudoklify/common/types/SudokuType;I)I + public static final fun getCellRowIndex (Ldev/teogor/sudoklify/common/types/SudokuType;I)I + public static final fun isDigitValid (Ldev/teogor/sudoklify/common/types/SudokuType;I)Z +} + diff --git a/sudoklify-ktx/src/main/kotlin/dev/teogor/sudoklify/ktx/SudokuTypeExtensions.kt b/sudoklify-ktx/src/main/kotlin/dev/teogor/sudoklify/ktx/SudokuTypeExtensions.kt new file mode 100644 index 0000000..8fd3c25 --- /dev/null +++ b/sudoklify-ktx/src/main/kotlin/dev/teogor/sudoklify/ktx/SudokuTypeExtensions.kt @@ -0,0 +1,271 @@ +/* + * Copyright 2024 Teogor (Teodor Grigor) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.teogor.sudoklify.ktx + +import dev.teogor.sudoklify.common.types.BoxCoordinates +import dev.teogor.sudoklify.common.types.SudokuType + +/** + * Returns a list containing all valid digits (1 to [SudokuType.digits]) for the + * Sudoku. + */ +fun SudokuType.getAllDigits(): List = (1..digits).toList() + +/** + * Checks if a given digit is valid within the range of allowed digits for this Sudoku + * (1 to [SudokuType.digits]). + */ +fun SudokuType.isDigitValid(digit: Int): Boolean = digit in 1..digits + +/** + * Returns the box index (within the range 0 to [SudokuType.boxes - 1]) for a given cell + * at the specified row and column. + * + * Throws an [IllegalArgumentException] with a specific message if the provided row or + * column index is invalid. + */ +fun SudokuType.getBoxIndex( + row: Int, + col: Int, +): Int { + requireValidRowColIndices( + row = row, + col = col, + message = "Invalid coordinates for box", + ) + + val boxWidth = gridSize.width + val boxHeight = gridSize.height + + val boxRowIndex = row / boxHeight + val boxColumnIndex = col / boxWidth + + return boxRowIndex * boxWidth + boxColumnIndex +} + +/** + * Returns the top-left and bottom-right coordinates of the box containing the cell at the + * specified row and column. + * + * Throws an [IllegalArgumentException] with a specific message if the provided row or + * column index is invalid. + */ +fun SudokuType.getBoxCoordinates( + row: Int, + col: Int, +): BoxCoordinates { + requireValidRowColIndices( + row = row, + col = col, + message = "Invalid coordinates for box", + ) + + val boxWidth = gridSize.width + val boxHeight = gridSize.height + + val boxRowIndex = row / boxHeight + val boxColumnIndex = col / boxWidth + + return BoxCoordinates( + topLeftCol = boxColumnIndex * boxWidth, + topLeftRow = boxRowIndex * boxHeight, + bottomRightCol = (boxColumnIndex + 1) * boxWidth - 1, + bottomRightRow = (boxRowIndex + 1) * boxHeight - 1, + ) +} + +/** + * Returns the row index (within the range 0 to [SudokuType.height - 1]) for a given cell + * index. + * + * Throws an [IllegalArgumentException] with a specific message if the provided cell index + * is invalid. + */ +fun SudokuType.getCellRowIndex(cellIndex: Int): Int { + requireValidCellIndex(cellIndex = cellIndex, message = "Invalid cell index for row calculation") + return cellIndex / width +} + +/** + * Returns the column index (within the range 0 to [SudokuType.width - 1]) for a given cell + * index. + * + * Throws an [IllegalArgumentException] with a specific message if the provided cell index + * is invalid. + */ +fun SudokuType.getCellColumnIndex(cellIndex: Int): Int { + requireValidCellIndex( + cellIndex = cellIndex, + message = "Invalid cell index for column calculation", + ) + return cellIndex % width +} + +/** + * Returns the box row index (within the range 0 to ([SudokuType.height] - 1 / + * [SudokuType.boxHeight] - 1)) for a given cell index. + * + * Throws an [IllegalArgumentException] with a specific message if the provided cell index + * is invalid. + */ +fun SudokuType.getCellBoxRowIndex(cellIndex: Int): Int { + requireValidCellIndex( + cellIndex = cellIndex, + message = "Invalid cell index for box row", + ) + return cellIndex / width +} + +/** + * Returns the box column index (within the range 0 to ([SudokuType.width - 1] / + * [SudokuType.boxWidth] - 1)) for a given cell index. + * + * Throws an [IllegalArgumentException] with a specific message if the provided cell + * index is invalid. + */ +fun SudokuType.getCellBoxColumnIndex(cellIndex: Int): Int { + requireValidCellIndex( + cellIndex = cellIndex, + message = "Invalid cell index for box column calculation", + ) + return (cellIndex % width) / boxWidth +} + +/** + * Checks if two cells are in the same row based on their indices. + * + * Throws an [IllegalArgumentException] with a specific message if either cell index + * is invalid. + */ +fun SudokuType.areCellsInSameRow( + cellIndex1: Int, + cellIndex2: Int, +): Boolean { + requireValidCellIndex( + cellIndex = cellIndex1, + message = "Invalid cell index for row comparison", + ) + requireValidCellIndex( + cellIndex = cellIndex2, + message = "Invalid cell index for row comparison", + ) + return getCellRowIndex(cellIndex1) == getCellRowIndex(cellIndex2) +} + +/** + * Checks if two cells are in the same column based on their indices. + * + * Throws an [IllegalArgumentException] with a specific message if either cell + * index is invalid. + */ +fun SudokuType.areCellsInSameColumn( + cellIndex1: Int, + cellIndex2: Int, +): Boolean { + requireValidCellIndex( + cellIndex = cellIndex1, + message = "Invalid cell index for column comparison", + ) + requireValidCellIndex( + cellIndex = cellIndex2, + message = "Invalid cell index for column comparison", + ) + return getCellColumnIndex(cellIndex1) == getCellColumnIndex(cellIndex2) +} + +/** + * Checks if two cells are in the same box based on their indices. + * + * Throws an [IllegalArgumentException] with a specific message if either cell index + * is invalid. + */ +fun SudokuType.areCellsInSameBox( + cellIndex1: Int, + cellIndex2: Int, +): Boolean { + requireValidCellIndex( + cellIndex = cellIndex1, + message = "Invalid cell index for box comparison", + ) + requireValidCellIndex( + cellIndex = cellIndex2, + message = "Invalid cell index for box comparison", + ) + return getCellBoxRowIndex(cellIndex1) == getCellBoxRowIndex(cellIndex2) && + getCellBoxColumnIndex(cellIndex1) == getCellBoxColumnIndex(cellIndex2) +} + +/** + * This alternative way to check if two cells are in the same box uses their row and + * column indices directly. + * + * Throws an [IllegalArgumentException] with a specific message if either row or column + * index is invalid. + */ +fun SudokuType.areCellsInSameBox( + row1: Int, + col1: Int, + row2: Int, + col2: Int, +): Boolean = getBoxIndex(row1, col1) == getBoxIndex(row2, col2) + +/** + * Checks if two cells are related (in the same row, column, or box) based on their row + * and column indices. + * + * Throws an [IllegalArgumentException] with a specific message if any of the row or + * column indices are invalid. + */ +fun SudokuType.areCellsRelated( + row1: Int, + col1: Int, + row2: Int, + col2: Int, +): Boolean { + return row1 == row2 || col1 == col2 || areCellsInSameBox(row1, col1, row2, col2) +} + +/** + * Internal helper function to validate a cell index. + * + * Throws an [IllegalArgumentException] with a specific message if the provided cell + * index is invalid. + */ +private fun SudokuType.requireValidRowColIndices( + row: Int, + col: Int, + message: String = "Invalid row/column indices", +) { + require(row in 0.. = arrayOf( puzzle = "-BCDCDA-BAD--CBA", solution = "ABCDCDABBADCDCBA", difficulty = Difficulty.EASY, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "BADCD--AA--DCDAB", solution = "BADCDCBAABCDCDAB", difficulty = Difficulty.EASY, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "DC-ABA-CCD-BAB-D", solution = "DCBABADCCDABABCD", difficulty = Difficulty.EASY, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "DCB-BA-CC-AB-BCD", solution = "DCBABADCCDABABCD", difficulty = Difficulty.EASY, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "C-ABA-CDD-BAB-DC", solution = "CDABABCDDCBABADC", difficulty = Difficulty.EASY, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "-DABA-CDDC-ABAD-", solution = "CDABABCDDCBABADC", difficulty = Difficulty.EASY, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "BADC----ABCDCDAB", solution = "BADCDCBAABCDCDAB", difficulty = Difficulty.EASY, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "----CDABBADCDCBA", solution = "ABCDCDABBADCDCBA", difficulty = Difficulty.EASY, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), // Medium @@ -80,49 +80,49 @@ val fourDigitsSeeds: Array = arrayOf( puzzle = "D--B-CA--DB-C--A", solution = "DACBBCADADBCCBDA", difficulty = Difficulty.MEDIUM, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "-BC-A--DB--C-AD-", solution = "DBCAACBDBDACCADB", difficulty = Difficulty.MEDIUM, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "--CDCD--AB----AB", solution = "BACDCDBAABDCDCAB", difficulty = Difficulty.MEDIUM, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "DB----BDCA----AC", solution = "DBCAACBDCADBBDAC", difficulty = Difficulty.MEDIUM, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "--CD--BAAB--DC--", solution = "BACDCDBAABDCDCAB", difficulty = Difficulty.MEDIUM, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "-BC-A--BC--D-DA-", solution = "DBCAACDBCABDBDAC", difficulty = Difficulty.MEDIUM, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "C--AD--B-CA--DB-", solution = "CBDADACBBCADADBC", difficulty = Difficulty.MEDIUM, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "B--A-DC--BA-C--D", solution = "BCDAADCBDBACCABD", difficulty = Difficulty.MEDIUM, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), // Hard @@ -130,49 +130,49 @@ val fourDigitsSeeds: Array = arrayOf( puzzle = "-CD-D--CC--A-AC-", solution = "ACDBDBACCDBABACD", difficulty = Difficulty.HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "D-A-A-B--D-A-A-B", solution = "DBACACBDBDCACADB", difficulty = Difficulty.HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "-DB--BA-D--BB--A", solution = "ADBCCBADDACBBCDA", difficulty = Difficulty.HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "-D-A-A-D-C-BA-D-", solution = "BDCACABDDCABABDC", difficulty = Difficulty.HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "-DC--CB-D--CC--B", solution = "BDCAACBDDBACCADB", difficulty = Difficulty.HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "--CDDC----BCCB--", solution = "BACDDCABADBCCBDA", difficulty = Difficulty.HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "AB----BABD----DB", solution = "ABCDDCBABDACCADB", difficulty = Difficulty.HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "A--B-BC--AB-B--C", solution = "ACDBDBCACABDBDAC", difficulty = Difficulty.HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), // VERY_HARD @@ -180,48 +180,48 @@ val fourDigitsSeeds: Array = arrayOf( puzzle = "-AC---------CDBA", solution = "BACDDCABABDCCDBA", difficulty = Difficulty.VERY_HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "-C-A--B---C--D-B", solution = "BCDADABCABCDCDAB", difficulty = Difficulty.VERY_HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "BDCA-----AB-----", solution = "BDCAACDBCABDDBAC", difficulty = Difficulty.VERY_HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "----ABCD-DB-----", solution = "DCABABCDCDBABADC", difficulty = Difficulty.VERY_HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "C----A-B-CD-A---", solution = "CBADDACBBCDAADBC", difficulty = Difficulty.VERY_HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "-CB--A---DA--B--", solution = "DCBABACDCDABABDC", difficulty = Difficulty.VERY_HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "A--D---B---CD--A", solution = "ABCDCDABBADCDCBA", difficulty = Difficulty.VERY_HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), SudokuBlueprint( puzzle = "----DACB-BA-----", solution = "BCDADACBCBADADBC", difficulty = Difficulty.VERY_HARD, - gameType = GameType.FourDigits, + sudokuType = SudokuType.Sudoku4x4, ), ) diff --git a/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/NineDigitsSeeds.kt b/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/NineDigitsSeeds.kt index 3d62915..28dc352 100644 --- a/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/NineDigitsSeeds.kt +++ b/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/NineDigitsSeeds.kt @@ -17,8 +17,8 @@ package dev.teogor.sudoklify.seeds import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.model.SudokuBlueprint +import dev.teogor.sudoklify.common.types.SudokuType /** * An array of `SudokuBlueprint` objects representing easy 9x9 Sudoku puzzles. @@ -29,223 +29,223 @@ val nineDigitsSeeds: Array = arrayOf( puzzle = "--CE-DG---BDF-GEI----C-B---GAF---IEH---------BCI---ADG---I-H----DBG-ECA---EB-AD--", solution = "FHCEIDGBAABDFHGEICEIGCABHFDGAFDBCIEHDEHAGIFCBBCIHEFADGCFAIDHBGEHDBGFECAIIGEBCADHF", difficulty = Difficulty.VERY_EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 47 SudokuBlueprint( puzzle = "--BD-GI--DE-----HG---HIE---B-E---D-I--HF-AE--A-D---H-C---CAD---EI-----DH--CI-HA--", solution = "CHBDFGIEADEIACBFHGFAGHIEBCDBFEGHCDAIICHFDAEGBAGDEBIHFCHBFCADGIEEIABGFCDHGDCIEHABF", difficulty = Difficulty.VERY_EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 48 SudokuBlueprint( puzzle = "-G-F-D-A-B---C---H-E-B-H-C-A-E---F-I-C--I--D-I-G---C-A-I-C-A-B-C---D---G-H-I-E-F-", solution = "HGCFEDIABBFAGCIDEHDEIBAHGCFABEDHCFGIFCHAIGBDEIDGEFBCHAEIFCGAHBDCABHDFEIGGHDIBEAFC", difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 49 SudokuBlueprint( puzzle = "-FBI--HA---IGE-D--D---A---G--D----EF-H-----D-FE----G--A---I---H--H-FAB---BF--CIG-", solution = "GFBICDHAEHAIGEFDBCDCEHABFIGBIDAGHCEFCHGFBEADIFEACDIGHBADCBIGEFHIGHEFABCDEBFDHCIGA", difficulty = Difficulty.VERY_EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 49 SudokuBlueprint( puzzle = "--HC-FG----ID-HE---D-----I-IF--H--AC---F-B---HE--D--GB-I-----F---EI-GB----FB-DH--", solution = "EBHCIFGDACAIDGHEBFFDGEBACIHIFBGHEDACDGAFCBIHEHECADIFGBBIDHECAFGAHEIFGBCDGCFBADHEI", difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 49 SudokuBlueprint( puzzle = "-D-FEC-BI-F-------E-G-A-C--D----H--BB-F---E-AG--B----C--H-C-B-FF------C-C--GHF-E-", solution = "HDAFECGBIIFCHGBDAEEBGDAICFHDCEAFHIGBBHFCIGEDAGAIBDEFHCAGHECDBIFFEDIBAHCGCIBGHFAED", difficulty = Difficulty.VERY_EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 49 SudokuBlueprint( puzzle = "-HD-A-EF-G--D----AB-I-C-G-D---A-------A---D--E----D--IA-C-E-B-GH----I--C-GE-B-FI-", solution = "CHDIAGEFBGEFDHBICABAIECFGHDIDHAGECBFFBAHICDGEECGBFDHAIAICFEHBDGHFBGDIAECDGECBAFIH", difficulty = Difficulty.MEDIUM, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 49 SudokuBlueprint( puzzle = "-----------D-HCI--F--DGE--A-DH-F-E---AIE-HFB---F-C-DI-A--GBI--D--GCE-A-----------", solution = "HGAFIBCDEEBDAHCIGFFICDGEBHABDHIFGEACCAIEDHFBGGEFBCADIHAFEGBIHCDIHGCEDAFBDCBHAFGEI", difficulty = Difficulty.HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 50 SudokuBlueprint( puzzle = "F--I-D--EG--B-E--D----A----CH-F---BG--I-D-F--AF---B-EI----I----I--D-G--AD--A-C--F", solution = "FCBIGDHAEGIABHECFDHDECAFIGBCHDFEIABGEBIGDAFCHAFGHCBDEIBAFEIHGDCIECDFGBHADGHABCEIF", difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 51 SudokuBlueprint( puzzle = "--GF-E-B----C-A--D----I-H-CFE-----IG--H---E--GC-----HB--D-B----I--A-G----GFI-DA--", solution = "CDGFHEIBAHIBCGAFEDAFEDIBHGCFEABDHCIGDBHGCIEAFGCIEAFDHBEADHBCGFIIHCAFGBDEBGFIEDACH", difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 52 SudokuBlueprint( puzzle = "-------GH------IEBE---IH-F-D---BCE--C---D---F--AIH---D-F--EA---AGE------HD----C--", solution = "BCIEFDAGHFHDCAGIEBEAGBIHDFCDIFGBCEHACBHADEGIFGEAIHFBCDIFCDEAHBGAGEHCBFDIHDBFGICAE", difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 53 SudokuBlueprint( puzzle = "------------EBFD---B--G-I-E-G--F--I--DIC-BGH--F--H--A-F-H-D--G---EHIA------------", solution = "DEFIACHBGIHGEBFDCACBADGHIFEHGBAFDEICADICEBGHFEFCGHIBADFAHBDECGIGCEHIAFDBBIDFCGAEH", difficulty = Difficulty.MEDIUM, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 53 SudokuBlueprint( puzzle = "C--B---H--HE---B---AB--E--D---D-H-CI---------BC-I-F---D----IHA---C---DI--F-H----E", solution = "CDFBIGEHAIHEFDABGCGABCHEIFDEGADBHFCIFIHGECADBBCDIAFGEHDBGECIHAFHECAFBDIGAFIHGDCBE", difficulty = Difficulty.MEDIUM, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 53 SudokuBlueprint( puzzle = "-----HFC----AD--IBI-F-C-----EH---IA----------DF-----BEE---H-D-CFC-EB-----H---I---", solution = "BDEGIHFCAHGCADFEIBIAFBCEGDHCEHDFBIAGGBAIECHFDDFIHAGCBEEIBFHADGCFCGEBDAHIAHDCGIBEF", difficulty = Difficulty.MEDIUM, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 53 SudokuBlueprint( puzzle = "BG--IE----E-HC---F-H-B-G----BH---IC-A-------G------------A-H-G-C--DG--H-----BF-ED", solution = "BGCFIEDAHIEDHCAGBFFHABDGEICEBHGFDICAADIEHCBFGGCFIABHDEDFBAEHCGICAEDGIFHBHIGCBFAED", difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 53 SudokuBlueprint( puzzle = "G--A-I--C----------BD--CEA---GD-BI---D-----B-F--H-E--A-CI--FAG----------H--I-D--E", solution = "GEHADIBFCCAFBEHGIDIBDGFCEAHAHGDCBIEFEDCFIAHBGFIBHGECDADCIEHFAGBBFECAGDHIHGAIBDFCE", difficulty = Difficulty.HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 53 SudokuBlueprint( puzzle = "--H---D---I-C---A--GD--AIC---I-A--H----H-C----F--I-C---AEF--HI--H---B-G---F---E--", solution = "ACHGBIDFEEIBCDFGAHFGDEHAICBCEIDAGBHFDBGHFCAEIHFABIECDGBAEFGDHICIHCAEBFGDGDFICHEBA", difficulty = Difficulty.VERY_HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 53 SudokuBlueprint( puzzle = "-EC-I-FB-B--H----CD----A--I--B----F-C-------D-I----A--I--E----FF----I--G-HD-B-IC-", solution = "HECGIDFBABAIHFEGDCDFGBCAHEIADBIEGCFHCGHFABEIDEIFCDHAGBIBAEGCDHFFCEDHIBAGGHDABFICE", difficulty = Difficulty.VERY_HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 54 SudokuBlueprint( puzzle = "A--D----C-IE---GA---B---F---F---CI-A----D----G-AI---H---G---H---AI---BD-E----B--I", solution = "AHFDGIEBCCIEFBHGADDGBCAEFIHBFDGHCIEAIEHBDACFGGCAIEFDHBFBGAIDHCEHAIECGBDFEDCHFBAGI", difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 54 SudokuBlueprint( puzzle = "-F-----G-H-------B--CEF-I----H--CD--CE--H--IF--AD--H----B-GEC--A-------D-G-----H-", solution = "EFIHDBAGCHDGCAIFEBBACEFGIDHFBHIECDAGCEDGHABIFGIADBFHCEDHBAGECFIACEFIHGBDIGFBCDEHA", difficulty = Difficulty.MEDIUM, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 55 SudokuBlueprint( puzzle = "-C-H-EG--D-E-----A---B------F--B--D-A--G-F--BI---H---G-----B-I-C-------D--GF-I-A-", solution = "FCAHDEGBIDBEIFGCHAHGIBACDEFGFCEBAIDHAHDGIFECBIEBCHDAFGEAHDGBFICCIFAEHBGDBDGFCIHAE", difficulty = Difficulty.MEDIUM, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 55 SudokuBlueprint( puzzle = "-E-CI-A------H----G------I--F--------GE--H-DCA-HFCD---------G-D---AE---B-----C-FE", solution = "DEFCIGABHBIADHFCEGGHCEBADIFCFDIGEBHAIGEBAHFDCABHFCDEGIECIHFBGADFDGAEIHCBHABGDCIFE", difficulty = Difficulty.VERY_HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 55 SudokuBlueprint( puzzle = "-DAI----E-------CF----BH-----DF-E--I--E---C--A--D-GE-----HG----EB-------F----ABG-", solution = "GDAIFCHBEIHBAEDGCFCEFGBHDIABGDFCEAHIHFEBAICDGAICDHGEFBDAIHGBFECEBGCDFIAHFCHEIABGD", difficulty = Difficulty.VERY_HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 55 SudokuBlueprint( puzzle = "-H-----C-IG--B---F---I-D--B--IH--C---F-----B---A--BE-----D-G---H---F--IE-AF----G-", solution = "AHBEGFDCIIGDCBHAEFFECIADGHBEBIHDACFGDFHGCEIBAGCAFIBEDHBIEDHGFACHDGAFCBIECAFBEIHGD", difficulty = Difficulty.HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 55 SudokuBlueprint( puzzle = "F-D-H-C------DF---E-----AD-D---G----G--B-E--H----F---AH-I-----D--E-ID-------C-G-E", solution = "FADEHGCBIICBADFEHGEHGCBIADFDFAIGHBECGICBAEDFHBEHDFCIGAHBIGEAFCDCGEFIDHABADFHCBGIE", difficulty = Difficulty.HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 56 SudokuBlueprint( puzzle = "D----I----CE-GA--F----E---HI------BC-----B-I-F----E---C-H--GB--B-G---A----A-----I", solution = "DAFCHIGEBHCEBGAIDFGBIFEDCAHIHDGAFEBCAECHDBFIGFGBICEDHACDHAIGBFEBIGEFHACDEFADBCHGI", difficulty = Difficulty.VERY_HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 56 SudokuBlueprint( puzzle = "--B----G--IE------C-----E-F---C-E--B---G--A--F---A--I--------H------IBADEH--BAI--", solution = "DFBAECHGIHIEBGFCDACGAIDHEBFADHCIEGFBIBCGFDAEHFEGHABDICBAIDCGFHEGCFEHIBADEHDFBAICG", difficulty = Difficulty.MEDIUM, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 56 SudokuBlueprint( puzzle = "---BF--I---------F--G--C-B----F----GF--HD--EIB-E--G----E-----A--C---E--H---DI-F--", solution = "EHABFDGICCBDGAIEHFIFGEHCABDAIHFEBCDGFGCHDABEIBDEICGHFAHEICGFDABDCFABEIGHGABDIHFCE", difficulty = Difficulty.HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 56 SudokuBlueprint( puzzle = "-E---D-C------I---F-A---D-I--H--AC------B-----IDC--GE-I-F---B-H---A------C-B---F-", solution = "BEIHADFCGHDCFGIABEFGAECBDHIEBHGDACIFCFGIBEHADAIDCFHGEBIAFDECBGHGHBAIFEDCDCEBHGIFA", difficulty = Difficulty.HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 57 SudokuBlueprint( puzzle = "-D-----EB---GBEI---I---D-H-B---E----------D----I--CH------C---G-B-I-----F-HBA----", solution = "CDGHIAFEBHFAGBEICDEIBCFDGHABHFDEIAGCAGCFHBDIEDEIAGCHBFIADECHBFGGBEIDFCAHFCHBAGEDI", difficulty = Difficulty.VERY_HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 58 SudokuBlueprint( puzzle = "E--B---G----A-----GC-H----ID-E--H--BH----BDA---------F------E-D--A-F----I------C-", solution = "EADBIFCGHFHIACGBDEGCBHDEAFIDFECAHGIBHIGFEBDACABCDGIHEFCGFIHAEBDBDAEFCIHGIEHGBDFCA", difficulty = Difficulty.HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), // Remaining Digits 58 SudokuBlueprint( puzzle = "--------FC-----G-I--BAF--H-E--GB-A--H-F-C---------------CE-I-D--G-H------A----C--", solution = "DEHCIGBAFCFABHDGEIGIBAFEDHCECIGBHAFDHBFDCAEIGADGIEFHCBBHCEGIFDAFGDHACIBEIAEFDBCGH", difficulty = Difficulty.HARD, - gameType = GameType.NineDigits, + sudokuType = SudokuType.Sudoku9x9, ), ) diff --git a/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/Seeds.kt b/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/Seeds.kt index 6b7559c..f67ca67 100644 --- a/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/Seeds.kt +++ b/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/Seeds.kt @@ -17,7 +17,7 @@ package dev.teogor.sudoklify.seeds import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType +import dev.teogor.sudoklify.common.types.SudokuType val combinedSeeds = arrayOf( *fourDigitsSeeds, @@ -30,11 +30,11 @@ val combinedSeeds = arrayOf( * Checks if this game type supports the specified difficulty level. * * @param difficulty The difficulty level to check for. - * @return True if the game type supports the given difficulty, + * @return True if the sudoku type supports the given difficulty, * false otherwise. */ -fun GameType.supportsDifficulty( +fun SudokuType.supportsDifficulty( difficulty: Difficulty, ) = combinedSeeds.any { - it.gameType == this && it.difficulty == difficulty + it.sudokuType == this && it.difficulty == difficulty } diff --git a/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/SixteenDigitsSeeds.kt b/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/SixteenDigitsSeeds.kt index cfe7052..7eb5697 100644 --- a/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/SixteenDigitsSeeds.kt +++ b/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/SixteenDigitsSeeds.kt @@ -16,9 +16,9 @@ package dev.teogor.sudoklify.seeds -import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.model.SudokuBlueprint +import dev.teogor.sudoklify.common.types.Difficulty +import dev.teogor.sudoklify.common.types.SudokuType /** * An array of `SudokuBlueprint` objects representing easy 16x16 Sudoku puzzles. @@ -29,96 +29,96 @@ val sixteenDigitsSeeds: Array = arrayOf( puzzle = "AdA-----EHD----AeC-----A---B--Af-----Ab-G--H--C-AF-------Aj-AaF-EAe--H--AbCAa-AeEIDGAj-HBAf---AjDAd--G-AeFEICA-EIAe-C-AbBAcAa-HD-Aj-HG-FD-----Af--AeEAcAjAeA--C-----AbE-IB-Ad-IAe-AaAbEH-Aj-AcFA-AaECAjBA-Ae--IGAf---DFH-EIAcAAdB-AaAjAb--Aj--ED-AfI-H-------AcG-Ab--Af--Ad-E-----Ad--G---A-----AAf----CFB-----AaAj", solution = "AdAAaAfBFAcEHDAbGAjIAeCAeFHAjAbADCAdBIAcAfAaGEIAcAbEGAdAeHAaAjCAfAFBDDCGBIAjAfAaFAEAeAcAdHAbAcAbCAaFAeEIDGAjAHBAfAdAfBAjDAdAcHGAbAeFEICAAaEIAeACAfAbBAcAaAdHDGAjFHGAdFDAaAjACIAfBAbAeEAcAjAeAAcHCFAdGAfAaAbEDIBBAdAfIAeGAaAbEHDAjCAcFAAbAaECAjBADAeFAcIGAfAdHGDFHAfEIAcAAdBCAaAjAbAeFAjBAbEDAdAfIAcHAaAeACGAaHAcGAAbBAjAfCAeAdFEDICEDAdAaIGAeAjAbAFBHAcAfAAfIAeAcHCFBEGDAdAbAaAj", difficulty = Difficulty.VERY_HARD, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 130 SudokuBlueprint( puzzle = "---B--F-G---AeAb--GD-FI--B-AjAc-AdACAfIAfHAAeAdAj-CAa--EG-DAdAc---HAAf--I-Aa--FBAd-Af-----I-AaH-----G-H---A-FAd-----AaAHBFAcIAbAeG-----FI-DAd---Ac-----Ab--A-----D---AcG-AfB-----EAbFAfDAGAcAeI-----AjA-G---Ae-E-----GAf-B-----Ab-AAjAc--C-Aj--AdHE---AaAbA-AjAd--IH-GAfDCAcEAeAaBDI-AcC-Aj--AbF-GH--AfE---Aa-Ac--Aj---", solution = "EAjAaBAcDFCGAfAdAAeAbHIGDAbFIAaEBAeAjAcHAdACAfIAfHAAeAdAjAbCAaBFEGAcDAdAcCAeGHAAfDAbIEAaBAjFBAdAcAfAAbGAjEIDAaHFAeCAbAeGAjHAfDEACFAdIAaBAcCAaAHBFAcIAbAeGAjAfAdDEFIEDAdCAaAeAcBHAfAAjAbGAeAFAbAaIAdDHEAjAcGCAfBAjHBAaCEAbFAfDAGAcAeIAdAfCIAcAjAHGBAdAbAeDEFAaDEAdGAfAeBAcIFAaCAbHAAjAcGAeCFAjAfAAdHEIBDAaAbAFAjAdAbBIHAaGAfDCAcEAeAaBDIEAcCAdAjAAeAbFAfGHHAbAfEDGAeAaFAcCBAjIAdA", difficulty = Difficulty.VERY_HARD, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), SudokuBlueprint( puzzle = "-BE----Ab-Af-AdHAj-G--Ac-Ae-H--GAAaI----C-F--E-H-Aj--Af-A----AfBAAaC-Ae---Ad-DAbAf-----GFAc-A-------HDG----Aj-I--E--BAaA-Ae-----GF-AjG---I---DC-Ab--AfA--Ac-AeAd---G---CAb-EI-----Af-AdFAj--H--H-A----EAbC-------Ad-GAaB-----AIAe-A---Aa-CFAjIAc----Ac-D--H-E-Ad--G-Aj----AfAbAjAe--C-G-Aa--G-AaED-F-B----AcAf-", solution = "AaBEAICDAbAcAfFAdHAjAeGAfAdAcDAeFHAjAbGAAaICBEICAeFAdAcEGHBAjDAaAfAbAAbHGAjAfBAAaCIAeEFDAdAcDAbAfIAjECAdGFAcAeAHAaBFAaAAeHDGAfEAbBAjAdIAcCEAcCBAaAAbAeAdHAfIDGFAjAjGAdHAcIBFAaDCAAbAeEAfADAjAcEAeAdHIAaGBAfFCAbAeEIAaCAbAcDAfAAdFAjBGHBFHGAAfAjIAeEAbCAcAdDAaCAfAbAdFGAaBAjAcDHEAIAeAdABAbGAaAfCFAjIAcAeEHDAcAeDCBHIEAAdAaAfGAbAjFHIFAfAbAjAeAcDCEGBAaAAdGAjAaEDAdFABAeHAbCAcAfI", difficulty = Difficulty.VERY_EASY, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 142 SudokuBlueprint( puzzle = "--D--AjFG--I---AfAc------AbAa-AjDFH-G----HDAfI-GAa---E-----AaEA-CH---D--Ab---IAe-HEAbB-Af-A-F-AcH-AjAb-------D-AfAe--Aj---Ac---A-AdAa-Af--EIFB-----AeAb-HF-AeG-----AAdBAa--C-EI-Aa---Af---A--AeAb-Aa-------CG-AjH-D-C-A-AcHAjAe-AaAb---B--A---AeD-AfAdAj-----Ad---AjI-FEAeC----F-DCEA-BG------HG---D--ACAa--Af--", solution = "AAeDCHAjFGAdAbIEBAaAfAcEIAfBAdAcAbAaAeAjDFHCGAAcAdAbHDAfIBGAaACFEAeAjGAjFAaEAAeCHAfBAcDIAdAbAdDGIAeAaHEAbBAjAfAcACFCAcHFAjAbGAAaAdAeIEDBAfAeAbBAjAfCDAcFEHAGAdAaIAfAaAEIFBAdCAcGDAeAbAjHFHAeGAbIAfAjEAAdBAaAcDCAjEIAdAaGCDAfHAcAbABFAeAbAAaAcBAeEFIDCGAfAjHAdDBCAfAAdAcHAjAeFAaAbGIEBCEAAcHAaAeDIAfAdAjFAbGAaAfAdAbGBAjIAcFEAeCHADIFAjDCEAAfBGAbHAdAeAcAaHGAcAeFDAdAbACAaAjIAfEB", difficulty = Difficulty.VERY_EASY, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 146 SudokuBlueprint( puzzle = "-FAaG-------ID--Ad-Ac-Af-----AdFE-CBAe------Ad--CAb-IAj-Ac--I-AfDAcFH--Aj-Ab-----H-A--AfI-------Aa--EAf-I--Ac-BAeH-A-Af----Ac-AbC-AaG--ID---Aj--GA--AcAfC--AbHE--DAf--B---AcF--AAc-GF-Ae----Ad-Af-AeAjC-B--F-AdAc--A-------AjA--Af-E-----E-Aj--AaAdBAeC-I--C-AcAa-IAf--H------AeIAb-BFC-----Aj-Ad-B--AjAe-------HAcAa-", solution = "AjFAaGAbEAeCBAcAIDHAfAdAbAcDAfAHIAjAaAdFEGCBAeEHAeAGAaAdBDCAbAfIAjFAcAdCIBAfDAcFHAeGAjAAbEAaAcEGHCABDAfIAaAeAdFAbAjFAaCAbEAfGIAjDAcAdBAeHAAAjAfAeFAdHAcEAbCBAaGIDIDBAdAaAjAbAeGAHFAcAfCEGAbHEAdCDAfIAjBAAeAaAcFAaBAAcIGFAbAeEDHCAdAjAfAfAeAjCHBAaEFGAdAcAbDAIDAdFIAcAeAjACAaAfAbEBGHHGEFAjAcAAaAdBAeCAfIDAbCAAcAaDIAfAdAbHAjGFEAeBAeIAbDBFCHAcAfEAaAjAAdGBAfAdAjAeAbEGAFIDHAcAaC", difficulty = Difficulty.VERY_EASY, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 148 SudokuBlueprint( puzzle = "I-Af---CAjAb-HB----Ab-----AG--CD-------CAc---G----Aj-B-EAj-Ae------Aa-DCG--IFAj-AbAa--AeG---H-C-AbBIE--Aa--A---Aj-HDAfAF--C-----AaBAd-Af----AAjDAc--------FGAeAf----E-IAcAf-----Aa--DAjFGAd-Ab---A--Aj--HGAbD-Ae-Aa---AdD--EI-AAfC--AdAaD-G------Af-HAc-Ac-F----C---AjI-------HAe--AdG-----D----IAd-FDAc---Ab-C", solution = "IGAfAaDECAjAbFHBAdAcAAeAbAcBAdAaFAGAjAeCDHIEAfAeDACAcAbIHGAfEAdAaAjFBFEAjHAeAfAdBAcAIAaAbDCGEAIFAjAcAbAaBAdAeGCAfDHGCAcAbBIEDFAaAfHAAeAjAdAjAeHDAfAFAdICAbEAcBGAaBAdAaAfCHGAeAAjDAcFEAbIDHAbAjFGAeAfAaBAdCEAIAcAfBEAcACAaIAeDAjFGAdHAbCIAdAEBAjAcAfHGAbDAaAeFAaFAeGAdDHAbEIAcAAfCBAjAdAaDIGAjBACAbFAfAeHAcEAcAfFAeAbAaDCHEBAjIGAdAAAbCBHAeAcEAdGAaIAjFAfDHAjGEIAdAfFDAcAAeBAbAaC", difficulty = Difficulty.EASY, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 150 SudokuBlueprint( puzzle = "-AdAe------GD-B--AjF-------Ac----G---B---D-G--AAd-E---AbG-----AjAaEI-AfFAcH---Af-B-A-Ad----I-----AjDABH-Ab--G--AeAjAb--F---IEAf-AdB--D-G-E-CAj----AHED----HB-C-Af-Ab--AcAj-AeDC---A--IBAa--H--Aa-AfAcIAeAb-----Af----I-Aj-Ad-B---FDEAd-AcBAaC-----HAj---C-AdH--Ab-Aa---Af---A----D-------AdG--H-AAb------FAc-", solution = "IAdAeAaFAfAcEHGDCBAAbAjFAHEAjAaAdAbAcAfBAeDGICAjBAfAcIDCGFAbAAdAaEHAeCAbGDBAeAHAjAaEIAdAfFAcHGECAfAbBAeAFAdAaAcAjDIAdAfAcICAjDABHAeAbFAaGEAAeAjAbHAcFAaGDIEAfCAdBAaFDBGAdEICAjAfAcAbAeAHEDIAdAFHBAaCAcAfAjAbAeGAcAjAbAeDCGAdEAHFIBAaAfBHFGAaEAfAcIAeAbAjAAdCDAfCAaAAbIAeAjDAdGBHAcEFDEAdAfAcBAaCAeIFAGHAjAbAeAcCAjAdHIFAbBAaGEDAfAAbAaAFEGAjDAfAcCHAeIBAdGIBHAeAAbAfAdEAjDCFAcAa", difficulty = Difficulty.EASY, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 150 SudokuBlueprint( puzzle = "---E---HD-A--I-----HE---Ab-------CAd---Aa-Ac---I-AG--IB--Ae-Ad-AcHG-E--Ae-DAb--A----F-G-IAf-AdCBFHAb--I-Ac-E--F--Ad-Ac--C----AjAb-AjAa--G-CAc-Ad-B------F-A-AaC-Ac--AbAe-AbH----Aj--F-D--Af--E-A-Ac--AaGAbAeAjC-BD-I-Ab----E--AaH-G--F-AfAbAe-Aj-C--AaH--DC-I---G-Ae---AcF-------B---AbG-----Ac--C-AH---E---", solution = "AcAeGEAjAfAbHDAdABFIAaCFAfAHEIGDAbAjAaCAeAdBAcCAdAbDFAaBAcEAeAfIHAGAjAaIBAjAAeCAdFAcHGDEAbAfAeAcDAbAaAjAAfBHEFCGAdIAfGAdCBFHAbADIAjAcAeEAaAFHBAdEAcIAeCGAaAfDAjAbEAjAaIAeGDCAcAbAdAfBFAHGBAjFDAEAaCAfAcHIAbAeAdAbHAeAaCAdAjGIFBDAAcAfEAdEAfAHAcIFAaGAbAeAjCDBDCIAcAbBAfAeAdEAjAAaHFGIAFGAfAbAeEAjBCAcAdAaHDBDCAdIHAaAjGAAeEAbAfAcFHAaEAeAcDAdBAfIFAbGAjCAAjAbAcAfGCFAHAaDAdEBIAe", difficulty = Difficulty.EASY, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 150 SudokuBlueprint( puzzle = "---BAAbEAd--Aa-----F-AaAcAe---Ad----ECAfAf--G---AaF-HB-Ad-AAb---------G-Ac-B-A-I--------F--H-AcF--HI--CDAbAj----H--Ad---G-BI-A--AeG-AjC--AcDA-Ad--Ab----D--Af-AcEAb--AeG-HC--I-DAd-Aj---E--Ab----AbGAeC--FAd--AjB-Af--E--------F-Ac-E-D-Ae---------AdB-Ab-AdAc-FG---I--AjICF----Ab---AaAfAc-E-----A--IFAeCG---", solution = "DICBAAbEAdAfAjAaAcHAeGFFHAaAcAeBGIAdADAbAjECAfAfAeEGAcAjDAaFCHBAbAdIAAbAdAAjCFHAfAeEGIAcAaBDADIEAaAdAbAeAcGAfFBAjHCAcFAeAaHIBACDAbAjAdAfEGHAbAfAdAjCFGAaBIEADAcAeGBAjCAfEAcDAAeAdHAaAbFIAdAjDFBAfIAcEAbCAAeGAaHCGBIFDAdHAjAaAcAeEAAfAbEAaAcAAbGAeCHAfFAdDIAjBAeAfHAbEAaAAjDIBGCFAdAcAaEGDIAeCBAbAcAjAfFHAAdBAAbAfAdAcAaFGHEDICAeAjICFAeGHAjAbBAdAAaAfAcDEAjAcAdHDAAfEIFAeCGBAbAa", difficulty = Difficulty.HARD, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 152 SudokuBlueprint( puzzle = "Aa----BH-Ad--AG-------C---Af-F-A-Ac-BAb---Aa-AcG---F--AjAfAc----FAe-E-C---AaCAAj-----B--EAe-------Ac--GAa--AjEAfI-AbF-----Af---Ae-AdAH-Af-----H-D-GAc-FAbDAe-CG-Ab-Aj-----H-FIAb-H---Ac-----BG-HAcEAd--BAb--Af-------BAe--I-----EAdAcAe---I-Ac-EA----DAdAc--Af---FC-B---EI-B-Ad-H-C---F-------AbB--Aj-AdI----A", solution = "AaEFAjAfBHDAdAbAcAGICAeAdDIAeCAjGAbAfAaFBAHAcEBAbCAEAaAdAcGIAeHFDAfAjAfAcGHAIFAeDEAjCAdBAbAaCAAjAcFAbIAdBAfHEAeGAaDHAdAeDAcACGAaFAbAjEAfIBAbFBGAaDEAfIAcCAeAjAdAHEAfAaIAjAeBHADAdGAcCFAbDAeAdCGAcAbEAjBAaIAfAHFFIAbAaHAfAjAAcCEAdDAeBGAHAcEAdFDBAbAeGAfIAaAjCAjGAfBAeCAaIFHADAbEAdAcAeCHFIGAcAaEAAfAbBAjDAdAcAjAAfDAdAeFCGBAaHAbEIIBEAdAbHACAeAjDFAaAcGAfGAaDAbBEAfAjHAdIAcCFAeA", difficulty = Difficulty.MEDIUM, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 152 SudokuBlueprint( puzzle = "Ad----AjAbH----------FB-AG--I--AdHAa--H-A-AdF--Ae-C--B---Af-----AjAbAd-C--A-Ab----E-C-Ae--GF-CAc-Ae--H-Ad--EBAAj-AfEG-Ad--------I-HA----DCIG--Ac--------H--CEAjD----AeD-Ac--------G-AjHB-AjCAbD--G-F--Af-AdAa-AfH--F-Aj-Ad----G-Ab--Af-IAeF-----Aa---B--Ab-Aa--AcH-Aj-A--IAdAj--A--GAa-AeAc----------DEAb----C", solution = "AdDIAaCAjAbHABGFEAfAeAcAjCFBAfAGAeAcIEDAdHAaAbEHAbAIAdFAcAaAeAfCGDBAjAcAeAfGEBDAaAjAbAdHCFIAIAbBHAjAfEACDAeAaAcGFAdCAcAaAeFGHAbAdAfIEBAAjDAfEGDAdAeAcBAbAFAjAaICHAAdAjFAaDCIGHBAcAbAeEAfBGAAdHAaAfCEAjDIFAbAcAeDFAcIAeAbAdEAfAaCGAAjHBAeAjCAbDAcIGHFABAfEAdAaAaAfHEAFBAjAeAdAcAbDCGIAbAEAfAcIAeFBCAjAdHAaDGGBDCAbEAaAfIAcHAeAjAdAFHIAdAjBCADFGAaAfAeAcAbEFAaAeAcGHAjAdDEAbAIBAfC", difficulty = Difficulty.HARD, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 154 SudokuBlueprint( puzzle = "---I-Ab-D-----H-CAb--H-AjC--AaI--E-Af--ECB-AAf---FAd-AjAaAf-Aj-Ae------Ad----I-Ac--AeAaFHE-Aj----F--DE-----Ad-Aj--AcAEAa---AjAc---Ab--------C-----AcAa-AdA--FA-AdH-----Af--------I---AaAc---AbCFH--G-Ac-----AE--D----D-GAAbIF--Aa-B----Ab------B-C-AdAaI-AfAc---GH-EAeAj--Ae-Ad--FB--AfAa-D--HE-C-----Ac-Ab-Aa---", solution = "AdAFIAaAbAcDAfAjEGBHAeCAbBAeHGAjCAdAAaIAcFEDAfAcDECBIAAfAeAbHFAdGAjAaAfGAjAaAeEFHDBCAdAcIAbAICAcAdAAeAaFHEAfAjAbDBGFAeAbDEGHIBAAdCAjAfAaAcAEAaBAfAdAjAcIGDAbCFHAeGAfHAjCBDAbFAeAcAaIAdAECFAAbAdHAeAaEDBAfGAcIAjBAdDAeIAfEAjAaAcGHAAbCFHAaIGFAcAbBAdCAjAEAeAfDAjAcAfEDCGAAbIFAeHAaAdBDHGAAbAaIEAjFAeBAfCAcAdAaIBAfAcDAdCGHAEAeAjFAbAeAbAdAcAjFBGCAfAaIDAEHEAjCFHAAfAeAcAdAbDAaBGI", difficulty = Difficulty.HARD, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 156 SudokuBlueprint( puzzle = "Ae-----Ab-FAf--AAcAjE--GAb------AcAeI-D-F---AfAa-G---A--BAdAc--H-Ae-FAj---Ab--Aa-----A-D---Aj----H-AeDAbAd-I-GB----Af--------C---AcAa-II-C-GAc-------DE--AdE-------AfAa-Ae-AcD-FI---C--------Af----EH-D-FAcAdC-Aj----Aj---G-I-----Ad--F---BH-A-Af--CAaG--I---Ae-CF---B-D-CAeG------EAj--AbAcAAe--AfE-Ad-----G", solution = "AeIAdAaDBAbHFAfGCAAcAjEABGAbAdCEAjAaHAcAeIAfDFFCAjEAfAaAcGIAbDAAeHBAdAcAfDHAAeIFAjBEAdAbGCAaEFAcAfHACDAdIAaAjGBAbAeHAjAeDAbAdAaIAcGBECFAAfGAbBAEAjFAeCDHAfAcAaAdIIAaCAdGAcBAfAFAeAbAjDEHAjAdEBFIDAAbCAfAaHAeGAcDAeFIAcAfGCEAjAdHBAAaAbAfAAbGBEHAaDAeFAcAdCIAjCHAaAcAjAbAeAdGAIBFEAfDAdEIFAaDAjBHAcAGAfAbAeCAaGAfAjIHAAbAeECFDAdAcBBDHCAeGAdAcAfAaAbIEAjFAAbAcAAeCFAfEBAdAjDAaIHG", difficulty = Difficulty.EASY, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), // Remaining Digits 156 SudokuBlueprint( puzzle = "Aj----F-G-Af--I--C-Af--CD----AaAeF-HAj---BAfIAa-H---Ab-D-E--Ab-----BD--Ad-------Af-I-AeBG--C--C--E--Ae------Ac--BH-A---AaAcAj---AeF--F--AdAc--E---I-AaG-A---Ae--DC--B--AdAj---HBAa---E-AcI--Ae------Af--B--Aa--I--GAcAf-F-Ae-------Ae--AI-----B--Ac-E-C---Ab-AAdFAa---AcA-HAaAe----AbAf--Aj-Ab--Aj--F-Ae-Ac----I", solution = "AjHDAeAdFEGAcAfAAbIAaBCAAfIAcCDAbBGAdAaAeFEHAjCGAdBAfIAaAcHFEAjAbADAeEFAaAbAeAjHACBDIAcAdAfGAaAcEAFAfAjIAbAeBGAdHCDDCAjAdEAaGAeIHFAAfAbAcBAfBHIAAbCDAaAcAjAdEGAeFAeAbFGBAdAcHDEAfCAjIAAaGAaAAfIEAeAjAdDCAcHBFAbAdAjCFDHBAaAAbGEAeAcIAfHAeAcEAbCAFAfAjIBGDAaAdBIAbDGAcAfAdFAaAeHCAjEAFAdAeAaAjAIAfEGHDBCAbAcIEAfCAcBDAbAjAAdFAaAeGHAcAGHAaAeAdCBIAbAfDFAjEAbDBAjHGFEAeCAcAaAAfAdI", difficulty = Difficulty.MEDIUM, - gameType = GameType.SixteenDigits, + sudokuType = SudokuType.Sudoku16x16, ), ) diff --git a/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/TwentyFiveDigitsSeeds.kt b/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/TwentyFiveDigitsSeeds.kt index 1da8998..9152398 100644 --- a/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/TwentyFiveDigitsSeeds.kt +++ b/sudoklify-seeds/src/main/kotlin/dev/teogor/sudoklify/seeds/TwentyFiveDigitsSeeds.kt @@ -17,8 +17,8 @@ package dev.teogor.sudoklify.seeds import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType import dev.teogor.sudoklify.common.model.SudokuBlueprint +import dev.teogor.sudoklify.common.types.SudokuType /** * An array of `SudokuBlueprint` objects representing easy 16x16 Sudoku puzzles. @@ -29,62 +29,62 @@ val twentyFiveDigitsSeeds: Array = arrayOf( puzzle = "-----Ah---HAdAc--Ai-BeBb-Af-BaBj------AcC---BAgBj-BbA--HDBa-BcAfBeE-AhAiFAj-Ab-GD--Ba--AeC-AdAaBb-Ag-Ac-Be--H--BaA-BcD---IBG-Ac--Ad-AaG---Af-AgAdAiBb-AaAe-CBc-Ab--D----Af--AgG--H-E-BbB-BdAcAb----C-Ae-D---B-Ae-Ad--AbBc---Bd-Bb-AfAaHAj--A--Bd--Ai-BaAaFAc-----EDBj--B--AcFAdAbIBb-AfBc-Aj-Ag-AaA-CBe-D-BaAiAa-BeAjAe-C--FE------Ah-Ai--Ab--Ai---AaFBa-IAhDBc-B---A-E--Aj-AeF---BbB---AaAbI---Bj-----A--------AjEBdAgAiAf-A-BjBFBcHBb--------Af-----Ac---EBbAb---AeAa---BBe-Bc--Ab-Ae---G-AiAcBdAj-ICBa---Af--B--Ai-Ag------EAd--Ba-AeAbAa-BdAAe-Be-GAc-BjAj-Bd-Ab-AiAh-BcHAdBbBaE--Bb--BcAaH-----AiBaAfE-F--A--C--DCAhF-Be-Ba---AdH--Ag-Aa-I---Bj-Aa-E----BdAfA-CBj-Aj-D--BcB--Be----Ad--F-GH-ID-BeAfBdAh-C---AAb-Ah--Ad-EHI---BeB-AaAg--Bd--G-Bb-Bd-EBaB-AaAe--Ah--GBj-A-AiFBeAd-BjAiIA-AfBdBe--GE-AjAeC---FAg------AaG-Bc-AhC-Bd--AcFH---Aj-----", solution = "BcBDAeIAhFAaEHAdAcAjBdAiABeBbAgAfGBaBjAbCAdBdAbAaAcCIAjAeBAgBjGBbAAhAiHDBaFBcAfBeEEAhAiFAjBeAbBcGDIBBaAfHAeCBjAdAaBbBdAgAAcCBeAgBbHBjAfBaABdBcDEAhAbIBGFAcAjAeAdAiAaGBaABjAfAcAgAdAiBbBeAaAeFCBcEAbAjBdDHBAhIAfBcBaAgGDAaHAhEAiBbBIBdAcAbAjBjAdBeCAAeFDEBjAiBAAeAcAdBeBaAbBcCGFBdIBbAgAfAaHAjAhAhABbCBdAgAjAiAbBaAaFAcAdBeAfHAeEDBjIBcBGHAcFAdAbIBbGAfBcAeAjBjAgAhAaABCBeEDBdBaAiAaIBeAjAeBdCBjBFEHAfADBaBcAhGAiAcAdAbAgBbAiBjHBdAaFBaCIAhDBcBeBAdAgGAAfEAbAcAjBbAeFGEDBbBAdAfBeAaAbIAgAeAjBjBaAiAcAhHACBdBcAcAbAeIBaAjEBdAgAiAfCAAaBjBFBcHBbAhBeGDAdAgCAjAfAhHGABcAcFBaBdEBbAbDAdBeAeAaAiIBjBBeAdBcBAAbDAeBbBjAhGHAiAcBdAjAaICBaAgEFAfAjHBAcBjAiBcAgFCBbAhDGEAdIBeBaAAeAbAaAfBdAAeAfBeAgGAcIBjAjBBdFAbAaAiAhCBcHAdBbBaEDIBbGAbBcAaHBDAdAcBeAiBaAfEAeFBdBjAAjAhCAgBdDCAhFEBeAbBaAAjAeAdHBcBbAgAfAaBIGAiAcBjBaAaAdEAiAeAhBbBdAfAAgCBjIAjAcDAbGBcBFHBeBAgAcBcAdBbBjFAjGHAiIDBaBeAfBdAhAbCEAeAaAAbFAhBaCAdAiEHIBjABbBeBDAaAgAeBcBdAfAcGAjBbAjBdHEBaBDAaAeCAfAhBcAgGBjAcAIAiFBeAdAbBjAiIADAfBdBeAcAbGEAaAjAeCAdBaBFAgAhBbBcHAeAfAaGBeBcAAhCAgBdAdAbAcFHBbEAiAjBBjDIBa", difficulty = Difficulty.VERY_EASY, - gameType = GameType.TwentyFiveDigits, + sudokuType = SudokuType.Sudoku25x25, ), // Remaining Digits 323 SudokuBlueprint( puzzle = "AjIEBG-Bd-BeAfAb--A-AdAi-BcH---C-----Be-----Ac-Aa-----AhBjAdBAf-H-C-BjFIA--GAf-Aj----BbBAcAbBc---Ae-Ab-BdAj-Bb-H-----Af---EAiGAAa-Af-Bc-AAiAcBa-CBb-H---------Bd---BjAfA-FD----BAcEAjBbHAeAiBa-Ab-Ad-H---C-BaAa-BI-Ab--EBe--Ag-BbAe--B-Aa----CIAgH-Bd-BcAcBj---Ba-D--IAbBeAdAhAf--Aj------C-------EAa-Ba--EAb--HAh-CAg--IAa--AjAfAi-Ac--AgBj-HDCAeA---BbBdAd-------AhAjIG----Ad-Bj-IBeAi--Ba-E--Ab--AaBcAfAh---B-----FAb-AcC-----A---AeAAeBb--Be--Af-B--AgAhD-Bj-I----AdCAfAi-------DIBc---AdAAeBeBj-BbAb--H-CAbBj--GD--AfBc-BaB--BdE--Ag-BeA-------Ad------Ag--AiAaBdIGAc--F-Bb---AiAcA-B-BdGCBc----Aj-Ab--AhBd-C--EAb--Ai-BjF-AcAa-Bc---Bb-Bc-Ag-BdIAfFAeGAjEAb----DBb-HBeA---Ag---------F-EAj-AbBdDG-Ai-Bc-DAjAhAiG---Bb-----A-H-CBe-Ad-Bd---BeAdBaAaBd----I-HAe--GBcAcAg-F-Aa-GAbAeAF-----Ad-Ag-----Aj-----E---AcAj-DAi-Bj--AfAaBa-Be-AhIAbBbA", solution = "AjIEBGAgBdDBeAfAbAeAhAFAdAiAaBcHBbBaAcCBjAgBbBaAiBeAeAbEBcFAcGAaCDBdAAjAhBjAdBAfIHAdCHBjFIAAhAaGAfBdAjBaAiBeAeBbBAcAbBcAgDEAeAhAbAcBdAjBjBbBHAgBcBeAdIAfDCBaEAiGAAaFAfAaBcDAAiAcBaAdCBbEHBjBAgAbFIGAeAjBdAhBeBcBjAfAAgFDGBdBeAaBAcEAjBbHAeAiBaIAbCAdAhHAiAcGCBcBaAaBjBIAhAbAfAEBeDAdAgFBbAeBdAjBFAaAeAjBbECIAgHAdBdAiBcAcBjAhAbAfBaADBeGIAbBeAdAhAfAiAcAjAAeBaDBbGCBcBdFBAgBjHEAaBdBaDBbEAbAeAdHAhBjCAgFBeIAaGAAjAfAiBcAcBAbAgBjBcHDCAeAAaEAfBbBdAdAiGBaAcFBBeAhAjIGAjBdFDAdAgBjAcIBeAiAAeBaAhEBBbAbHCAaBcAfAhBeAdIBEHAiBbAjFAbBjAcCBcBdAfAgAaADGBaAeAAeBbAaAcBeBcAbAfBaBHGAgAhDAjBjCIBdFEAiAdCAfAiEBaBGFAhBdDIBcAjAaHAdAAeBeBjAcBbAbAgAcHICAbBjBbAGDAdAaAfBcAeBaBBeAjBdEAhFAgAiBeAAeAjBjHBBcBaAdAhFCDBbAbAgEAfAiAaBdIGAcEAdFBaBbAaAhAgAiAcABeBIBdGCBcHAeDAfAjBjAbDGAhBdAfCBeAjEAbBaAgAiHBjFIAcAaABcAdBAeBbAiBcBAgAaBdIAfFAeGAjEAbAcBjAhAdDBbCHBeABaBaAcAgAfIAhAdBeAeBjCAFBEAjBbAbBdDGAaAiHBcBjDAjAhAiGAfIAgBbBcAcBaAaAbAFHECBeAeAdBBdBbBABeAdBaAaBdAbEAjDIAhHAeAfAiGBcAcAgBjFCAaBdGAbAeAFHCBcAiBbAdBeAgBAcIBjAhAjEBaAfDFECHBcAcAjBDAiBdBjAeGAfAaBaAgBeAdAhIAbBbA", difficulty = Difficulty.VERY_EASY, - gameType = GameType.TwentyFiveDigits, + sudokuType = SudokuType.Sudoku25x25, ), // Remaining Digits 325 SudokuBlueprint( puzzle = "-BcAc-IAf-EF-AhAeA-AaBj-------BaAj--Ab--Ai-Ah-Ae--I--Ag----------Ag-BbAeB-DH-GBc--EAi--AdBd-AhBeAAc-Ba-DGI-AAc--BdF-AgBb-AjE-AfAb-BAiAiBd---AgAb--BaDC-B-Bc---Ah-G-FAe-HCB---Ag-AfBdAa--------E--Ah-BcBj----A-Bb--EGAj---Ai-AdAcCAaBeAfAg----BeAd--E--Ba-FH-G--Ai-D-B---IAi--BaG-B---Ah-Aa-DBeAeA--BjBeAfAdAcD--FAb-Ai-AgBb-AhA-C---BcAj-----------AbAAd-BjBa-----Af--AaBjI-Be--Ah-BaAb---Ae------Aj-AcAdBdAb-Aj-Ba-Aa--CAgB-HBeAd--Af-G-Ae-BcCEAf-Ac------Bb---AB-Bj--D-AiFB--Ae-----BjBa-AiBdBc-----------FA---E-AdBb-GH-I-BaC--AhAiBBcDBa--GAfAeAc-Ai-Bb---C-AdBc--FE---Ad-E-B--I-AhBj-D--Bd--AjF----BeBbDAhHBdAj-G---AbAeBc--Ag-Ai----AaAd-Ae--Bc--------EAdAf-B---AjAbG-FAa-E-Ab---Ag-Ai-BeGC--BdAj---AfAAfAi-AhBe-BjC-AaE-AcAd--AbBb-AgHI-Ae-AeAbAgC-DG--IA--AfBa-AiAc-BcAdF-E----------Be--Bj--G-Ae-H--Ai--AAj-------AcAe-CFB-BjBa-AfBc-AhAg-", solution = "HBcAcAdIAfBeEFGAhAeAAiAaBjCDBAbBdAgBbBaAjAjBAbAfCAiBdAhBjAeAdBeIAcBbAgFABaGAaBcHDEAaAgFBbAeBCDHAjGBcAbBaEAiAfIAdBdBjAhBeAAcAhBaBeDGIBcAAcAdHBdFBjAgBbAeAjEAaAfAbCBAiAiBdBjAEAgAbBbAaBaDCAjBAfBcHBeAcAhIGAdFAeGHCBAjBjAiAgAeAfBdAaBeDAAcBbAbBcBaEAdFAhIBcBjBaFAbAhABBbDIEGAjHAeBdAiAgAdAcCAaBeAfAgAAeAaAhBeAdBcCEAcAfBaAbFHAjGIBjAiBdDBbBEBbBdIAiAcAjBaGHBAdBcCAhFAaAfDBeAeAAgAbBjBeAfAdAcDAaIFAbBdAiBjAgBbAeAhAECBBaHBcAjGBdGDBcFBbBAjAgAiAbAAdIBjBaAcAhAeCBeAfEHAaBjIBbBeAEAhHBaAbCFAfAeDAaBcAgGAiAjBAcAdBdAbAhAjAiBaFAaAcACAgBEHBeAdDBdAfBbGBjAeIBcCEAfAgAcAdAeBeBdBcAaBbAhGAjABHBjIAbDBaAiFBAdHAeAaGDAfIBjBaAcAiBdBcAjBeFAbEAgBbACAhAcFAAjAgBdEBjAdBbAfGHAaIAbBaCBeAeAhAiBBcDBaBeAaGAfAeAcAbAiABbAjBAhCIAdBcHDFEBdBjAgAdCEAbBBaHIBcAhBjAgDAAiBdGAaAjFBbAeAfAcBeBbDAhHBdAjAfGBeBFAbAeBcAcEAgBjAiACBaIAaAdIAeAiBjBcCAgAaDFBeBaBdEAdAfAhBBbAcAAjAbGHFAaBEHAbBaAeAhAgBcAiBbBeGCIAdBdAjDAcBjAfAAfAiBcAhBeABjCAjAaEDAcAdBdBAbBbFAgHIGAeBaAeAbAgCBjDGBdBIAHAaAfBaBeAiAcAhBcAdFAjEBbDAcIBaBbBcFAdAfBeAjAhBjAgAbGEAeAHBAaAiBdCAAjGBdAdHBbAiEAcAeICFBDBjBaAaAfBcBeAhAgAb", difficulty = Difficulty.EASY, - gameType = GameType.TwentyFiveDigits, + sudokuType = SudokuType.Sudoku25x25, ), // Remaining Digits 333 SudokuBlueprint( puzzle = "AaF-------------DAhBjAe-AgBa--B-H-AGAh-Aa----BE----AgAd-Bc--AbAgB-I--E-AbCAe-Ah--H-Be-ABjGAaAd-BaAe--AjBb-FH--AgAd-AfAb-E-Aa--A----DAdBd--Ag-BjAb--Ac--BaAiAjC------Ai----BjB-F---BaAg--A--Ae-Ah-HAj-F--Bc-Bd---ABbG--Af---Ba-Ab--A--EAcAjH--AdBcAaAiBj--Bb-BaAeBAgFG--AgAhBd--Ac-BbGCE---Ad-F-BcAj-AiAAaG-B-BjAa---I-HBeAj-Bd------Ad----G--Bj--AcAhB-Ba-CAjAg-Be-Bb-BdAe-Be----ABcCAi-Aa-------F--Ah---BbBa-Ah-----Ag-----A-----Aa-HAi---Ai--Ae-------Bc-AcBdAhBa----C-BcAe-C-Bd-BaDA-Bj-GAfH--Ai--E----Bb------A-CAfAa-I---AbAi-G-AjAfAbAj-FB-Bj-Bd---AgBeAiAe-D--CAcAh--BdBaAgIGAi-Aa--AbFAhAcBc--AAjAdAe--Bb--Ai-Aa---Aj--AeAAd---Ac-Ag--I-EE-A-D--H--BbAj---G-AdBd----Ag------HGDBj--Ac--AbBa-I--EAjAf----E--I-Bc-BAh-AjAf--GH-FA--BaAc-BjAaFBaAc-Aj-E--I-HBbD-B--Be-CAdAb--H-AgBe----BaAa----Af-EBdI-Bb-I--AfBb-BaAdBdAi-------------FAe", solution = "AaFBcAbEAiIGAdAcHBeBdCADAhBjAeAfAgBaBbAjBAcHBeAGAhDAaAeAjIBjBEBaFBdBbAgAdAfBcCAiAbAgBAfIAiBdEBaAbCAeFAhBbAjHBcBeAcABjGAaAdDBaAeCBjAjBbBFHBcAiAgAdDAfAbIEGAaAhBdAAcBeAhBbDAdBdAfAAgBeBjAbBcGAcAaBBaAiAjCIHAeEFBcAiAbBbAdCBjBEFAfBdDBaAgAaAjAIGAeAcAhBeHAjAaFCAeBcAgBdDBeAcABbGAdAhAfBAiHBaEAbIBjABeIEAcAjHAbAfAdBcAaAiBjAhCBbDBaAeBAgFGBdDAgAhBdHBaAcAeBbGCEAbIBAdBeFBjBcAjAfAiAAaGAfBBaBjAaAhAiAIFHBeAjAeBdAbAgEAcCBbAdDBcFEGAaABjAbAfAcAhBAiBaHCAjAgBcBeDBbAdBdAeIBeAcBjDAgABcCAiHAaBbEBdIAeAdAbFBGAhAjAfBaBbBaBdAhAbBeAjEBAgAdAfAcAeFABjGCIBcAaDHAiBIHAiAfAdAeBbGAaAjDAgAbBcEAcBdAhBaFABeBjCAdBcAeAjCFBdIBaDAAhBjBeGAfHAaBbAiAcBEAbAgAeAdBbBeBcEFAcAgABaCAfAaBjIBAhHAbAiDGBdAjAfAbAjGFBAdBjBcBdEIHAgBeAiAeBaDBbAaCAcAhAHBdBaAgIGAiBeAaAfDAbFAhAcBcECAAjAdAeBjBBbBjCAiBAaDBbAhAjBaGAeAAdBdBeFAcAfAgHAbIBcEEAhAAcDAeCHIAbBbAjBcBAiGAaAdBdBjBeFBaAgAfCAAgBcBHGDBjBbBdAcAeFAbBaAiIAdBeEAjAfAaAhBdDEAeBeIAaBcCBAhAdAjAfBbBjGHAbFAAiAgBaAcAiBjAaFBaAcAfAjAhEAgGIAHBbDAeBBdAbBeBcCAdAbAjAdHAhAgBeAFAeBjBaAaAiDAcCAfBcEBdIBBbGIGAcAfBbAbBaAdBdAiBeBCBcEAgAAjAaAhDBjHFAe", difficulty = Difficulty.EASY, - gameType = GameType.TwentyFiveDigits, + sudokuType = SudokuType.Sudoku25x25, ), // Remaining Digits 337 SudokuBlueprint( puzzle = "--BjBd-Ah----Ba-Aj-----DCAdGAb-BcAhAcBcFAaAe--Bd-D----Bj---Be-AfCH-Aj-Be-AdAa-BA-GI-Bc---Bb------Bd-AIAe--Aj----E-C--Ad-F-Ah--BbBa---GD-AdBj-FBbABd--BcIAh-Ba--Aj-BEBAh-----C-BeBdAe---AbF-Bb--Bc--Ai--Ab-IAh------AfAjEBcAeC-Bd-Ac--IFBbAd-BcAiAeBaHAgAb-----------AjBe-Bj-----AgF-Bc--Ba--Bd----D-GBb-----BbBd-Be-E---AdAaG--BjBa---AgBe-FB-Ad---DAbAi-Bb---Bd---E------AjBj-AaBc-AiBdAc--AhD--Ad---AeCA----AAfAeGI--Bc-Aj--BAiAbFBe----AdBbH---Ab--BdC--AgAeAf-BcE-BAa------Ag---Ah---Af-BAaH---Ae-FBa-AdG---BAi--BcAaI---C-F-BjAb-----FAd-Bj----G--Bb--Ac-EI-----Ah-BdH-----------AdBcAiAAcAgD-BIBaAf--E-Ag-IBdAbAcAiG------BbAh-Be--F--Ai--E-FAg---AbAaB-Aj-----BdAcCAe-A--Ab-CAjBj--AfIAiBd-EB-BbBa---BaG--E-Bc-Ai--Bj-Be----A--AbBAd-Aa------I---B-AbBb-BaBj-AiAg-G-Ae-CBAi-Be---Bb----E-H--AaAjBdAfDBjBj-AdBbAbBdAg-----Ac-G----Af-IAa--", solution = "BAgBjBdBbAhBeAiAfIBaAaAjHFAcAeADCAdGAbEBcAhAcBcFAaAeBbEBdBaDAdBAiAbBjAgGAjBeAAfCHIAjBaBeAfAdAaAcBACGIAhBcAgAbAiBbHEAeBjDFBdHAIAeAiGAjAbDBcAcEBjCAfBAdAaFBdAhAgBeBbBaAbECGDAgAdBjHFBbABdAeBeBcIAhAfBaAiAcAjAaBEBAhHGABjAdCAjBeBdAeAcDAgAbFBaBbAfAiBcIAaAiBeAgAbBaIAhDAaGBFBbAfAjEBcAeCABdAdAcBjHIFBbAdBdBcAiAeBaHAgAbAaGBjAhAfDAcBCAEAjBeAcBjAaCAeBAfAgFEBcHAiBaAAjBdAdBeIAbDAhGBbAAjDBcAfBbBdAcBeAbECIAhAdAaGHAiBjBaAeFBAgBeAeFBAhAdHAjBjDAbAiBaBbIACBdAaAcBcEAgAfGAfAbGAjBjBaAaBcBAiBdAcFEAhDBbBeAdAgIHAeCACAaAcEAAfAeGIAgBjBcAdAjHBaBAiAbFBeAhBbBdDAdBbHBaIFAbAAcBdCDBeAgAeAfAhBcEGBAaBjAiAjDAiBdAgBcCEAhBbBeAAfGBAaHBjAjIAeAcFBaAbAdGAhAeAcBAiBaBeBcAaIAjHBdCAdFAfBjAbDBbAAgEFAdBaBjCHBAfGAAeBbAgDAcBeEIBdBcAaAjAiAhAbBdHAbAaAjBjCBbAeAhFBeEAdBcAiAAcAgDGBIBaAfBcAfEDAgAjIBdAbAcAiGABjBaCAaBBbAhHBeAdAeFBbIAiABeEDFAgAdAfAhAbAaBGAjBaAeHBjBcBdAcCAeBcAAhFAbGCAjBjAaAgAfIAiBdDEBAdBbBaHBeAcBaGAfIEDBcAaAiAeHBjCBeBdBbAcAgAAjFAbBAdAhAaBdAjBeHAcAIEAfAdBDAbBbFBaBjAhAiAgCGBcAeAgCBAiAcBeFBaAdBbAhAeBcAEIHAbGAaAjBdAfDBjBjDAdBbAbBdAgHAhBAjBaAcFGAeBeCBcAfEIAaAAi", difficulty = Difficulty.VERY_EASY, - gameType = GameType.TwentyFiveDigits, + sudokuType = SudokuType.Sudoku25x25, ), // Remaining Digits 338 SudokuBlueprint( puzzle = "AfBbIAg----GHAbAAc--Ad--Ae-Ba--BeBc---D-Ab---BAe------AiAj--HF-----Be-IBjBcAi----AdBd-Af-Ag--AjAbC------F-AdAa--B---Bc-Bj--BbE----BBjBdE-AeAfAcAjIAg-Ai-AbH---Ah-A--Ae----Ah-I-AAfAb-Ac--------BcE-AbAcBd---AjAiAgG-H-BaAdD--Ah-I-BeFBj------BcAaF-B-AhICHAgAj-Ab-AiBd----AaAi--C-Ad-E-BeA-B-Af--AeAg------Bj-E-D-BbFBc------AcC-BaAh-AfBd-Ai--BAa-DAb-IA--Aj----Bc--Bb-BaAd--------CAi------Bb-BdA--AbBcAh----FAeEBj-AfAdBd-AgICG----AjDH--AaC-Ai------AhF--------IAd-Aj--I----Ba--BjBc-AcD-AfBd--C-AaAi-GAh-BbH------DBaI-F-B-Be------HBd--Ag-I-AhF-B-C-E--AbBb----BAj-Ba-BjBcAiHAcI-A-GAgAb------AaFD-Ab-Bd--AhAiAd-Bb-BeAjAeH---IBaA-BjAg--------E-AfGBb-D-Bc----B--Af-Ae---AjBc-Ba-AgAaCAiIF-AbDAdBj----ABe--H-Ag---F--AbAd-Bb------AbCAc--E-Ba-BjAe----BBcBdAj-Aa-----FBa--GAh------AfAe---E-I---BAa--G-Be--F--EAjBbAhBj----AfAeABa", solution = "AfBbIAgAaCAhBdGHAbAAcEAjAdFBAeDBaBjAiBeBcCBcAhDAdAbAgABbBAeAaBaBjBeEBdAiAjGAfHFAcIGABaBeAcIBjBcAiEDFHAdBdAaAfBbAgAhBAjAbCAeAjAiAbAeHFBaAdAaBeGBAfCAhBcABjIAcBbEAgDBdFBBjBdEDAeAfAcAjIAgBbAiBcAbHBeCBaAhAdAAaGAeDHCAgAhBIBjAAfAbBdAcAiFBaGBeAdAaBbBcEAjAbAcBdBcBAfAjAiAgGBbHAaBaAdDAeEAhAICBeFBjABaEBbAfBeBcAaFAeBDAhICHAgAjBjAbGAiBdAdAcAhGAaAiFAcCBaAdBdEAjBeABjBBbAfBcIAeAgDAbHIBeAdBjAjEAbDHBbFBcAgGAeAiAaBdAcCABaAhBAfBdAfAiGBjBAaCDAbBeIAAeHAjEBaAdFBcAhAcBbAgBaAdBeFDAgIGAhAcCAiAjBEBjBcAaBbHBdAAfAeAbBcAhBbAbAHFAeEBjAaAfAdBdAcAgICGAiBeBBaAjDHAgAcAaCBcAiAjBdAfBaBbDAhFABeAbBAeEGBjIAdEAjAeBIAdBbBeABaAgGBjBcAbAcDAhAfBdHFCAiAaAiEGAhBcBbHAcAbAaBdBjAeDBaIAdFABAgBeAjAfCAdAeAHBdAjDAgAfIBcAhFBeBBaCAcEAaBjAbBbGAiBeCBAjBbBaAdBjBcAiHAcIAaABdGAgAbAfDAeEAhFAaFDAfAbGBdEBAhAiAdCBbAgBeAjAeHBjAcBcIBaAAcBjAgIBaAeAFBeCAjEAbAfGBbAhDAiBcAdBdAaHBBbHAfEAeBdAcBAjBcABaGAgAaCAiIFBeAbDAdBjAhBjIAjABeAaAfHAeAgAhCBcFDGAbAdBaBbAiAcBBdEDAbCAcAhAEBbBaAdBjAeAiHIAfBBcBdAjFAaGAgBeAgBdFBaAiBjGAhCDAdBeBAbAfAeAcAAaEAjIHBcBbBAaBcAdGAiBeAbIFAcBdEAjBbAhBjHDAgCAfAeABa", difficulty = Difficulty.VERY_HARD, - gameType = GameType.TwentyFiveDigits, + sudokuType = SudokuType.Sudoku25x25, ), // Remaining Digits 339 SudokuBlueprint( puzzle = "HFG----Ah----AcBj--C-AAb--AeAa-----Aa-BeE---F-Ba-IBcBAh--Bb---E---AhGBb---D-------F----Ai----AbAd--BcFAc-EAh-Aj-BeDAgAf---GB--Ae-BdDAa--CBcBb----Ba--Ad-----Ag--AdBaBeFD---BcA-BbHBG---IAi----EBd-B---Bc--AiC-D---I---BeAc--Af-GAg--AiABj-BaHBd------FEBb------E-AbBbG-Aa-Ad---A-Ba-Bj-Aj---Aa-FBj--Ba-AgB-BeG-EBbAc-AfAh--Bc--AbAfI-GBaAeDBe-B---AcAiE---AjAgAaD-Bd--C-Bb-Be-Ba-------AhAe-G-E-EAhAiBAj--I-Ae---C-Ag--DBjAbBcAc-Aj-Ag-CAb-------G-Bc-Ba-Aa--Be-HBjGBa---EAgAh---Aa-AbAjABdBe-BbAdC--Af--BAj-AgBeBc-BaBj-AbA-D--BbAc-Aa---Bd-E-H-Aj---Ad-Ah-AgIAb-Ai------AgCBa------BdAiD-AfAcAe--BeI-Bj--AdAh---Bd---Aa-CBe--Ba---Bc-AiA----AcBj---CEAiAj-IF---AdGBBdD--Ah-----Ac--D----IAaAd--BaABe-F--AcBc---AdBaBdC-A-AbAi-FAhAj--AgAe----A----Ab-------Ba---AfAcAi---C---C--BjGAE-Ae-Ac---HB-D-----BjBb--AeAj-H--AgBc----Aa----AcAAd", solution = "HFGBbDBaAdAhAfAjAiBeAcBjBBdCEAAbBcAgAeAaICAfAAcAaAiBeEAgAeAbFBdBaHIBcBAhGAdBbDBjAjEBeBcAgAhGBbBjBBdDICAfAdAaHAeFAjBaAcAbAiAAiBaBjAbAdAIBcFAcAaEAhAeAjBbBeDAgAfHCBdGBBIAeAjBdDAaHAbCBcBbGAAgBjBaAcAiAdEBeAfAhFAgAcAjAdBaBeFDAaAfAhBcAEBbHBGAbBjCIAiBdAeBbHEBdBjBAhAdAjBcAfAbAiCAeDFAgAaIGABaBeAcAbBAfBcGAgCIAiABjAcBaHBdAhAjBeAdAeAaFEBbDAhCAiBeAeEAcAbBbGIAaFAdDAfBdABcBaBBjHAjAgADAaIFBjBdAeBaHAgBAjBeGAiEBbAcCAfAhAdAbBcFAdAbAfIBcGBaAeDBeAhBBbBjCAcAiEHABdAjAgAaDAaBdHBcCABbAdBeAcBaAgAjAiBAbIBjAhAeAfGFEBeEAhAiBAjHAaIFAeAAdBdCGAgAfBbDBjAbBcAcBaAjBbAgACAbAiAcBdBjFAfEGIBcAdBaAeAaAhBBeDHBjGBaAeAcAfEAgAhBHDAaBcAbAjABdBeFBbAdCIAiAfAiFBAjIAgBeBcAdBaBjAeAbAEDAhBdBbAcHAaCGAaBdDEAHAeAjBjBaGAdBbAhAcAgIAbCAiFBcBAfBeBcAgCBaHAhBAGAbBdAiDAaAfAcAeFAjBeIEBjAdBbAdAhIGBbBdDFAcAaBCBeAgEBaAfBjHBcAjAiAAeAbAeAbAcBjBeBbAfCEAiAjHIFBcAAaAdGBBdDAgBaAhBdAeBAhAbAcBcAiDAgBbAjHIAaAdBjCBaABeGFEAfAcBcHAaAfAdBaBdCIAGAbAiBeFAhAjDEAgAeBbBBjIAAdFAgAaAbBBeBbEBdBjDBaAeGBcAfAcAiAjAhHCBaAjBeCAiFBjGAEAdAeAfAcAhAbBbHBAgDAaIBcBdGBjBbDEAeAjAfHAhCAgBcBFBeAiAaIBdAbBaAcAAd", difficulty = Difficulty.HARD, - gameType = GameType.TwentyFiveDigits, + sudokuType = SudokuType.Sudoku25x25, ), // Remaining Digits 340 SudokuBlueprint( puzzle = "AjAgGHBbAd-Bj---IAAi--Be---AcAeD---Bd--Ah-Aj-----AaAfEAe--FD--Bb-AdAi--AeAf-GDBe-Ad-Ag-CBd--Ah----E-IBj---Ah-A------Aj--Bb---Ba---Aa-C--EAe--FAh----HBa--AgAbAfI-AiAcCAa--G---E---Aj--Bb-Ab-FAh---------I---EBaAd-GBeAeAi----AfAbAj-AeAd--Ab--F--B-AcAiAf-D---I---Ah---Ag----Ai----I-Ad-AjBj-BbBe-D-AiAbBaA--C-AeBbAgBdAa-FG----Ac--BABeAg-G--I-----HAhC-BD-E-BcAe-Ad--Bc--AhBa-Af-FE-Ac----Be--Ab-AaFAa-Af--AbAi-G--D--I-AhAd--H-BaAgAe-Bj--Ac----Aj-AiBe-Bb-FBc--D--C-EAh-C-DAj-BcIG-----Ab--Bb-BjAcAfAf--D----AeAb-ABeBaBbBc-Ag--GBFAi-Bj-EBd-AgBc-Ba-Ae----G----Aj---Bb---C---G-BdAcE-F--Aj--Ab--AgD-AgGBb----AaEAjAf-CBcBd---Ba---------AdBc-H-Ah--Aj---Ac---Ae--CAaBeG-AjAbDC--IA----BaAg--BdBb--H-Ac---Ai---Ae--Aa------Bc-H---CA-I----F--AhAi-Ac-Ag-DBaC-BdE--BcC-A--AaBb--HGAhAe-----Be-Af--F---AfAcF---Ag--BdAbC---Bj-IAeBeAdGAh", solution = "AjAgGHBbAdBBjBdCBaIAAiBcAbBeAaAfEAcAeDAhFBcBdBaAAhAiAjAgAbIBeAcAaAfEAeBjGFDBCBbHAdAiAcFAeAfHGDBeBaAdAbAgBbCBdBIAhBcAAjAaEBjIBjBEAbAhAfABcAaFDHAeAjAiCBbAcAdAgBaBdBeGAaDCBeAdEAeAcBbFAhBjGBdBHBaAjAAgAbAfIBcAiAcCAaBjIGAAfAdEDHBcAjBeBaBbBdAbBFAhAiAgAeDBHFBdBcIAhAcBbEBaAdAGBeAeAiAgCAaBjAfAbAjEAeAdBbAjAbAgHFBeBjBAhAcAiAfBcDAaACIGBdBaAhAfBcGAgBdBaBAaAiCAeFAbIEAdAcAjBjHBbBeADBeAiAbBaAAjBjCDAeBbAgBdAaAfFGHIAhBcAcEAdBABeAgAjGFAaIBjAdAbAfBbHAhCAcBDBaEAiBcAeBdAdBbDBcAiAeAhBaCAfBdFEBAcBjAgAHBeIGAbAjAaFAaBdAfAcBbAbAiBGBcCDBjAeIEAhAdAjBeHABaAgAeAbBjIBaAcBdEHAgAjAaAiBeABbAfFBcGAdDAhBCHEAhBCBeDAjABcIGBaAgAdAaBdAbAeAiBbFBjAcAfAfAjAcDAaICAdAeAbHABeBaBbBcAhAgBjBdGBFAiEBjHEBdBeAgBcFBaDAeAdBAhAbGICAiAaAjAAcAfBbBaAICAeBBeGAiBdAcEBjFAaAdAjAfBbAbAhBcAgDHAgGBbAhBAAcAaEAjAfAiCBcBdDHBeBaFBjAdAeIAbAbFAiAdBcAfHBbAhBjAgAjIGDAcAEBAeBaBdCAaBeGAhAjAbDCAdBeIABBcAfEBaAgFAeBdBbAiAaHBjAcBdAdBeAiBjBaEAeAfAcAaBbAjIFAhAbBcGHDAgBCABIAeAaHBjFAbGAhAiBeAcAdAgADBaCAfBdEAjBbBcCBcAAgEAaBbBdAjHGAhAeDBjBAiAdBeAcAfAbBaFIBbBaAfAcFDAiBcAgBABdAbCHAjAaBjEIAeBeAdGAh", difficulty = Difficulty.MEDIUM, - gameType = GameType.TwentyFiveDigits, + sudokuType = SudokuType.Sudoku25x25, ), // Remaining Digits 346 SudokuBlueprint( puzzle = "--Ad--BjBb--Bc--AF--AhAcAi-I-Bd--Ba--Aj-----Be--------AgAd-AbAcB---Be---Ai---AbBbBc---BdI-E-Ah--AdBb--BdH-Aa--A--IAeB-C--Aj-AiBe-AfAi-AfF-I--G-AgCAdAcBa-A--Aa-Bc--H-Bj--BdAf--Ba--DB-Ad-AaAe-----IFEBb--Ag---AhBj---AbF--HD-Ba-Aa-AjBAf-H-----Bb-I--Ae------BdBjAi-FC--Ad--Ab-AgAfAaBb---Ai-Bc-Be-Ae---Ba-AhAb-Ae-ACG-AiBjAj--Bb-AcEBBc--IBc-Ad-A----B-------Ba-H-Aj--Ab-BBj-C------Ba-AgAi--BdGAf-------AeBbG-AfAdH--Ab--AhAjB-AAaAc-------AcAeAj--AaI-Af------Ab-CAd-Bc--G-C-Ab-------Be----Bc-Bb-AhB--HBaAAa-Bd--AhBcD-BbAfAc-B-AeG-Ad---Aa-Bj-Ba-D---AeCAbAd-Ai--A--BbAc-AjAbBb------H--Af-C-----I-FBjAh-Ac-I-FBe--BjAg---GH---Bc--DAaAfAd-----AeBc-Aj-EG--Ag--BaC--Bd-Aj--D-Ac--Be-AdGAgEBd-Bb--H-AeAb-BaG-BdAc-B--Ae-BaAbAh--Aj--Af-BbA--CBj--Bc-Ah-BbF---HAaAc---Ab---Ag---AhBbAg-AdI--------Bc-----E--Ai--A-Ae-BdGBj--AjBe--Ac--EC--F--", solution = "AeDAdCEBjBbBaAjBcBeAfAFHAbAhAcAiBIAgBdAaGBaAIAjBcFAhCEBeAaAiBjBdGHAeAfAgAdDAbAcBBbAgGBeAaBHAiAcAfAeAbBbBcAjDBaBdIFEBjAhCAAdBbAcBjBdHAbAaAdAgAEAhIAeBDCBcGAjFAiBeBaAfAiAbAfFAhIDBGBdAgCAdAcBaBeABjBbAaAjBcEAeHAcBjAiBeBdAfEAjBaGBcDBAhAdAAaAeCAgAbHBbIFEBbAeAAgAiBBcAhBjBdBeAcAbFIGHDAfBaAdAaCAjBAfBcHGDAdFAaBbAICAgAeEAbBaAjBeAcBdBjAiAhFCAjIAdBdAcAbHAgAfAaBbBaEBAiAhBcBjBeDAeGAAaBaDAhAbBeAeIACGHAiBjAjBdFBbAdAcEBBcAfAgIBcAhAdBeAAgDAiAcBEGBbAaFAfCBaAeHBjAjAbBdAbHBBjAjCBeAhBbIAcAdBaBcAgAiDAaBdGAfFAEAeBdEAgAeBbGBcAfAdHCFAbAiBjAhAjBIAAaAcBaBeDDFBaAiAcAeAjBjBAaIBdAfAAhBbBeEHAbGCAdAgBcAAaGAfCBaAbEBdFDAeAjHBeAgBjAdAcBcAiBbIAhBCAgHBaAAaBjBdIAbAhBcDBeBbAfAcAjBFAeGAiAdEBcBdAaGBjAgBaHDAfFBAeCAbAdEAiBeIAAjAhBbAcBeAjAbBbDEGAiAcAdHBaAaAfACBcBdAeAhAgIBFBjAhAeAcEIAjFBeCBBjAgBdAdAiGHAbABbBcBaAfDAaAfAdFBAiBbAAeBcAhAjAcEGIAaAgDBjBaCBeHBdAbAjICDFAcAfAaBeAiAdGAgEBdBjBbAAhHBAeAbBcBaGBeBdAcAaBHAgAeEBaAbAhIBcAjAdFAfAiBbADBjCBjBEBcBaAhCBbFDAiAHAaAcAeIGAbBdAdAfAgAjBeHAhBbAgAfAdIAAbAjAeBjFBCBcBaBeAaDBdEGAcAiAdAiAAbAeBcBdGBjBaBbAjBeDAfAcBAgECAhAaFHI", difficulty = Difficulty.MEDIUM, - gameType = GameType.TwentyFiveDigits, + sudokuType = SudokuType.Sudoku25x25, ), ) diff --git a/sudoklify-seeds/src/test/kotlin/dev/teogor/sudoklify/seeds/SudokuParamsTest.kt b/sudoklify-seeds/src/test/kotlin/dev/teogor/sudoklify/seeds/SudokuParamsTest.kt index 9417d94..8136bcb 100644 --- a/sudoklify-seeds/src/test/kotlin/dev/teogor/sudoklify/seeds/SudokuParamsTest.kt +++ b/sudoklify-seeds/src/test/kotlin/dev/teogor/sudoklify/seeds/SudokuParamsTest.kt @@ -18,8 +18,9 @@ package dev.teogor.sudoklify.seeds import dev.teogor.sudoklify.common.model.SudokuParams import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType +import dev.teogor.sudoklify.common.types.SudokuType import dev.teogor.sudoklify.core.generation.createPuzzle +import dev.teogor.sudoklify.ktx.createSeed import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotEquals import org.junit.jupiter.api.Test @@ -29,30 +30,30 @@ class SudokuParamsTest { fun createPuzzle_returnsPuzzleWithCorrectParams() { val params = SudokuParams( difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, - seed = 1234L, + sudokuType = SudokuType.Sudoku9x9, + seed = createSeed(1234L), seeds = combinedSeeds, ) val puzzle = params.createPuzzle() assertEquals(Difficulty.EASY, puzzle.difficulty) - assertEquals(GameType.NineDigits, puzzle.gameType) - assertEquals(1234L, puzzle.seed) + assertEquals(SudokuType.Sudoku9x9, puzzle.sudokuType) + assertEquals(1234L, puzzle.seed.value) } @Test fun createPuzzle_generatesDifferentPuzzlesWithDifferentSeeds() { val params1 = SudokuParams( difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, - seed = 1234L, + sudokuType = SudokuType.Sudoku9x9, + seed = createSeed(1234L), seeds = combinedSeeds, ) val params2 = SudokuParams( difficulty = Difficulty.EASY, - gameType = GameType.NineDigits, - seed = 4321L, + sudokuType = SudokuType.Sudoku9x9, + seed = createSeed(4321L), seeds = combinedSeeds, ) diff --git a/sudoklify-seeds/src/test/kotlin/dev/teogor/sudoklify/seeds/SudokuSeedsTest.kt b/sudoklify-seeds/src/test/kotlin/dev/teogor/sudoklify/seeds/SudokuSeedsTest.kt index 4d667e1..2570dd5 100644 --- a/sudoklify-seeds/src/test/kotlin/dev/teogor/sudoklify/seeds/SudokuSeedsTest.kt +++ b/sudoklify-seeds/src/test/kotlin/dev/teogor/sudoklify/seeds/SudokuSeedsTest.kt @@ -18,13 +18,13 @@ package dev.teogor.sudoklify.seeds import dev.teogor.sudoklify.common.types.Board import dev.teogor.sudoklify.common.types.Difficulty -import dev.teogor.sudoklify.common.types.GameType +import dev.teogor.sudoklify.common.types.SudokuType import dev.teogor.sudoklify.core.generation.difficulty -import dev.teogor.sudoklify.core.generation.gameType import dev.teogor.sudoklify.core.generation.generateSudoku import dev.teogor.sudoklify.core.generation.seed import dev.teogor.sudoklify.core.generation.seeds import dev.teogor.sudoklify.core.generation.sudokuParamsBuilder +import dev.teogor.sudoklify.core.generation.sudokuType import dev.teogor.sudoklify.core.util.toBoard import dev.teogor.sudoklify.core.util.toSequenceString import dev.teogor.sudoklify.ktx.createSeed @@ -37,11 +37,10 @@ class SudokuSeedsTest { fun `test Verify Solution Generation for 4x4 Sudoku`() { val expectedSolution = "3214412314322341" - val gameType = GameType.FourDigits val sudokuParams = sudokuParamsBuilder { seeds { combinedSeeds } seed { createSeed(0L) } - gameType { gameType } + sudokuType { SudokuType.Sudoku4x4 } difficulty { Difficulty.EASY } } val sudoku = sudokuParams.generateSudoku() @@ -54,11 +53,10 @@ class SudokuSeedsTest { val expectedSolution = "395126784178549623642783915531678249964215378827934561486352197759861432213497856" - val gameType = GameType.NineDigits val sudokuParams = sudokuParamsBuilder { seeds { combinedSeeds } seed { createSeed(0L) } - gameType { gameType } + sudokuType { SudokuType.Sudoku9x9 } difficulty { Difficulty.EASY } } val sudoku = sudokuParams.generateSudoku() @@ -71,11 +69,10 @@ class SudokuSeedsTest { val expectedSolution = "15101714111269161352834151017141112691613528341441181016131512231956731669182547141512111310121410168315137914625115246127114310161115981381113195104151226714163697145134111081231161521061631315714411128152947513263816115911121014912151141416102581336717391562111681351441011221584161261131497103115161312515108311142147961113107914251561613412813521234791161081611415" - val gameType = GameType.SixteenDigits val sudokuParams = sudokuParamsBuilder { seeds { combinedSeeds } seed { createSeed(0L) } - gameType { gameType } + sudokuType { SudokuType.Sudoku16x16 } difficulty { Difficulty.EASY } } val sudoku = sudokuParams.generateSudoku() @@ -88,10 +85,9 @@ class SudokuSeedsTest { val expectedSolution = "62281315211101618205914112571724122342319207102125931711622113232441952151612814181232123722813191718154211410616205249112511195916142420234825212103221182113176715212332581713414225201292151810196247111162320178526741219141122918115132521162410391214313252281410762115111623172418192025324720111813623412181525102211416195229172411142213120231521181631782519410259712672116151918935102424251281420622111231713510211973262291281420181325161523174124111412231112152524821101719796452201318162321618122023191110113942451781437156252122817423920211618131115256124122210197253141062518216111917241132352079122132281415422913221191618203724511236178124101415251174231612101452125922081922153716111318241514191062249122317211135242511182320168741824141725512215631971623131189122102021258115181572411714610162219209231332124121651211102423192015197184213132281425176218220174512213716112210612324251481519139115924146182191125218131716472051223322101159241461821911252181317164720512233221019136722810152516242313141211291741821520" - val gameType = GameType.TwentyFiveDigits val sudokuParams = sudokuParamsBuilder { seed { createSeed(0L) } - gameType { gameType } + sudokuType { SudokuType.Sudoku25x25 } difficulty { Difficulty.EASY } } val sudoku = sudokuParams.generateSudoku() @@ -103,8 +99,8 @@ class SudokuSeedsTest { fun `test Verify Puzzle Solutions Against Generated Puzzles`() { combinedSeeds.forEach { sudoku -> val isValid = comparePuzzles( - puzzle = sudoku.puzzle.toBoard(sudoku.gameType), - solution = sudoku.solution.toBoard(sudoku.gameType), + puzzle = sudoku.puzzle.toBoard(sudoku.sudokuType), + solution = sudoku.solution.toBoard(sudoku.sudokuType), ) assertEquals(true, isValid, "Invalid puzzle for seed ${sudoku.solution}")