Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fangyi-zhou/advent-of-code-ocaml-starter
Starter code for doing Advent of Code in OCaml
https://github.com/fangyi-zhou/advent-of-code-ocaml-starter
advent-of-code ocaml
Last synced: 3 months ago
JSON representation
Starter code for doing Advent of Code in OCaml
- Host: GitHub
- URL: https://github.com/fangyi-zhou/advent-of-code-ocaml-starter
- Owner: fangyi-zhou
- Created: 2022-12-14T14:28:56.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-14T14:44:25.000Z (almost 2 years ago)
- Last Synced: 2024-06-30T04:14:11.514Z (4 months ago)
- Topics: advent-of-code, ocaml
- Language: OCaml
- Homepage:
- Size: 7.81 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-advent-of-code - fangyi-zhou/advent-of-code-ocaml-starter
README
# Advent of code with OCaml
## Getting started
1. Create a repository using this template
1. Install dependencies via `opam install . --deps-only`
1. Put your session cookie into `.session`
1. (Optional) Put the year into `.year` (e.g. 2022)## HowTo
For each day, first specify a type `t` for the parsed input, and then
there are 3 functions to implement:- `input : string -> t`, a function to parse the input into a user specified
type `t`
- `part1 : t -> unit` and `part2 : t -> unit`, functions to execute both partsThe functor `Day.Make` generates a function `run` to run the pipeline.
```ocaml
val run : ?only_part1:bool -> ?only_part2:bool -> string -> unit
```The main executable, `aoc`, can be invoked via
```bash
dune exec aoc DAY
```which will invoke the `run` function for that DAY, with input taken from
`inputs` directory.
If no input file is present, then the input file would be downloaded using your
session cookie.If you want to test your program with the small example for the day, the
easiest way is to put it the `example` in the template file.
The expectation test can be invoked with `dune test`, and updated with `dune
promote`, see more in [dune documentation on expectation
tests](https://dune.readthedocs.io/en/stable/tests.html#inline-expectation-tests).