Skip to content

StarDylan/AdventOfCode2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎄 Advent of Code 2023

Solutions for Advent of Code in Rust.

2023 Results

Day Part 1 Part 2
Day 1
Day 2
Day 3
Day 4
Day 5
Day 6
Day 7
Day 8
Day 9

Benchmarks

Day Part 1 Part 2
Day 1 80.5µs 1.1ms
Day 2 42.4µs 41.9µs
Day 3 102.8µs 6.7ms
Day 4 569.3µs 749.8ms
Day 5 11.7µs 4.7s
Day 6 284.0ns 17.6ms
Day 7 4.6ms 106.9ms
Day 8 860.8µs 2.0ms
Day 9 626.9µs 624.8µs

Total: 5591.66ms


Usage

Scaffold a day

# example: `cargo scaffold 1`
cargo scaffold <day>

# output:
# Created module file "src/bin/01.rs"
# Created empty input file "data/inputs/01.txt"
# Created empty example file "data/examples/01.txt"
# ---
# 🎄 Type `cargo solve 01` to run your solution.

Individual solutions live in the ./src/bin/ directory as separate binaries. Inputs and examples live in the the ./data directory.

Every solution has unit tests referencing its example file. Use these unit tests to develop and debug your solutions against the example input.

Tip: when editing a solution, rust-analyzer will display buttons for running / debugging unit tests above the unit test blocks.

Download input & description for a day

Note
This command requires installing the aoc-cli crate.

# example: `cargo download 1`
cargo download <day>

# output:
# [INFO  aoc] 🎄 aoc-cli - Advent of Code command-line tool
# [INFO  aoc_client] 🎅 Saved puzzle to 'data/puzzles/01.md'
# [INFO  aoc_client] 🎅 Saved input to 'data/inputs/01.txt'
# ---
# 🎄 Successfully wrote input to "data/inputs/01.txt".
# 🎄 Successfully wrote puzzle to "data/puzzles/01.md".

Run solutions for a day

# example: `cargo solve 01`
cargo solve <day>

# output:
#     Finished dev [unoptimized + debuginfo] target(s) in 0.13s
#     Running `target/debug/01`
# Part 1: 42 (166.0ns)
# Part 2: 42 (41.0ns)

The solve command runs your solution against real puzzle inputs. To run an optimized build of your code, append the --release flag as with any other rust program.

By default, solve executes your code once and shows the execution time. If you append the --time flag to the command, the runner will run your code between 10 and 10.000 times (depending on execution time of first execution) and print the average execution time.

For example, running a benchmarked, optimized execution of day 1 would look like cargo solve 1 --release --time. Displayed timings show the raw execution time of your solution without overhead like file reads.

Submitting solutions

Note
This command requires installing the aoc-cli crate.

In order to submit part of a solution for checking, append the --submit <part> option to the solve command.

Run all solutions

cargo all

# output:
#     Running `target/release/advent_of_code`
# ----------
# | Day 01 |
# ----------
# Part 1: 42 (19.0ns)
# Part 2: 42 (19.0ns)
# <...other days...>
# Total: 0.20ms

This runs all solutions sequentially and prints output to the command-line. Same as for the solve command, --release controls whether real inputs will be used.

Update readme benchmarks

The template can output a table with solution times to your readme. Please note that these are not "scientific" benchmarks, understand them as a fun approximation. 😉

In order to generate a benchmarking table, run cargo all --release --time. If everything goes well, the command will output "Successfully updated README with benchmarks." after the execution finishes.

Run all tests

cargo test

To run tests for a specific day, append --bin <day>, e.g. cargo test --bin 01. You can further scope it down to a specific part, e.g. cargo test --bin 01 part_one.

Format code

cargo fmt

Lint code

cargo clippy

Read puzzle description in terminal

Note
This command requires installing the aoc-cli crate.

# example: `cargo read 1`
cargo read <day>

# output:
# Loaded session cookie from "/Users/<snip>/.adventofcode.session".
# Fetching puzzle for day 1, 2022...
# ...the input...

Optional template features

Configure aoc-cli integration

  1. Install aoc-cli via cargo: cargo install aoc-cli --version 0.12.0
  2. Create an .adventofcode.session file in your home directory and paste your session cookie. To retrieve the session cookie, press F12 anywhere on the Advent of Code website to open your browser developer tools. Look in Cookies under the Application or Storage tab, and copy out the session cookie value. [^1]

Once installed, you can use the download command and automatically submit solutions via the --submit flag.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages