7 releases (4 breaking)
new 0.5.1 | Dec 3, 2024 |
---|---|
0.5.0 | Dec 3, 2024 |
0.4.1 | Dec 2, 2024 |
0.3.0 | Dec 2, 2024 |
0.1.0 | Dec 2, 2024 |
#987 in Command line utilities
18KB
349 lines
aoc-rs
This is my attempt at using Rust to build an Advent of Code puzzle solver. It's also my attempt to learn Rust!
Install
cargo install aoc-rs-1npo
Usage
aoc-rs <COMMAND> <YEAR> <DAY> <PART>
The first three arguments are required, PART
defaults to 1 if absent.
There are 2 commands: solve
and submit
.
Use the solve
command to print the solution to the screen.
For example:
aoc-rs solve 2024 1 1
[2024-12-03T01:29:14Z INFO aoc_rs_1npo::web] Got puzzle input from cached file
[2024-12-03T01:29:14Z INFO aoc_rs_1npo::puzzles] Got puzzle input for year 2024 day 1
[2024-12-03T01:29:14Z INFO aoc_rs_1npo::puzzles] Solution for part 1 = "1651298"
Use the submit
command to submit the solution as an answer to adventofcode.com.
For example:
aoc-rs submit 2024 1 2
[2024-12-03T01:35:46Z INFO aoc_rs_1npo::web] Got puzzle input from cached file
[2024-12-03T01:35:46Z INFO aoc_rs_1npo::puzzles] Got puzzle input for year 2024 day 1
[2024-12-03T01:35:46Z INFO aoc_rs_1npo::puzzles] Solution for part 2 = "21306195"
[2024-12-03T01:35:46Z INFO aoc_rs_1npo::puzzles] Puzzle solved! Great job!
Developer Guide
Adding Solutions for New Days
Replace DAY
, PART
, YYYY
, and N
with the appropriate values
- Create
src/puzzles/yearYYYY/dayN.rs
- Add
pub mod dayN;
tosrc/puzzles/yearYYYY/mod.rs
- Add
solutions.insert((2024, DAY, PART), Box::new(yearYYYY::dayN::partN));
toget_puzzle_solution()
insrc/puzzles/mod.rs
- Implement the input parsing for the day's puzzle in
yearYYYY::dayN::parse()
- Implement the solutions for parts 1 and 2 in
yearYYYY::dayN::part1()
andyearYYYY::dayN::part2()
respectively
Adding a New Year
- Create
src/puzzles/yearYYYY
- Create
src/puzzles/yearYYYY/mod.rs
- Follow the steps above to create
dayN.rs
files for the year
Acknowledgements
Thanks to Nir for his dayN.rs
template and his file caching code :)
Dependencies
~9–39MB
~611K SLoC