The "Dive!" problem is about parsing and executing commands based on twodimensional positioning data.
The command typings given in the exercise closely resemble the data type declaration syntax, so I read up about data type declarations on the Haskell wiki:
For debugging purposes, I made my type implement the "Show" class and implemented the "show" method for my type, as shown in this post:
After having implemented the solutions for both parts, I realized that I could use a folding operation to apply the position changes dictated by the given commands.
I learned that foldr
and foldl
have different results if the combinator function (applyCommandPartTwo
, in this case) is not associative.
The combination function's arguments are also flipped:
./day02.hs
: My solution for part one of this puzzle./input.txt
: My personal puzzle input for this challenge./README.md
: documentation for this solution :)