Generated from steventhorne/aoc-rust.
This template is a fork of fspoettel/advent-of-code-rust.
Template includes the following changes:
- Move
scaffoldscript to rust module for cross-platform use - Remove
downloadscript in favor of running aoc-cli directly (download script is not cross-platform)- TODO: Make rust script as
downloadreplacement
- TODO: Make rust script as
- Open ☝️ template on Github.
- Click
Use this templateand create your repository. - Clone the repository to your machine.
- Install the Rust toolchain.
- (optional) Install rust-analyzer for your editor.
- (optional) Install a native debugger, e.g. CodeLLDB for VS Code.
- (optional) Install
aoc-cliand follow their setup guide to use thedownloadscript for puzzle inputs. (see below) - (optional) Setup the README stars github action. (see below)
# example: `cargo run --bin scaffold -- -d 1`
cargo run --bin scaffold -- -d <day> [-i]
Optional `-i` arg will create the input file as well.
# output:
# Created input file for day 01
# Created example file for day 01
# Created module file for day 01
# ---
# 🎄 Type `cargo run --bin 01` to run your solution.Individual solutions live in the ./src/bin directory as separate binaries.
Every solution has unit tests referencing the example file. Use these tests to develop and debug your solution. When editing a solution, rust-analyzer will display buttons for these actions above the unit tests.
Puzzle inputs are not checked into git. See here why.
# example: `cargo run --bin 01`
cargo run --bin <day>
# output:
# Running `target/debug/01`
# 🎄 Part 1 🎄
#
# 6 (elapsed: 37.03µs)
#
# 🎄 Part 2 🎄
#
# 9 (elapsed: 33.18µs)To run an optimized version for benchmarking, use the --release flag or the alias cargo rr --bin <day>.
Displayed timings show the raw execution time of your solution w/o overhead (e.g. file reads).
cargo run
# output:
# Running `target/release/aoc`
# ----------
# | Day 01 |
# ----------
# 🎄 Part 1 🎄
#
# 0 (elapsed: 170.00µs)
#
# 🎄 Part 2 🎄
#
# 0 (elapsed: 30.00µs)
# <...other days...>
# Total: 0.20msTo run an optimized version for benchmarking, use the --release flag or the alias cargo rr.
Total timing is computed from individual solution timings and excludes overhead.
cargo testcargo fmtcargo clippyThis template includes a Github action that automatically updates the readme with your advent of code progress.
To enable it, you need to do two things:
- set repository secrets.
- create a private leaderboard.
Go to the Secrets tab in your repository settings and create the following secrets:
AOC_USER_ID: Go to this page and copy your user id. It's the number behind the#symbol in the first name option. Example:3031AOC_YEAR: the year you want to track. Example:2021AOC_SESSION: an active session for the advent of code website. To get this, press F12 anywhere on the Advent of Code website to open your browser developer tools. Look in your Cookies under the Application or Storage tab, and copy out thesessioncookie.
Go to the leaderboard page of the year you want to track and click Private Leaderboard. If you have not created a leaderboard yet, create one by clicking Create It. Your leaderboard should be accessible under https://adventofcode.com/{year}/leaderboard/private/view/{aoc_user_id}.
