Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jurisk committed Dec 16, 2023
1 parent 9c899dd commit 29be731
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
12 changes: 1 addition & 11 deletions scala2/src/main/scala/jurisk/adventofcode/y2018/Advent17.scala
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,8 @@ object Advent17 {

def simulate(field: Field2D[Square]): Field2D[Square] = {
printField("Before:", field)

val (result, _) = Simulation.runUntilStableStateWithCounter(State(field)) {
case (state, iteration) =>
val newState = state.next
if (iteration % 1_000 == 0) {
printField("Next", newState.field)
}
newState
}

val result = Simulation.runUntilStableState(State(field))(_.next)
printField("After:", result.field)

result.field
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ object Advent24 {
}

private def simulateRound(state: State): (Int, Int) = {
val (result, _) = Simulation.runUntilStableStateWithCounter(state) {
case (state, _) =>
state.next
}
val result = Simulation.runUntilStableState(state)(_.next)

(
result.immuneSystem.values.map(_.units).sum,
Expand Down

0 comments on commit 29be731

Please sign in to comment.