Advent of Code 2022 Solutions (in Rust)

Overview

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 their solutions in Rust. Follow the instructions below to get started!

Setup

Prerequisites

If you don't already have Rust installed, you'll want to install it here. Otherwise, the only things you'll need are a terminal/shell and a text editor (I recommend Helix if you're shopping for a new one).

Clobbering my Solutions (For Your Integrity!)

To get started, you'll want to fork this repository and then delete any of my solutions I've submitted so far to keep yourself from being spoiled:

rm src/day*.rs

Also, in the src/main.rs file, you'll need to delete all mod dayN; declarations and use dayN::DayN; statements, as well as reset the get_day_solution implementation to the following:

fn get_day_solution(day: usize, lines: impl Iterator<Item = String>) -> Box<dyn DaySolution> {
    match day {
        // 1 => Box::new(Day1::from_lines(input)),
        _other => panic!("Day hasn't been solved yet"),
    }
}

Now you're ready to go!. You'll want to log in to Advent of Code so that you can download inputs automatically.

Logging In to Advent of Code

Go to the Advent of Code site and log in at the top of the page. Once you're signed in, you should open the Developer Tools and head to the "Network" tab, and then reload the page. Look through your requests until you find one that has your "session" cookie. Copy the contents of that cookie (the alphanumeric string after the equals sign) sans quotes to a file called .session in this repository. Now you're ready to download inputs from the terminal!

Note: the .session file is .gitignored, so you don't accidentally upload your login token to GitHub.

Setting Up For a Day

The prep-day.sh script in the root of this repository will download your input using curl to a .gitignored .input directory and then copy a boilerplate module to src/dayN.rs, so you can start working (almost) right away! Here's how to run it:

sh prep-day.sh <day>

Just remember to update main.rs with the suggestions printed by the prep-day.sh script to ensure that you can run your solutions.

Running

To run your solutions for a day, run the following in the repo:

cargo run <day>

You should see something like the following:

❯ cargo run 1
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/aoc-2022 1`
Solving day 1...
Part 1: <solution> (0.000100000 seconds)
Part 2: <solution> (0.000300000 seconds)

Questions

If you have any issues getting this up and running, you can make an issue on GitHub, email me at [email protected] or ping me on Discord at Smores#6844; I'm happy to help anyone that gets stuck. Good luck learning Rust for those of you picking it up, and enjoy the gift of pulling your hair out puzzle solving for the holiday season!

You might also like...
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

Advent of Code 2022 - in Rust!

Advent of Code 2022 My solutions to problems in 2022 edition of Advent of Code, written in Rust. How to use this repo: The best way to see how solutio

🎄 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

Advent of Code 2022 - my answers

Advent of Code 2022 my answers Development occurs in language-specific directories: Haskell Kotlin Python Rust Day1.hs Day1.kt day1.py day1.rs Day2.hs

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

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

🎄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

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

Owner
Sam Mohr
Sam Mohr
🦀 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 ⭐

Felix Spöttel 10 Dec 28, 2022
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

Axel Lindeberg 32 Jan 5, 2023
🎄 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
My Advent of Code 2022 solutions, in Rust.

AoC 2022 My solutions for the 2022 edition of Advent of Code in Rust. Simply run cargo run --release --bin dayXX to solve. Some days require z3, insta

Orson Peters 6 Jan 26, 2023
🎄 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
Solutions to Advent of Code 2022 puzzles

Solutions to Advent of Code 2022 puzzles

null 3 Dec 15, 2022
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

Kirk Haines 4 Dec 31, 2022
Advent of Code 2022 (Rust)

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

Dominik Harmim 2 Dec 15, 2022
Advent of Code 2022 in Rust 🦀

Advent of Code 2022 in Rust ??

Philippe Bouamriou 3 Dec 2, 2022
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

Luke Taylor 6 Dec 15, 2022