I really enjoyed today's puzzle. I spent nearly the entire time figuring out the solution and much less time trying to find the right function in the standard library or wrestling with the language server and tooling.
I started off solving part 1 as if I was looking for all rectangles. I wasn't until I kept getting the wrong answer that I realized I needed to measure the side lengths. I had a sneaking suspicion that part 2 would involve finding the rectangles... but I was wrong.
Ironically, the approach I used for part 2 is still not too different from part 1. I defined a square by simply the top left and right points, which lets me just look for the bottom left and right points to see if they exist. In previous years, I have defaulted to using a dictionary for these problems involving 2d grids, but a set worked out a lot better.
I am enjoying Roc quite a lot, and it’s nice to have the option to us a for loop instead of folding. Roc also doesn’t seem to like shadowed variables, so I have to come up with more names for initial state with nested folds. I solved this by splitting up the nested functions in the input parser. As already mentioned in the Roc Zulip, it would be nice to have better output for failed tests. I have to resort to adding dbg statements. And it would be nice to be able to pipeline dbg. Also, it’s strange to me that List.fold_with_index exists but Iter.fold_with_index does not. I’m curious how these are implemented and why List doesn’t just inherit from Iter.
I would love to contribute to the development of a programming language, and I feel like his might be an area I would help out with given my extensive experience with a lot of different standard libraries. Oh, and while we’re talking about standard libraries, I love that I don’t have to import the standard modules themselves unlike Gleam and Go.
Anyway, here’s my solution…
