Skip to content

Commit

Permalink
Merge pull request #61 from teogor/bugfix/deprecated-functions-compat…
Browse files Browse the repository at this point in the history
…ibility

Ensure Compatibility During Deprecation: Replace Deprecated Functions in createPuzzle()
  • Loading branch information
teogor authored Mar 2, 2024
2 parents 841d6ac + a648d5e commit b8b808e
Showing 1 changed file with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import dev.teogor.sudoklify.core.util.sortRandom
import dev.teogor.sudoklify.core.util.toBoard
import dev.teogor.sudoklify.core.util.toSequenceString
import dev.teogor.sudoklify.ktx.createSeed
import dev.teogor.sudoklify.ktx.mapIndexedToSudokuBoard
import dev.teogor.sudoklify.ktx.mapToSudokuBoard
import dev.teogor.sudoklify.ktx.toJEncodedCell
import kotlin.math.sqrt
import kotlin.random.Random
Expand Down Expand Up @@ -102,17 +100,27 @@ class SudokuGenerator internal constructor(
sudokuType = seed.sudokuType,
seed = this.seed,
givens =
puzzle.toSequenceString()
.mapIndexedToSudokuBoard(seed.sudokuType) { value, row, col ->
SudokuPuzzle.Givens(
value = value,
row = row,
col = col,
)
}.flatten().filter { it.value != 0 },
puzzle
.map { it.toList() }
.mapIndexed { row, cols ->
cols.mapIndexed { col, value ->
SudokuPuzzle.Givens(
value = value.toIntOrNull() ?: 0,
row = row,
col = col,
)
}
}
.flatten()
.filter { it.value != 0 },
solution =
solution.toSequenceString()
.mapToSudokuBoard(seed.sudokuType),
solution
.map { it.toList() }
.map { cols ->
cols.map { value ->
value.toIntOrNull() ?: 0
}
},
)
}

Expand Down

0 comments on commit b8b808e

Please sign in to comment.