Quick'n dirty macro set for advent of code 2021

Related tags

Command-line aoc2021
Overview

AOC quick'n dirty macro set

Those are implemented using quick'n dirty procedural macros and libraries.

Running the program

Use cargo run --release -- [OPTIONS].

Options are:

  • --day N (or -d N): run day N instead of the current day of month
  • --all (or -a): run all days
  • --input FILE (or -i FILE): use a specific input file instead of input/dayN.txt
  • --timing (or -t): include timing information

Functions

Add a module for every day in src/lib.rs. Modules must contain functions such as (here src/day1.rs):

#[aoc(day1, part1)]
fn part1(input: &[u32]) -> usize {
    input.windows(2).filter(|v| v[1] > v[0]).count()
}

#[aoc(day1, part2)]
fn part2(input: &[u32]) -> usize {
    input.windows(4).filter(|v| v[3] > v[0]).count()
}

Alternate versions are also supported:

#[aoc(day1, part2, alternate_version)]
fn part2_alternate_version(input: &[u32]) -> usize {
    use itertools::Itertools;
    part1(
        &input
            .iter()
            .tuple_windows()
            .map(|(a, b, c)| a + b + c)
            .collect::<Vec<_>>(),
    )
}

Arguments

Functions arguments can be:

  • nothing
  • &str: the content of the input file;
  • &[u8]: the content of the input file;
  • &[T] where T: FromStr: the content of each line of the input file parsed through FromStr::from_str().

Return value

The return value must implement Display and can be wrapped in a Result (the string Result< is looked up to detect this).

You might also like...
Advent of Code 2021, in rust this year

Advent of Code 2021 🎄 Solutions for the 2021 edition of Advent of Code. This year, I try to do this in Rust 🦀 . I discover the language, so do not t

My solutions for Advent of Code 2021, in Rust

Advent of Code 2021 These are my solutions. I have decided to use Rust for now. I'm new to Rust, so it might be some of the worst Rust code you've see

My solution for the advent of code 2021, mainly written in Rust

Advent-of-Code-2021 My solution for the advent of code 2021, written in Rust Error Handle NOPE!!! unwrap() everything everywhere Use To run all of the

My solutions for the 2021 edition of the Advent of Code, using Rust and SOM (Simple Object Machine)

Advent of Code 2021 These are my solutions for the 2021 edition of the Advent of Code. The solutions are all implemented using both Rust and SOM (Simp

Solutions to Advent of Code 2021, coded in rust

Advent of Code 2021 (aoc-2021-rust) Solutions to Advent of Code 2021 (https://adventofcode.com/2021), coded as part of my efforts to learn Rust Run co

Soluciones a los retos del Advent of Code 2021.

Advent of Code 2021 Soluciones a Advent of Code 2021. Repos de otros miembros de AoC Canarias: Ricardo Cárdenes Víctor Ruiz José Rodríguez Juan Ignaci

☃️ Learning Rust with AoC 2021 🎄https://adventofcode.com/2021/

🎄 Andrei's 2021 Advent of Code 🎄 Learning Goals Rust basics (vectors, arrays, math, etc.) Rust basic CLI Rust linear algebra and ndarrays (e.g., htt

Rust-advent - Learning Rust by solving advent of code challenges (Streaming live on Twitch every Monday)
Rust-advent - Learning Rust by solving advent of code challenges (Streaming live on Twitch every Monday)

Rust advent 🦀 🐚 Learning Rust by implementing solutions for Advent of Code problems. 🎥 HEY, we are live-streaming our attempts to solve the exercis

Quick & Dirty cli to process mysql dumps

mysql2databend Quick & Dirtyl CLI to process mysql dumps and clean them so they can be ingested in Databend using a regular MySQL client. Features: re

Owner
Samuel Tardieu
Samuel Tardieu
Advent of Code 2021 puzzles & solutions in Rust

Advent of Code 2021 These are puzzles for the Advent of Code 2021 challenge, written and solved in the Rust programming language. The puzzle for each

Chevy Ray Johnston 8 Dec 19, 2021
Repository with my Advent of Code 2021 puzzle solutions 🎄

?? Advent of Code 2021 ?? I decided to stick with Rust this year and try to improve a bit on it, I basically haven't used it since last year's AoC, so

fratorgano 2 Dec 1, 2022
Advent of Code 2021 (Rust)

aoc-2021 Advent of Code 2021 with Rust. To build and run the project This project uses cargo-aoc. More detailed instructions can be found at that proj

Belén Albeza 13 Dec 23, 2021
Advent of Code 2021, also an attempt to practice a bit of Rust.

Advent of Code 2021 Advent of Code 2021 (my first one!), also an attempt to practice a bit of Rust. Running (Assuming that the respective inputs are i

Edoardo Debenedetti 1 Dec 3, 2021
My solutions to Advent of Code 2021 (mostly in rust)

Advent of Code 2021 Small code to solve problems at https://adventofcode.com/2021. Most of the code are written in Rust. How to run solutions For exam

“Plane” Abhabongse  Janthong 3 Apr 22, 2022
Learning Rust through Advent of Code 2021 - probably not very clean!

AoC 2021 ======== I'm using AoC2021 as an excuse to learn Rust (and maybe some other languages). Please do *not* use this repository as a good source

Andrew Zhu 0 Dec 8, 2021
🦀 Advent of Code 2021

Advent of Code 2021 License Licensed under either of Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) MIT li

Vitaly Domnikov 2 Dec 10, 2021
Advent of Code - 2021

Advent of Code - 2021 Solutions to the Advent of Code 2021 written in Rust using cargo-aoc. Instructions Install cargo-aoc with cargo install cargo-ao

Tim Oram 2 Dec 17, 2021
🎄My Advent of Code 2021 solutions in the Rust programming language

Advent of Code 2021 in Rust My Advent of Code 2021 solutions in the Rust programming language. This repository holds a separate Rust project for each

Tim Visée 227 Dec 16, 2022
My solutions for the Advent of Code 2021 in Scala, Python, Haskell and Rust.

Advent of Code 2021 These are my Advent of Code 2021 solutions written in Scala 3, Haskell, Python and Rust. Day Title L1 L2 L3 L4 01 Sonar Sweep Scal

Axel Suárez 2 Oct 14, 2022