Let’s do this (Advent of Code) thing again!
I’m sticking with Rust again. I still use Python when I need to hammer out something quickly, but if I want to do something correctly (and especially if I want it to be fast), you can’t beat Rust.
Let’s see how it goes!
Full solutions will once again be posted to GitHub (including previous years and possibly some I haven’t written up yet): jpverkamp/advent-of-code
As we go, this will list all posted days:
Posts in Advent of Code 2024:
- Advent of Code 2024
- AoC 2024 Day 1: Sortinator
- AoC 2024 Day 2: Safinator
- AoC 2024 Day 3: Mulinator
- AoC 2024 Day 4: Gridnator
- AoC 2024 Day 5: (Not) Transitivinator
- AoC 2024 Day 6: Wanderinator
- AoC 2024 Day 7: Mathinator
- AoC 2024 Day 8: Vectorinator
- AoC 2024 Day 9: Defraginator
- AoC 2024 Day 10: Take-a-Hikinator
- AoC 2024 Day 11: Exponential Growthinator
- AoC 2024 Day 12: Edginator
- AoC 2024 Day 13: Cramerinator
- AoC 2024 Day 14: Chaosinator
- AoC 2024 Day 15: Sokobaninator
- AoC 2024 Day 16: Astarinator
- AoC 2024 Day 17: Virtual Machininator
- AoC 2024 Day 18: Last Chancinator
- AoC 2024 Day 19: Regexinator
- AoC 2024 Day 20: Shadow Catinator
And here are my previous year’s solutions:
- Advent of Code 2015
- Advent of Code 2016
- Advent of Code 2017
- Advent of Code 2018
- Advent of Code 2021
- Advent of Code 2022
- Advent of Code 2023
I’m moving a bit this year, using the (so far) wonderful cargo-aoc library. I’d seen that in previous years, but hadn’t quite gotten around to using it. So far, it makes things really nice!
Basically, you set up cargo-aoc
:
$ cargo install cargo-aoc
$ cargo aoc credentials ...
$ cargo add aoc-runner aoc-runner-derive
# To set up a new day
$ cargo aoc --generate --day 1
# To download my input (why we had credentials)
$ cargo aoc input --day 1
# To run a given day (leave off --day 1 to run the most recent)
$ cargo aoc --day 1
# Benchmarks!
$ cargo aoc bench --day 1
All basically for free!
All we have to do is have the project with:
// == In main.rs ==
aoc_main! { lib = aoc2024 }
// == In lib.rs ==
pub mod day1;
// ...
aoc_lib!{ year = 2024 }
// == Then solutions, for example day1.rs ==
#[aoc(day1, part1, i32)]
pub fn part1(input: &str) -> i32 {
// ...
}
#[aoc(day1, part2, i32)]
pub fn part2(input: &str) -> i32 {
// ...
}
You can return anything that impl Display
, so for now numeric types are it.
Pretty cool, we’ll see if it sticks through the entire year.
At some point, I’m going to have to dig into those macros and see how they did it!