54
SOLUTION MEGATHREAD-🎄- 2019 Day 3 Solutions -🎄-(self.adventofcode)
submitted 6 years, 1 month ago* (edited 14 minutes after) by daggerdragon to /r/adventofcode (134.8k)
since 6 years, 1 month ago
5 of 5
Tip Reveddit Real-Time can notify you when your content is removed.
your account history
Tip Check if your account has any removed comments.
view my removed comments you are viewing a single comment's thread.
view all comments


Haskell:
Represented each wire as a Map of points to the number of steps to reach it, and Map has handy intersection and intersectionWith functions.
That "fromListWith min" is smart. I wasted a lot of time recursing in the State monad and checking membership in the map
Thanks! For what it's worth I was also recursing and checking membership before but went back and simplified after. I've found the State monad to be more overhead than it's worth for simpler iterative mutations like this.
Wow, replicate + scanl is a slick way to get the step list!
Funny how your part2 function is identical to mine but implementation of parseWire is totally different. Power of Haskell 💪