diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2016/Advent24.scala b/scala2/src/main/scala/jurisk/adventofcode/y2016/Advent24.scala index 1acb6d42..1587498c 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2016/Advent24.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2016/Advent24.scala @@ -36,7 +36,7 @@ object Advent24 extends IOApp.Simple { def locationOf(locationCode: LocationCode): Coords2D = field - .filterCoordsByValue(_ == Square.Location(locationCode)) + .filterCoordsByValue(Square.Location(locationCode)) .singleElementUnsafe val (a, b) = setOfTwo.tupleInArbitraryOrder diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2018/Advent17.scala b/scala2/src/main/scala/jurisk/adventofcode/y2018/Advent17.scala index 068216a5..87f2b34f 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2018/Advent17.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2018/Advent17.scala @@ -48,7 +48,7 @@ object Advent17 { } private def runWaterDown: State = { - val waterSquares = field.filterCoordsByValue(_ == RunningWater) + val waterSquares = field.filterCoordsByValue(RunningWater) // Optimisation possibility: run all the way at once, not just one square val result = waterSquares.foldLeft(field) { case (acc, c) => acc.conditionalUpdate(c.S, _ == Empty, RunningWater) @@ -57,7 +57,7 @@ object Advent17 { } private def runWaterToSides: State = { - val waterSquares = field.filterCoordsByValue(_ == RunningWater) + val waterSquares = field.filterCoordsByValue(RunningWater) val result = waterSquares.foldLeft(field) { case (acc, c) => if (isSolid(acc, c.S)) { // Optimisation possibility: all the way at once, not just one square diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent12.scala b/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent12.scala index 2f653ef8..02c645f2 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent12.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent12.scala @@ -31,8 +31,8 @@ object Advent12 { def parse(data: String): Task = { val charField = Field2D.parseCharField(data) - val List(start) = charField.filterCoordsByValue(_ == 'S') - val List(end) = charField.filterCoordsByValue(_ == 'E') + val List(start) = charField.filterCoordsByValue('S') + val List(end) = charField.filterCoordsByValue('E') val field = charField map { case 'S' => Elevation.Lowest diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent17.scala b/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent17.scala index dbfafb50..3ab9ee8f 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent17.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent17.scala @@ -109,7 +109,7 @@ object Advent17 { private def fieldMinY(field: Field2D[Square]): Int = field - .filterCoordsByValue { + .filterCoordsByPredicate { case Square.Wall => true case Square.Rock => true case Square.Empty => false diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent22.scala b/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent22.scala index 632e2fef..8e8a2ecb 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent22.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent22.scala @@ -233,7 +233,7 @@ object Advent22 { val (field, commands) = data val start = field - .filterCoordsByValue(_ == Open) + .filterCoordsByValue(Open) .filter(_.y == 0) .minBy(_.x) diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent23.scala b/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent23.scala index 6ab6b36c..93c1c23b 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent23.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2022/Advent23.scala @@ -94,7 +94,7 @@ object Advent23 { def parse(data: String): State = { val field = Field2D.parseBooleanField(data) - val elfPositions = field.filterCoordsByValue(_ == true) + val elfPositions = field.filterCoordsByValue(true) val elves = elfPositions.zipWithIndex.map { case (c, idx) => Elf(idx, c) } diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent03.scala b/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent03.scala index ff5d2b23..50bceaa6 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent03.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent03.scala @@ -48,7 +48,7 @@ object Advent03 { private def extractNumbers( field: Field2D[Square] ): Set[(Int, Set[Coords2D])] = { - val digitCoords = field.filterCoordsByValue(_.isDigit) + val digitCoords = field.filterCoordsByPredicate(_.isDigit) val islands = ConnectedComponents .connectedComponents[Coords2D]( @@ -78,7 +78,7 @@ object Advent03 { def part1(data: Parsed): Int = { val numbers = extractNumbers(data) - val specialSymbolCoords = data.filterCoordsByValue { + val specialSymbolCoords = data.filterCoordsByPredicate { case Symbol(_) => true case _ => false }.toSet @@ -94,7 +94,7 @@ object Advent03 { def part2(data: Parsed): Int = { val numbers = extractNumbers(data) - val gearSymbolCoords = data.filterCoordsByValue(_ == Gear) + val gearSymbolCoords = data.filterCoordsByValue(Gear) gearSymbolCoords .map { gearCoordinates => diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent10.scala b/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent10.scala index feb074ee..9a5b8652 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent10.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent10.scala @@ -31,7 +31,7 @@ object Advent10 { def parse(s: String): Input = { val chars: Field2D[Char] = Field2D.parseCharField(s) - val animalAt = chars.filterCoordsByValue(_ == 'S').singleResultUnsafe + val animalAt = chars.filterCoordsByValue('S').singleResultUnsafe val mapping = Map( '|' -> N_S, diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent11.scala b/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent11.scala index 56a8588e..f48e2c9d 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent11.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent11.scala @@ -18,7 +18,7 @@ object Advent11 { def parse(input: String): Galaxies = { val field = Field2D.parseBooleanField(input) - val coords = field.filterCoordsByValue(_ == true) + val coords = field.filterCoordsByValue(true) val results = coords.map { c => Coordinates2D[BigInt](c.x, c.y) diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent21.scala b/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent21.scala index 316532c8..19481c77 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent21.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2023/Advent21.scala @@ -26,7 +26,7 @@ object Advent21 { def parse(input: String): Input = { val temp = Field2D.parseCharField(input) - val start = temp.filterCoordsByValue(_ == 'S').singleResultUnsafe + val start = temp.filterCoordsByValue('S').singleResultUnsafe val field = temp.map { case '.' => false diff --git a/scala2/src/main/scala/jurisk/adventofcode/y2024/Advent10.scala b/scala2/src/main/scala/jurisk/adventofcode/y2024/Advent10.scala index f368277d..02d319e0 100644 --- a/scala2/src/main/scala/jurisk/adventofcode/y2024/Advent10.scala +++ b/scala2/src/main/scala/jurisk/adventofcode/y2024/Advent10.scala @@ -2,7 +2,6 @@ package jurisk.adventofcode.y2024 import jurisk.geometry.{Coords2D, Field2D} import jurisk.utils.FileInput._ -import jurisk.utils.Parsing.StringOps object Advent10 { type Input = Field2D[Int] @@ -51,7 +50,7 @@ object Advent10 { } private def solve(data: Input, f: (Input, Coords2D) => Int): Int = { - val candidateTrailHeads = data.filterCoordsByValue(_ == Start) + val candidateTrailHeads = data.filterCoordsByValue(Start) val scores = candidateTrailHeads.map(c => f(data, c)) scores.sum }