My Advent of Code 2023 solutions, written in Roc.
Since Roc is a young language, it's not available in most package managers. Hence I'm using direnv along with Nix to automatically set up a shell with roc installed (and roc_ls, the LSP implementation) whenever I cd to this repo. Once you install direnv and Nix, you can just run direnv allow and then wait a bit for Roc to compile from scratch.
Inputs are automatically loaded from the Advent of Code website and cached in the .input/ folder. For you to load your specific inputs, you need to be logged in. You can follow these instructions to learn how to find your session cookie, at which point you can copy it without quotes to a file named .session.
Solutions for each day live in the days folder, each called DayX.roc. You can copy this template to kickstart a day's solutions off:
interface DayXX
exposes [part1, part2]
imports []
part1 = \lines ->
"TODO"
part2 = \lines ->
"TODO"There are two other places where you'll need to add code for hooking up the new day's solutions:
- Add a
days.DayXXimport to the top ofmain.roc - Add a
XX -> Ok (DayXX.part1, DayXX.part2)case to thesolutionsForDayfunction
Assuming you have Roc installed, just run roc main.roc <DAY> with DAY being the solutions you want to run.
~/dev/aoc-2023
❯ roc main.roc 1
Advent of Code 2023 solutions for day 1:
Result for part 1 in 4ms: ...
Result for part 2 in 407ms: ...