Skip to content

Solutions for Advent of Code 2024 in Rust πŸ¦€πŸ‘¨β€πŸ’»πŸŽ„

License

Notifications You must be signed in to change notification settings

MoritzHayden/aoc-2024

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ„ Advent of Code 2024

Solutions for Advent of Code 2024 in Rust.

2024 Results

Day Part 1 Part 2
Day 1 ⭐ ⭐
Day 2 ⭐ ⭐
Day 3 ⭐ ⭐
Day 4 ⭐ ⭐
Day 5 ⭐

Benchmarks

Day Part 1 Part 2
Day 1 317.1Β΅s 317.9Β΅s
Day 2 114.8Β΅s 160.5Β΅s
Day 3 233.9Β΅s 286.0Β΅s
Day 4 2.4ms 161.3Β΅s
Day 5 1.4ms -

Total: 5.39ms


Setup

  1. Install the Rust toolchain
  2. Install aoc-cli via Cargo: cargo install aoc-cli
  3. Create the file <home_directory>/.adventofcode.session and paste your AoC session cookie into it

Usage

Scaffold Solution

# 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.

Download Input

# example: `cargo download 1`
# alternative: `cargo scaffold 1 --download`
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 Solution

# example: `cargo solve 01`
# alternative: `cargo solve 01 --release`
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)

Submit Solution

# example: `cargo solve 01 --submit 1`
cargo solve <day> --submit <part>

Run All Solutions

# alternative: `cargo all --release`
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

Benchmark Solutions

# example: `cargo time 8 --store`
cargo time <day> [--all] [--store]

# output:
# Day 08
# ------
# Part 1: 1 (39.0ns @ 10000 samples)
# Part 2: 2 (39.0ns @ 10000 samples)
#
# Total (Run): 0.00ms
#
# Stored updated benchmarks.

Read Puzzle Description

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

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

Scaffold, Download, and Read Current Day

# example: `cargo today` on December 1st
cargo today

# 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.
# [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".
#
# Loaded session cookie from "/Users/<snip>/.adventofcode.session".
# Fetching puzzle for day 1, 2022...
# ...the input...

Run Tests

cargo test

Run Formatter

cargo fmt

Run Linter

cargo clippy

Run Profiler

# example: `cargo solve 1 --dhat`
cargo solve <day> --dhat

About

Solutions for Advent of Code 2024 in Rust πŸ¦€πŸ‘¨β€πŸ’»πŸŽ„

Topics

Resources

License

Stars

Watchers

Forks

Languages