Skip to content

Files

Latest commit

689677b · Dec 30, 2021

History

History

day02

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Dec 30, 2021
Dec 30, 2021
Dec 30, 2021

Day 02: Dive!

The "Dive!" problem is about parsing and executing commands based on twodimensional positioning data.

Learnings and resources

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:

File structure