36 lines
1 KiB
Markdown
36 lines
1 KiB
Markdown
# Advent of Code 2021
|
|
|
|
this flake builds a package containing a program for each problem in this years advent of code.
|
|
|
|
## adding a problem
|
|
|
|
create a folder in `code/src` for the problem, then add an entry with the following format into `code/aoc2021-programs.cabal`:
|
|
|
|
```
|
|
executable aoc2021-XX
|
|
main-is: Main.hs
|
|
ghc-options: -O2 -Wall
|
|
hs-source-dirs: src/XX
|
|
build-depends: base
|
|
default-language: Haskell2010
|
|
```
|
|
|
|
## building
|
|
|
|
your choice of:
|
|
|
|
```
|
|
nix shell git+https://git.p7.co.nz/thornAvery/aoc2021
|
|
nix build git+https://git.p7.co.nz/thornAvery/aoc2021
|
|
```
|
|
|
|
or you can add the overlay defined in the flake
|
|
|
|
## running
|
|
|
|
this flake defines a wrapper script that automates passing input to the problems.
|
|
|
|
in order to use it, the problem folder must include `XX-input.txt`, where `XX` is the suffix defined in the cabal file.
|
|
|
|
the default package provides a wrapper `aoc2021`, which when invoked with `aoc2021 XX` will cat the contents of `XX-input.txt` to the program `aoc2021-XX` (as defined in the cabal file).
|