2021-12-01 14:48:17 +01:00
# Advent Of Code
2023-11-29 15:57:17 +01:00
Template repository for Advent of Code. It automatically downloads your puzzle inputs and bootstraps files for the following languages:
- Typescript
- Python
- Rust
Have fun! 🤗🎄
2023-11-18 17:52:07 +01:00
## Getting started
New "days" are generated with [`hygen` ](https://github.com/jondot/hygen ). This will bootstrap code for python and rust. See details about the specifica languages below
```bash
# First time setup
bun i
2023-11-29 16:02:54 +01:00
# Put the Advent of Code token into .env (details below)
2023-11-29 15:57:17 +01:00
# Generate day
2023-11-18 17:52:07 +01:00
bun run gen --year 2022 --day 1
```
2023-11-29 16:02:54 +01:00
> Extracting the Advent of Code cookie
>
> 1. Navigate to https://adventofcode.com/ and login.
> 2. Open dev tools and copy the cookie named `session`.
> 3. save `TOKEN=<my-token>` to `.env`.
2023-11-29 15:57:17 +01:00
## Languages
Below are instructions for the specific handling of each language included.
2023-11-18 17:52:07 +01:00
2023-11-29 15:57:17 +01:00
### Typescript
2023-11-18 17:52:07 +01:00
Run a single day:
```bash
2023-11-29 15:57:17 +01:00
# Once
bun run 2022/01/typescript/main.ts
# Rerun on change
bun run --watch 2022/01/typescript/main.ts
```
### Python
```bash
# Get a python enabled shell, with the latest version
poetry shell
# Run once
python 2022/01/python/main.py
# Rerun on change
bunx nodemon 2022/01/python/main.py
```
### Rust
Run a single day:
```bash
# Once
2023-11-18 17:52:07 +01:00
cargo run --bin 2022-01
2023-11-29 15:57:17 +01:00
# Rerun on change (requires: https://github.com/watchexec/cargo-watch)
cargo watch -x 'run --bin 2022-01'
2023-11-18 17:52:07 +01:00
```
2023-11-29 15:57:17 +01:00
Benchmark a day:
2023-11-18 17:52:07 +01:00
```bash
cargo bench --bin 2022-01
```
2023-11-29 15:57:17 +01:00
Benchmark all days:
2023-11-18 17:52:07 +01:00
```bash
cargo bench
```
> The benchmark is the built in Rust one. This is the [reason](https://doc.rust-lang.org/cargo/commands/cargo-bench.html) for the _nightly_ version.