Skip to content

smores56/aoc-2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Code 2023

My Advent of Code 2023 solutions, written in Roc.

Setup

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.

Loading Inputs

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.

New Days

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.DayXX import to the top of main.roc
  • Add a XX -> Ok (DayXX.part1, DayXX.part2) case to the solutionsForDay function

Running

Assuming you have Roc installed, just run roc main.roc <DAY> with DAY being the solutions you want to run.

Example

~/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: ...

About

Solutions for AoC 2023 in Roc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published