Skip to content

Commit

Permalink
wip perf
Browse files Browse the repository at this point in the history
  • Loading branch information
meikpiep committed Oct 26, 2024
1 parent caa4627 commit 894336c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ private val logger = KotlinLogging.logger {}

class HumanSolver(
private val grid: Grid,
private val validate: Boolean = false,
) {
private val humanSolverStrategy =
HumanSolverStrategies.entries
Expand Down Expand Up @@ -41,7 +42,9 @@ class HumanSolver(
if (progress) {
logger.info { "Added ${it.difficulty} from ${it.solver::class.simpleName}" }

if (grid.numberOfMistakes() != 0 || grid.cells.any { !it.isUserValueSet && it.possibles.isEmpty() }) {
if (validate &&
(grid.numberOfMistakes() != 0 || grid.cells.any { !it.isUserValueSet && it.possibles.isEmpty() })
) {
logger.error { "Last step introduced errors." }
throw IllegalStateException("Found a grid with wrong values.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class HumanDifficultySolverTest :
val grid = calculator.calculate()
grid.cells.forEach { it.possibles = grid.variant.possibleDigits }

val solver = HumanSolver(grid)
val solver = HumanSolver(grid, true)

val solverResult = solver.solveAndCalculateDifficulty()

Expand Down

0 comments on commit 894336c

Please sign in to comment.