diff options
| author | Andreas Grois <andi@grois.info> | 2023-12-09 16:34:30 +0100 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2023-12-09 16:34:30 +0100 |
| commit | ecbf7b27be05dc242f066e681dbe22c4274834f5 (patch) | |
| tree | cab87543d89619e18da875a2435f2c1c6da9acdd /Day3.lean | |
| parent | 244078f9f9e722aceafe64e745b9aa50136fb71a (diff) | |
Day 8 Part 2
Diffstat (limited to 'Day3.lean')
| -rw-r--r-- | Day3.lean | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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 |
