Git Product home page Git Product logo

advent-of-code-2022's Introduction

🎄 Advent of Code 2022

Solutions for Advent of Code in Rust.

All solutions marked with ⭐ run in under 1ms in release mode (on my machine, your experience may vary). Solutions marked ✨ take longer than that.

Day Part 1 Part 2
Day 1
Day 2
Day 3
Day 4
Day 5
Day 6
Day 7
Day 8
Day 9
Day 10
Day 11 ✨ 1.1 ms
Day 12 ✨ 24 ms ✨ 22 ms
Day 13
Day 14 ✨ 2.9 ms
Day 15 ✨ 20 ms
Day 16
Day 17
Day 18 ✨ 1.9 ms
Day 19
Day 20 ✨ 40 ms ✨ 645 ms
Day 21 ✨ 25 ms
Day 22
Day 23 ✨ 4.8 ms ✨ 575 ms
Day 24
Day 25 ✨ 12 ms

Usage

Scaffold a day

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

# output:
# Created module "src/bin/01.rs"
# Created empty input file "src/inputs/01.txt"
# Created empty example file "src/examples/01.txt"
# ---
# 🎄 Type `cargo solve 01` to run your solution.

Individual solutions live in the ./src/bin/ directory as separate binaries.

Every solution has unit tests referencing its example file. I yse these unit tests to develop and debug my solution against the example input.

Download input for a day

Note
This command requires installing the aoc-cli crate.

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

# output:
# Downloading input with aoc-cli...
# Loaded session cookie from "/home/felix/.adventofcode.session".
# Downloading input for day 1, 2022...
# Saving puzzle input to "/tmp/tmp.MBdcAdL9Iw/input"...
# Done!
# ---
# 🎄 Successfully wrote input to "src/inputs/01.txt"!

To download inputs for previous years, append the --year/-y flag. (example: cargo download 1 --year 2020)

Puzzle inputs are not checked into git. Reasoning.

Run solutions for a day

# example: `cargo solve 01`
cargo solve <day>

# output:
#     Running `target/debug/01`
# 🎄 Part 1 🎄
#
# 6 (elapsed: 37.03µs)
#
# 🎄 Part 2 🎄
#
# 9 (elapsed: 33.18µs)

solve is an alias for cargo run --bin. To run an optimized version for benchmarking, append the --release flag.

Displayed timings show the raw execution time of the solution without overhead (e.g. file reads).

Run all solutions

cargo all

# output:
#     Running `target/release/advent_of_code`
# ----------
# | Day 01 |
# ----------
# 🎄 Part 1 🎄
#
# 0 (elapsed: 170.00µs)
#
# 🎄 Part 2 🎄
#
# 0 (elapsed: 30.00µs)
# <...other days...>
# Total: 0.20ms

all is an alias for cargo run. To run an optimized version for benchmarking, use the --release flag.

Total timing is computed from individual solution timings and excludes as much overhead as possible.

Run all solutions against the example input

cargo test

To run tests for a specific day, append --bin <day>, e.g. cargo test --bin 01. You can further scope it down to a specific part, e.g. cargo test --bin 01 part_one.

Format code

cargo fmt

Lint code

cargo clippy

advent-of-code-2022's People

Contributors

jakuj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.