I like the intensive usage of streams
Interesting solution. I like the idea of putting all points in two MapSet
s, the code is pretty straightforward to read.
Funny you say that, I did actually say to myself when I sat down that I wanted to try your technique of stream-all-the-things today. In the end though, I didnāt feel like I fit it to the problem very well.
I rarely bother to explain my solutions because I post them so late in the cycle that my ideas are already represented. I do read through the solutions of others when Iām done though.
I ended up switching datastructure two times for day 3. Started with lists for the wires, but switched to MapSet to be able to use MapSet.intersection/2. Then for part 2 I switched to Map to be able to track steps, but continued comparing using MapSet.intersection by first converting to a MapSet.
My solution is a bit overkill with nested modules to contain different parts of the code, itās something Iāve experimented with recently, to see if the code stays more readable when I return to it later. Though I didnāt go all the way through with it. Code left it as it was when I finished part 2.
Yeah, it doesnāt seem that streams are optimal here. To be clear, I donāt use streams that much in real code, but I like to use these challenges to practice them a bit.
Escripts are slow and my initial solution with maps was very slow so I re-wrote my Gleam solution after watching this: https://github.com/michallepicki/adventofcode/blob/master/2019/gleam/src/crossed_wires_after_watching_freds_recording.gleam
(could optimize even further but meh)
Iām slowly catching up!
Finally solved Day03 after tracking down a silly logic error which didnāt show up in any of the tests but did when I was trying to calculate my part 2 result. Code is here.