Skip to content
/ aoc-rs Public

My attempt at using Rust to solve Advent of Code puzzles

Notifications You must be signed in to change notification settings

1npo/aoc-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. Create src/puzzles/yearYYYY/dayN.rs
  2. Add pub mod dayN; to src/puzzles/yearYYYY/mod.rs
  3. Add solutions.insert((2024, DAY, PART), Box::new(yearYYYY::dayN::partN)); to get_puzzle_solution() in src/puzzles/mod.rs
  4. Implement the input parsing for the day's puzzle in yearYYYY::dayN::parse()
  5. Implement the solutions for parts 1 and 2 in yearYYYY::dayN::part1() and yearYYYY::dayN::part2() respectively

Adding a New Year

  1. Create src/puzzles/yearYYYY
  2. Create src/puzzles/yearYYYY/mod.rs
  3. 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 :)

About

My attempt at using Rust to solve Advent of Code puzzles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages