To run code for a day:
cabal run y2025d01 input/2025/day01/sample.txt
- Haskell's
scanlis handy for this sort of problem. - I had a bunch of off-by-ones on part 2, for example if you landed exactly on zero, I'd double-count it.
- Looking at reddit posts, the cleanest solution is to replace the big turns with a bunch of L1s and R1s. Then you can reuse your code from part 1.
replicateis the function for this.
- Defining local helper functions with
whereis handy, and you don't need to write explicit types for them. - You can't write
1 / 2in Haskell, but you can write1.div2 - The Haskell equivalent of
str * nisconcat (replicate n str).