https://adventofcode.com/2022/

Related tags

Command-line aoc2022
Overview

Advent of Code 2022

This repository contains my solutions for Advent of Code 2022.

Goal is readable, simple and mostly clean.

Each day is solved in it's dedicated file in the src/bin directory.

Only a few well-known dependencies are used:

  • anyhow for easy and simple error handling, in all the files.
  • regex is used in a few files for easy parsing.
  • serde and serde_json are used in day 13 for easy parsing.

About my writing of these files

I am an experienced rust developer. I use rust since 2014 (so before rust 1.0). You may know me for structopt or keyberon. I like to use iterators, the ? operator and prefer (a bit too much) short names to comments.

I have solved these problems by doing some "dirty" things (as .clone() abuse, copy and paste, unreadable mess, damn slow algorithm running during lunch). Then I have cleaned them, and sometime improved them. They all run in less than 2 seconds in release on my computer.

All these programs should solve any problem from the official site, except day 22 (the cube folding is hardcoded for my instance).

Days

In this section, I make a few remarks on the different days. I will suppose you have already read the instructions on the official site.

Day 1

This implementation use a BinaryHeap.

Day 2

This implementation use a lot rust "plain enum", and implement the TryFrom on them. It also externalize the preprocessing of the input in a function returning an (somethat) impl Iterator.

Day 3

This implementation use HashSets and the let else new (at the time of writing) feature.

Day 4

Using the somethat recent TryFrom<&[T]> for [T; N] implementation. Also using function as argument to mutualize part 1 and part 2.

Day 5

impl FromStr for Move to use line.parse() in the code.

Day 6

A very simple implementation (but not optimal) thanks to windows and iterators.

Day 7

Elegant and simple recursion with a closure as visitor. Also, readable parsing using pattern matching on a slice.

Day 8

Genericity by using iterators as function argument.

Day 9

Using RangeInclusive::contains and pattern matching on Ordering.

Day 10

Nothing really special. Part 2 must be "decoded" by eye.

Day 11

Some closure wrapped in Arc<dyn Fn>.

Day 12

A very compact BFS implementation thanks to VecDeque, Extend and returning impl Iterator.

Day 13

The parsing is done using serde_json and serde with #[serde(untagged)]. If you want a hand-written parser, you can search in the history.

The custom comparison method is implemented as Ord. It is done simply and without allocation thanks to std::slice::from_ref and the Ord implementation of a slice.

Day 14

A small macro to mutualize some code with break and continue.

Day 15

Using RangeInclusive as intervals, and regex for parsing.

You might also like...
My solutions for Advent of Code 2022, written in Rust

Template largely copied from RikvanToor/aoc-rust-template, upgraded for clap v4. This template can be forked/cloned from beeb/aoc-rust. Usage First, f

Advent of Code 2022 in Rust ๐Ÿฆ€

Advent of Code 2022 in Rust ๐Ÿฆ€

  ๐Ÿฆ€ Rust solutions for Advent of Code 2022
๐Ÿฆ€ Rust solutions for Advent of Code 2022

๐ŸŽ„ Advent of Code 2022 Solutions for Advent of Code in Rust. 2022 Results Day Part 1 Part 2 Day 1 โญ โญ Day 2 โญ โญ Day 3 โญ โญ Day 4 โญ โญ Day 5 โญ โญ Day 6 โญ

My try at Advent of Code 2022 in Rust.

Advent of Code 2022 My solutions to Advent of Code 2022, written in Rust. I love seeing the variety of solution other people come up with, so I decide

Solutions to Advent of Code 2022 in Rust ย ๐Ÿฆ€

AdventOfCode2022 ๐ŸŽ„ Solutions to AoC 2022 in Rust ๐Ÿฆ€ Usage cargo run --release --bin DAY # run a specific day cargo run --release # run all

๐ŸŽ„ Advent of Code written in various languages. (2015-2022)

๐ŸŽ„ Advent of Code This repository contains my solutions to the Advent of Code puzzles. Every year, I will try to solve the puzzles in a different lang

Trying to solve Advent of Code 2022 in 25 different languages (1 day = 1 language)

Advent of Code 2022: 15/25 langs Iโ€™ll try to solve this Advent of Code using different language for each day. Any programs needed to run the code will

Here are my Advent of Code solutions for 2022.

advent-of-code-2022 This repository contains my Advent of Code solutions for 2022. I am doing them in Ruby, Crystal, and Rust, and as I release each d

I will be attempting Advent of Code 2022 with Rust, a language I have never learned before.

Advent of Code 2022 This year, I will be attempting Advent of Code with Rust, a language I have never learned before. I will also be taking some notes

Owner
Guillaume P.
Guillaume P.
๐ŸŽ„ My Advent of Code solutions in Rust. http://adventofcode.com/2022

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

Tim Visรฉe 98 Jan 4, 2023
โ˜ƒ๏ธ 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

Andrei Bรขrsan 1 Feb 2, 2022
Code and Development environment for adventofcode.com - 2021 edition

aoc-2021 Warning Spoiler Alert! If you want to solve the aoc problems on your own, do not read any further. This repository contains solutions for the

docToolchain 11 Oct 22, 2022
Repository for solving adventofcode.com puzzles

Advent Of Code ?? This is a repository for any Otovista that wants to participate in the advent of code christmas calendar challenges. Advent of Code

Otovo 4 Dec 20, 2022
INFCON 2022 - Rust ํฌ๋กœ์Šค ํ”Œ๋žซํผ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฐœํ‘œ ์ž๋ฃŒ ๋ฐ ์˜ˆ์ œ ์ฝ”๋“œ

2022-INFCON-Rust-CrossPlatform INFCON 2022 - Rust ํฌ๋กœ์Šค ํ”Œ๋žซํผ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฐœํ‘œ ์ž๋ฃŒ ๋ฐ ์˜ˆ์ œ ์ฝ”๋“œ Contents Presentation Supplement Example Core library rust-cross rust-cr

Chris Ohk 50 Dec 29, 2022
An awesome CLI tool for effectively learning Rust and more. Project winner of the RustFi 2022 hackathon

rlrn An awesome CLI tool for effectively learning Rust and more Table of Contents About The Project Built With Getting Started Prerequisites Installat

Victor Kostyuk 6 Dec 25, 2022
๐ŸŽ„ My solutions to Advent of Code 2022.

?? advent-of-code-2022 Overview This repository contains my solutions to Advent of Code 2022. I decided to take this year as an opportunity to learn R

Vighnesh Shenoy 3 Dec 15, 2022
Advent of Code 2022 (Rust)

Advent of Code 2022 ?? | -+- A /=\ /\ /\ ___ _ __ _ __ __ __ i/ O \i / \/

Dominik Harmim 2 Dec 15, 2022
Solutions to Advent of Code 2022 puzzles

Solutions to Advent of Code 2022 puzzles

null 3 Dec 15, 2022
Advent of Code 2022 Solutions (in Rust)

Advent of Code 2022 My solutions for Advent of Code 2022, written in Rust. This repository provides a good template for anyone interested in writing t

Sam Mohr 3 Dec 2, 2022