Git Product home page Git Product logo

aoc-2023's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.