Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fpapado/elm-aoc-starter
A setup for starting to solve Advent of Code problems in Elm, with tests and a CLI.
https://github.com/fpapado/elm-aoc-starter
advent-of-code aoc elm
Last synced: 3 days ago
JSON representation
A setup for starting to solve Advent of Code problems in Elm, with tests and a CLI.
- Host: GitHub
- URL: https://github.com/fpapado/elm-aoc-starter
- Owner: fpapado
- Created: 2019-12-11T17:13:40.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T11:49:55.000Z (almost 2 years ago)
- Last Synced: 2024-04-13T18:27:18.844Z (7 months ago)
- Topics: advent-of-code, aoc, elm
- Language: Elm
- Homepage:
- Size: 162 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Elm Advent of Code Starter
This is a simple setup for starting to solve [Advent of Code][aoc] problems in [Elm][elm].
## What problem this addresses
Advent of Code problems often take their input from a file.
In Elm, we don't have a filesystem!
This setup allows reading the input using [Elm flags][elm-flags].Similarly, we set up tests with [`elm-test`][elm-test], so you can view your code on the command line, rather than having to set up a format for the browser.
You could do all of those things manually, or in a browser, or through the test interface. This is meant to be a starting point!
## Quick Start
You will need [Node][node] and [npm][npm].\* npm comes installed with Node.
It should not matter much which versions, though either way I'd recommend you use [nvm][nvm] to install Node. It works better without needing admin privileges for every npm installation.You will also need [git][git].
Then, in a terminal, like iterm or gnome terminal, run:
```shell
npx degit fpapado/elm-aoc-starter aoc-2019-elm
cd aoc-2019-elm
npm ci
npm test
```## Structure / Solving Advent of Code Problems
Adding a solution works as follows:
- Copy the input that Advent of Code gives you to `inputs/dayX.txt`
- Add your solution in an Elm module under `src`. I call them `DayX.elm`, but you can pick anything.
- In `Main.elm`, import your module, and change the pattern match in `init` to call the respective function for the day and part.
- Run `npm run solve day part`, e.g. `npm run solve 1 1`, in a terminalIf you want to run tests:
- Add a test module under `tests`, for example `tests/Day1Test.elm`
- Write tests as you want :)
- Run `npm run test` or `elm-test` directly, in a terminal## Other notes
### \*On needing Node
Node is used for the CLI toolchain and the test runner.
The Elm compiler can very well be run by itself, without needing Node :)[aoc]: https://adventofcode.com/
[elm]: https://elm-lang.org/
[elm-test]: https://github.com/elm-explorations/test
[elm-flags]: https://guide.elm-lang.org/interop/flags.html
[node]: https://nodejs.org/en/
[npm]: https://www.npmjs.com/
[nvm]: https://github.com/nvm-sh/nvm#installation-and-update
[git]: https://help.github.com/en/github/getting-started-with-github/set-up-git