Giter Club home page Giter Club logo

aoc22's Introduction

Advent of Code Solutions

Structure

Solutions

Solutions are divided into modules in the following manner:

  • Each day has its separate module folder
  • Each part of the day has its own module in the day's folder
  • There is a Common.hs module inside the day's folder to factor out common functionality in parts I and II.

Tests

Each solution should have its corresponding test, which usually uses the examples from the corresponding problem. The naming convention for the day module is Day<day>Spec.hs. For example, for day 1 the corresponding test module would be called DayOneSpec.

Puzzle inputs

The puzzle inputs are located in the puzzle-inputs directory. These must be named following the convention: day<day number>.txt.

The provided CLI tool can be used to fetch the input for every day. For example, to fetch the input for day 1:

aoc fetchInput --day 1

This will download your input and put it in puzzle-inputs/day1.txt.

NOTE: For this to work you need to put your session cookie in an .env file using the key AOC_SESSION.

Generate boilerplate

This template comes with a CLI tool to help you generate all this boilerplate code. To install it run

cabal install

Then you can use the tool to generate to solution component and test modules:

aoc generate --day 1

Example output:

Creating component file: lib/Aoc/Day/One/PartOne.hs
Creating component file: lib/Aoc/Day/One/PartTwo.hs
Creating component file: lib/Aoc/Day/One/Common.hs
Creating test module: test/DayOneSpec.hs

Finished creating component.

Copy this in your cabal file to add the new component to the build:

In lib:

   Aoc.Day.One.PartOne,
   Aoc.Day.One.PartTwo,
   Aoc.Day.One.Common,

In the test suite:

   DayOneSpec,


Running

In the app directory there is an executable to run the solutions. You'll need to edit it in order to add the solution for each day. See the instructions in the source code.

Then you can run it with

cabal run aoc-runner <day-number>

For example, to run the solution for day 1:

cabal run aoc-runner 1

License

MIT

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.