Skip to content

Commit

Permalink
Simplifies code by removing an unused parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
meikpiep committed Jan 2, 2025
1 parent fbff374 commit c243818
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ abstract class AbstractLinesSingleCagePossiblesSum(
lines.any { line -> line.contains(it) }
}.any { !it.isUserValueSet }

if (!StaticSumUtils.hasStaticSumInCells(grid, cage, lineCells, cache)) {
if (!StaticSumUtils.hasStaticSumInCells(cage, lineCells, cache)) {
if (singleCageNotCoveredByLines != null && hasAtLeastOnePossibleInLines) {
return Pair(null, 0)
}

singleCageNotCoveredByLines = cage
} else {
staticGridSum += StaticSumUtils.staticSumInCells(grid, cage, lineCells, cache)
staticGridSum += StaticSumUtils.staticSumInCells(cage, lineCells, cache)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ abstract class AbstractTwoCellsPossiblesSum(
lines.any { line -> line.contains(it) }
}.filter { !it.isUserValueSet }

if (!StaticSumUtils.hasStaticSumInCells(grid, cage, lineCells, cache)) {
if (!StaticSumUtils.hasStaticSumInCells(cage, lineCells, cache)) {
cellsNotCoveredByLines += dynamicSumCells
staticGridSum +=
cage.cells
Expand All @@ -75,7 +75,7 @@ abstract class AbstractTwoCellsPossiblesSum(
return Pair(emptyList(), 0)
}
} else {
staticGridSum += StaticSumUtils.staticSumInCells(grid, cage, lineCells, cache)
staticGridSum += StaticSumUtils.staticSumInCells(cage, lineCells, cache)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GridSumEnforcesCageSum : HumanSolverStrategy {
var staticGridSum = 0

grid.cages.forEach { cage ->
if (StaticSumUtils.hasStaticSum(grid, cage, cache)) {
if (StaticSumUtils.hasStaticSum(cage, cache)) {
staticGridSum += StaticSumUtils.staticSum(grid, cage, cache)
} else if (cageWithDynamicSum == null) {
cageWithDynamicSum = cage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package org.piepmeyer.gauguin.difficulty.human.strategy

import org.piepmeyer.gauguin.creation.cage.GridCageType
import org.piepmeyer.gauguin.difficulty.human.HumanSolverCache
import org.piepmeyer.gauguin.grid.Grid
import org.piepmeyer.gauguin.grid.GridCage
import org.piepmeyer.gauguin.grid.GridCageAction
import org.piepmeyer.gauguin.grid.GridCell

object StaticSumUtils {
fun staticSum(
grid: Grid,
cage: GridCage,
cache: HumanSolverCache,
): Int {
Expand All @@ -28,7 +26,6 @@ object StaticSumUtils {
}

fun staticSumInCells(
grid: Grid,
cage: GridCage,
cells: Set<GridCell>,
cache: HumanSolverCache,
Expand All @@ -55,7 +52,6 @@ object StaticSumUtils {
}

fun hasStaticSum(
grid: Grid,
cage: GridCage,
cache: HumanSolverCache,
): Boolean {
Expand All @@ -73,7 +69,6 @@ object StaticSumUtils {
}

fun hasStaticSumInCells(
grid: Grid,
cage: GridCage,
cells: Set<GridCell>,
cache: HumanSolverCache,
Expand Down

0 comments on commit c243818

Please sign in to comment.