Skip to content

Commit

Permalink
Introduce new sudoku types classic_12x12, reworked classic_6x6
Browse files Browse the repository at this point in the history
  • Loading branch information
ILikeYourHat committed Dec 21, 2024
1 parent cf0a5c8 commit 175769b
Show file tree
Hide file tree
Showing 24 changed files with 205 additions and 48 deletions.
37 changes: 37 additions & 0 deletions src/main/kotlin/io/github/ilikeyourhat/kudoku/type/Classic12x12.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.github.ilikeyourhat.kudoku.type

import io.github.ilikeyourhat.kudoku.model.SudokuType
import io.github.ilikeyourhat.kudoku.model.dividers.RegionDivider

object Classic12x12 : SudokuType {

override val name = "classic_12x12"
override val sizeX = 12
override val sizeY = 12
override val maxValue = 12

override fun template() = """
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
_,_,_,_ _,_,_,_ _,_,_,_
""".trimIndent()

override fun divider(): RegionDivider {
return RegionDivider()
.divideByRows()
.divideByColumns()
.divideByBlocks(4, 3)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.github.ilikeyourhat.kudoku.type

import io.github.ilikeyourhat.kudoku.model.SudokuType
import io.github.ilikeyourhat.kudoku.model.dividers.RegionDivider

object Classic12x12Vertical : SudokuType {

override val name = "classic_12x12_vertical"
override val sizeX = 12
override val sizeY = 12
override val maxValue = 12

override fun template() = """
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
_,_,_ _,_,_ _,_,_ _,_,_
""".trimIndent()

override fun divider(): RegionDivider {
return RegionDivider()
.divideByRows()
.divideByColumns()
.divideByBlocks(3, 4)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package io.github.ilikeyourhat.kudoku.type
import io.github.ilikeyourhat.kudoku.model.SudokuType
import io.github.ilikeyourhat.kudoku.model.dividers.RegionDivider

object Classic6x6Horizontal : SudokuType {
object Classic6x6 : SudokuType {

override val name = "classic_6x6_horizontal"
override val name = "classic_6x6"
override val sizeX = 6
override val sizeY = 6
override val maxValue = 6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package io.github.ilikeyourhat.kudoku.type
val BUILD_IN_TYPES = listOf(
Butterfly12x12,
Classic4x4,
Classic6x6Horizontal,
Classic6x6,
Classic6x6Vertical,
Classic9x9,
Classic12x12,
Classic12x12Vertical,
Classic16x16,
Classic25x25,
DoubleBackslash15x15,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class Butterfly12x12Test : SudokuTypesTest() {
class Butterfly12x12Test : SudokuTypeTestTemplate() {

override val puzzle = """
butterfly_12x12
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.github.ilikeyourhat.kudoku.type

class Classic12x12Test : SudokuTypeTestTemplate() {

override val puzzle = """
classic_12x12
01,__,05,__, 02,__,__,__, __,__,12,08
08,__,04,__, __,07,__,__, __,__,__,__
__,__,__,07, __,__,12,06, 02,__,05,__
12,__,__,__, __,__,__,__, 04,08,__,__
05,06,09,__, __,02,__,04, __,__,10,__
__,04,03,__, __,06,__,01, __,__,09,__
06,__,01,__, __,__,__,07, __,11,__,02
03,__,__,__, __,__,__,02, __,05,__,09
__,__,02,__, __,__,05,10, 03,__,08,__
__,__,__,__, __,__,__,__, __,02,__,__
__,__,__,12, 01,__,__,05, __,10,__,__
__,__,__,__, __,__,06,__, 08,__,07,01
""".trimIndent()

override val solution = """
classic_12x12
01,03,05,06, 02,10,04,09, 11,07,12,08
08,12,04,02, 05,07,01,11, 06,09,03,10
11,09,10,07, 03,08,12,06, 02,01,05,04
12,10,07,01, 11,05,09,03, 04,08,02,06
05,06,09,11, 12,02,08,04, 01,03,10,07
02,04,03,08, 07,06,10,01, 05,12,09,11
06,05,01,09, 08,12,03,07, 10,11,04,02
03,08,12,10, 06,04,11,02, 07,05,01,09
07,11,02,04, 09,01,05,10, 03,06,08,12
10,01,06,03, 04,09,07,08, 12,02,11,05
04,07,08,12, 01,11,02,05, 09,10,06,03
09,02,11,05, 10,03,06,12, 08,04,07,01
""".trimIndent()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.github.ilikeyourhat.kudoku.type

class Classic12x12VerticalTest : SudokuTypeTestTemplate() {

override val puzzle = """
classic_12x12_vertical
__,__,__, __,01,__, __,07,__, __,05,12
__,__,09, __,__,04, 01,12,__, __,__,__
__,__,__, 06,__,__, __,02,__, __,__,__
11,10,07, __,__,__, __,__,04, __,01,__
09,__,__, 02,05,10, __,__,__, __,03,04
__,11,03, 04,__,__, __,__,06, __,10,__
__,__,__, __,12,07, __,11,__, __,09,__
05,__,__, __,__,01, __,__,__, __,__,__
__,__,02, 10,__,__, 11,__,12, __,__,__
__,__,__, 05,__,__, __,__,__, __,__,08
__,__,__, __,__,__, 09,__,10, 06,07,__
__,__,__, __,07,__, __,__,__, __,02,05
""".trimIndent()

override val solution = """
classic_12x12_vertical
02,03,06, 08,01,09, 10,07,11, 04,05,12
08,05,09, 07,11,04, 01,12,03, 02,06,10
04,01,12, 06,10,03, 05,02,08, 07,11,09
11,10,07, 12,02,05, 06,09,04, 08,01,03
09,06,01, 02,05,10, 12,08,07, 11,03,04
12,11,03, 04,09,08, 02,01,06, 05,10,07
10,02,08, 03,12,07, 04,11,05, 01,09,06
05,07,04, 11,06,01, 03,10,09, 12,08,02
07,08,02, 10,03,06, 11,05,12, 09,04,01
01,09,10, 05,04,11, 07,06,02, 03,12,08
03,12,05, 01,08,02, 09,04,10, 06,07,11
06,04,11, 09,07,12, 08,03,01, 10,02,05
""".trimIndent()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class Classic16x16Test : SudokuTypesTest() {
class Classic16x16Test : SudokuTypeTestTemplate() {

override val puzzle = """
classic_16x16
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class Classic25x25Test : SudokuTypesTest() {
class Classic25x25Test : SudokuTypeTestTemplate() {

override val puzzle = """
classic_25x25
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class Classic4x4Test : SudokuTypesTest() {
class Classic4x4Test : SudokuTypeTestTemplate() {

override val puzzle = """
classic_4x4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class Classic6X6HorizontalTest : SudokuTypesTest() {
class Classic6x6Test : SudokuTypeTestTemplate() {

override val puzzle = """
classic_6x6_horizontal
classic_6x6
_,5,_, 2,_,_
_,2,_, _,4,_
Expand All @@ -15,7 +15,7 @@ class Classic6X6HorizontalTest : SudokuTypesTest() {
""".trimIndent()

override val solution = """
classic_6x6_horizontal
classic_6x6
6,5,4, 2,1,3
1,2,3, 5,4,6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class Classic6X6VerticalTest : SudokuTypesTest() {
class Classic6x6VerticalTest : SudokuTypeTestTemplate() {

override val puzzle = """
classic_6x6_vertical
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class Classic9x9Test : SudokuTypesTest() {
class Classic9x9Test : SudokuTypeTestTemplate() {

override val puzzle = """
classic_9x9
_,_,3 ,_,2,_, 6,_,_
9,_,_ ,3,_,5, _,_,1
_,_,1 ,8,_,6, 4,_,_
_,_,3, _,2,_, 6,_,_
9,_,_, 3,_,5, _,_,1
_,_,1, 8,_,6, 4,_,_
_,_,8, 1,_,2, 9,_,_
7,_,_, _,_,_, _,_,8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class DoubleBackslash15x15Test : SudokuTypesTest() {
class DoubleBackslash15x15Test : SudokuTypeTestTemplate() {

override val puzzle = """
double_backslash_15x15
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class DoubleDiagonal9x9Test : SudokuTypesTest() {
class DoubleDiagonal9x9Test : SudokuTypeTestTemplate() {

override val puzzle = """
double_diagonal_9x9
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class DoubleSlash15x15Test : SudokuTypesTest() {
class DoubleSlash15x15Test : SudokuTypeTestTemplate() {

override val puzzle = """
double_slash_15x15
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class SamuraiButterfly30x30Test : SudokuTypesTest() {
class SamuraiButterfly30x30Test : SudokuTypeTestTemplate() {

override val puzzle = """
samurai_butterfly_30x30
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class SamuraiClassic21x21Test : SudokuTypesTest() {
class SamuraiClassic21x21Test : SudokuTypeTestTemplate() {

override val puzzle = """
samurai_classic_21x21
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class SamuraiClassic40x40Test : SudokuTypesTest() {
class SamuraiClassic40x40Test : SudokuTypeTestTemplate() {

override val puzzle = """
samurai_classic_40x40
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class Square1x1Test : SudokuTypesTest() {
class Square1x1Test : SudokuTypeTestTemplate() {

override val puzzle = """
square_1x1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class Square2x2Test : SudokuTypesTest() {
class Square2x2Test : SudokuTypeTestTemplate() {

override val puzzle = """
square_2x2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

import io.github.ilikeyourhat.kudoku.Kudoku
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import io.kotest.matchers.booleans.shouldBeTrue
import io.kotest.matchers.equals.shouldBeEqual
import org.junit.jupiter.api.Test

abstract class SudokuTypesTest {
abstract class SudokuTypeTestTemplate {

abstract val puzzle: String
abstract val solution: String
Expand All @@ -18,7 +18,7 @@ abstract class SudokuTypesTest {

val result = solver.solve(sudokuToSolve)

assertEquals(expectedResult, result)
assertTrue(result.isSolved())
result.shouldBeEqual(expectedResult)
result.isSolved().shouldBeTrue()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class TripleBackslash15x15Test : SudokuTypesTest() {
class TripleBackslash15x15Test : SudokuTypeTestTemplate() {

override val puzzle = """
triple_backslash_15x15
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.ilikeyourhat.kudoku.integration.type
package io.github.ilikeyourhat.kudoku.type

class TripleSlash15x15Test : SudokuTypesTest() {
class TripleSlash15x15Test : SudokuTypeTestTemplate() {

override val puzzle = """
triple_slash_15x15
Expand Down

0 comments on commit 175769b

Please sign in to comment.