summaryrefslogtreecommitdiff
path: root/Day3.lean
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2023-12-09 16:34:30 +0100
committerAndreas Grois <andi@grois.info>2023-12-09 16:34:30 +0100
commitecbf7b27be05dc242f066e681dbe22c4274834f5 (patch)
treecab87543d89619e18da875a2435f2c1c6da9acdd /Day3.lean
parent244078f9f9e722aceafe64e745b9aa50136fb71a (diff)
Day 8 Part 2
Diffstat (limited to 'Day3.lean')
-rw-r--r--Day3.lean2
1 files changed, 1 insertions, 1 deletions
diff --git a/Day3.lean b/Day3.lean
index e15e205..fbc9e3e 100644
--- a/Day3.lean
+++ b/Day3.lean
@@ -106,7 +106,7 @@ def part2 (schematic : Schematic) : Nat :=
Lean.HashMap.ofList $ schematic.numbers.bind $ λ pn ↦ pn.positions.map (·, pn)
let gearSymbols := schematic.parts.filter (Part.symbol · == '*')
-- but the symbols aren't enough, they need to be adjacent to **exactly** 2 numbers
- let numbersNextGearSymbols := List.dedup <$> gearSymbols.map λgs ↦
+ let numbersNextGearSymbols := List.eraseReps <$> gearSymbols.map λgs ↦
gs.position.adjacents.filterMap numberCoordinates.find?
let gearSymbols := numbersNextGearSymbols.filter (List.length · == 2)
let gearRatios := gearSymbols.map $ List.foldl (· * PartNumber.value ·) 1