Day 1, 2 and 3
This commit is contained in:
commit
129c9f85a0
1
day1/.gitignore
vendored
Normal file
1
day1/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
7
day1/Cargo.lock
generated
Normal file
7
day1/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aoc1"
|
||||
version = "0.1.0"
|
8
day1/Cargo.toml
Normal file
8
day1/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "aoc1"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
2248
day1/input.txt
Normal file
2248
day1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
91
day1/src/main.rs
Normal file
91
day1/src/main.rs
Normal file
@ -0,0 +1,91 @@
|
||||
#![feature(test)]
|
||||
|
||||
use std::{collections::BinaryHeap, fs::read_to_string};
|
||||
|
||||
fn main() {
|
||||
let input = read_to_string("input.txt").expect("need input file");
|
||||
let (max, top3) = initial(&input);
|
||||
println!("{max}, {top3}");
|
||||
let (max, top3) = idiomatic(&input);
|
||||
println!("{max}, {top3}");
|
||||
}
|
||||
|
||||
fn idiomatic(input: &str) -> (u32, u32) {
|
||||
let mut sums: BinaryHeap<_> = input
|
||||
.split_terminator("\n\n")
|
||||
.map(|block| {
|
||||
block
|
||||
.split_terminator('\n')
|
||||
.map(|line| line.parse::<u32>().unwrap_or_default())
|
||||
.sum()
|
||||
})
|
||||
.collect();
|
||||
let max = sums.pop().unwrap_or_default();
|
||||
let top3 = max + sums.pop().unwrap_or_default() + sums.pop().unwrap_or_default();
|
||||
(max, top3)
|
||||
}
|
||||
|
||||
fn initial(input: &str) -> (u32, u32) {
|
||||
let numbers = input.split_terminator('\n').map(|s| s.parse::<u32>().ok());
|
||||
let mut elves = vec![0];
|
||||
for number in numbers {
|
||||
match number {
|
||||
Some(ration) => {
|
||||
*elves.last_mut().unwrap() += ration;
|
||||
}
|
||||
None => elves.push(0),
|
||||
}
|
||||
}
|
||||
let (index, max) = elves.iter().enumerate().max_by_key(|(_, v)| **v).unwrap();
|
||||
let mut elves = elves.clone();
|
||||
elves.remove(index);
|
||||
let (index, second) = elves.iter().enumerate().max_by_key(|(_, v)| **v).unwrap();
|
||||
let mut elves = elves.clone();
|
||||
elves.remove(index);
|
||||
let third = elves.iter().max().unwrap();
|
||||
let top3 = max + second + third;
|
||||
(*max, top3)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{BufRead, BufReader},
|
||||
};
|
||||
|
||||
use super::*;
|
||||
extern crate test;
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
fn bench_initial(b: &mut Bencher) {
|
||||
let input = read_to_string("input.txt").expect("need input file");
|
||||
b.iter(|| initial(&input));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_idiomatic(b: &mut Bencher) {
|
||||
let input = read_to_string("input.txt").expect("need input file");
|
||||
b.iter(|| idiomatic(&input));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_read_string(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
read_to_string("input.txt")
|
||||
.unwrap()
|
||||
.split_terminator('\n')
|
||||
.for_each(drop);
|
||||
});
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_lines(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
BufReader::new(File::open("input.txt").unwrap())
|
||||
.lines()
|
||||
.for_each(drop);
|
||||
});
|
||||
}
|
||||
}
|
1
day10/.gitignore
vendored
Normal file
1
day10/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day10/Cargo.toml
Normal file
8
day10/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day10"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day10/src/main.rs
Normal file
3
day10/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day11/.gitignore
vendored
Normal file
1
day11/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day11/Cargo.toml
Normal file
8
day11/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day11"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day11/src/main.rs
Normal file
3
day11/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day12/.gitignore
vendored
Normal file
1
day12/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day12/Cargo.toml
Normal file
8
day12/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day12"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day12/src/main.rs
Normal file
3
day12/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day13/.gitignore
vendored
Normal file
1
day13/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day13/Cargo.toml
Normal file
8
day13/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day13"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day13/src/main.rs
Normal file
3
day13/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day14/.gitignore
vendored
Normal file
1
day14/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day14/Cargo.toml
Normal file
8
day14/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day14"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day14/src/main.rs
Normal file
3
day14/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day15/.gitignore
vendored
Normal file
1
day15/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day15/Cargo.toml
Normal file
8
day15/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day15"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day15/src/main.rs
Normal file
3
day15/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day16/.gitignore
vendored
Normal file
1
day16/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day16/Cargo.toml
Normal file
8
day16/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day16"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day16/src/main.rs
Normal file
3
day16/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day17/.gitignore
vendored
Normal file
1
day17/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day17/Cargo.toml
Normal file
8
day17/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day17"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day17/src/main.rs
Normal file
3
day17/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day18/.gitignore
vendored
Normal file
1
day18/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day18/Cargo.toml
Normal file
8
day18/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day18"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day18/src/main.rs
Normal file
3
day18/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day19/.gitignore
vendored
Normal file
1
day19/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day19/Cargo.toml
Normal file
8
day19/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day19"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day19/src/main.rs
Normal file
3
day19/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day2/.gitignore
vendored
Normal file
1
day2/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
7
day2/Cargo.lock
generated
Normal file
7
day2/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "day2"
|
||||
version = "0.1.0"
|
8
day2/Cargo.toml
Normal file
8
day2/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day2"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
2500
day2/input.txt
Normal file
2500
day2/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
117
day2/src/main.rs
Normal file
117
day2/src/main.rs
Normal file
@ -0,0 +1,117 @@
|
||||
use std::fs::read_to_string;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
enum Symbol {
|
||||
Rock,
|
||||
Paper,
|
||||
Scissors,
|
||||
}
|
||||
|
||||
impl From<char> for Symbol {
|
||||
fn from(value: char) -> Self {
|
||||
match value {
|
||||
'A' => Self::Rock,
|
||||
'B' => Self::Paper,
|
||||
'C' => Self::Scissors,
|
||||
'X' => Self::Rock,
|
||||
'Y' => Self::Paper,
|
||||
'Z' => Self::Scissors,
|
||||
_ => panic!("invalid input"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
enum Outcome {
|
||||
Win,
|
||||
Draw,
|
||||
Lose,
|
||||
}
|
||||
|
||||
impl From<char> for Outcome {
|
||||
fn from(value: char) -> Self {
|
||||
match value {
|
||||
'X' => Self::Lose,
|
||||
'Y' => Self::Draw,
|
||||
'Z' => Self::Win,
|
||||
_ => panic!("invalid input"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Symbol {
|
||||
fn play(self, opponent: Self) -> Outcome {
|
||||
if self == opponent {
|
||||
Outcome::Draw
|
||||
} else if (self == Self::Rock && opponent == Self::Scissors)
|
||||
|| (self == Self::Paper && opponent == Self::Rock)
|
||||
|| (self == Self::Scissors && opponent == Self::Paper)
|
||||
{
|
||||
Outcome::Win
|
||||
} else {
|
||||
Outcome::Lose
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn score(play: Symbol, result: Outcome) -> u32 {
|
||||
let score = match play {
|
||||
Symbol::Rock => 1,
|
||||
Symbol::Paper => 2,
|
||||
Symbol::Scissors => 3,
|
||||
};
|
||||
let score2 = match result {
|
||||
Outcome::Lose => 0,
|
||||
Outcome::Draw => 3,
|
||||
Outcome::Win => 6,
|
||||
};
|
||||
score + score2
|
||||
}
|
||||
|
||||
fn get_play(opponent: Symbol, outcome: Outcome) -> Symbol {
|
||||
match outcome {
|
||||
Outcome::Win => match opponent {
|
||||
Symbol::Rock => Symbol::Paper,
|
||||
Symbol::Paper => Symbol::Scissors,
|
||||
Symbol::Scissors => Symbol::Rock,
|
||||
},
|
||||
Outcome::Draw => opponent,
|
||||
Outcome::Lose => match opponent {
|
||||
Symbol::Rock => Symbol::Scissors,
|
||||
Symbol::Paper => Symbol::Rock,
|
||||
Symbol::Scissors => Symbol::Paper,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn initial(input: &str) -> (u32, u32) {
|
||||
let first = input
|
||||
.split_terminator('\n')
|
||||
.map(|line| {
|
||||
line.split_whitespace()
|
||||
.map(|s| Symbol::from(s.chars().next().unwrap()))
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.map(|p| score(p[1], p[1].play(p[0])))
|
||||
.sum();
|
||||
let second = input
|
||||
.split_terminator('\n')
|
||||
.map(|line| {
|
||||
let chars: Vec<_> = line
|
||||
.split_whitespace()
|
||||
.map(|s| s.chars().next().unwrap())
|
||||
.collect();
|
||||
let opponent = Symbol::from(chars[0]);
|
||||
let outcome = Outcome::from(chars[1]);
|
||||
let play = get_play(opponent, outcome);
|
||||
score(play, outcome)
|
||||
})
|
||||
.sum();
|
||||
(first, second)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let input = read_to_string("input.txt").expect("input needed");
|
||||
let score = initial(&input);
|
||||
println!("score: {score:?}");
|
||||
}
|
1
day20/.gitignore
vendored
Normal file
1
day20/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day20/Cargo.toml
Normal file
8
day20/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day20"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day20/src/main.rs
Normal file
3
day20/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day21/.gitignore
vendored
Normal file
1
day21/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day21/Cargo.toml
Normal file
8
day21/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day21"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day21/src/main.rs
Normal file
3
day21/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day22/.gitignore
vendored
Normal file
1
day22/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day22/Cargo.toml
Normal file
8
day22/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day22"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day22/src/main.rs
Normal file
3
day22/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day23/.gitignore
vendored
Normal file
1
day23/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day23/Cargo.toml
Normal file
8
day23/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day23"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day23/src/main.rs
Normal file
3
day23/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day24/.gitignore
vendored
Normal file
1
day24/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day24/Cargo.toml
Normal file
8
day24/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day24"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day24/src/main.rs
Normal file
3
day24/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day25/.gitignore
vendored
Normal file
1
day25/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day25/Cargo.toml
Normal file
8
day25/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day25"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day25/src/main.rs
Normal file
3
day25/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day3/.gitignore
vendored
Normal file
1
day3/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
243
day3/Cargo.lock
generated
Normal file
243
day3/Cargo.lock
generated
Normal file
@ -0,0 +1,243 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "color-eyre"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"color-spantrace",
|
||||
"eyre",
|
||||
"indenter",
|
||||
"once_cell",
|
||||
"owo-colors",
|
||||
"tracing-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color-spantrace"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"owo-colors",
|
||||
"tracing-core",
|
||||
"tracing-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "day3"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"color-eyre",
|
||||
"itertools",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
|
||||
|
||||
[[package]]
|
||||
name = "eyre"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb"
|
||||
dependencies = [
|
||||
"indenter",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.26.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d"
|
||||
|
||||
[[package]]
|
||||
name = "indenter"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.138"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
|
||||
dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
|
||||
|
||||
[[package]]
|
||||
name = "owo-colors"
|
||||
version = "3.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"pin-project-lite",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-error"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e"
|
||||
dependencies = [
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
|
||||
dependencies = [
|
||||
"sharded-slab",
|
||||
"thread_local",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "valuable"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
10
day3/Cargo.toml
Normal file
10
day3/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "day3"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
color-eyre = "0.6.2"
|
||||
itertools = "0.10.5"
|
300
day3/input.txt
Normal file
300
day3/input.txt
Normal file
@ -0,0 +1,300 @@
|
||||
DMwrszrfMzSSCpLpfCCn
|
||||
RMvhZhQqlvhMvRtbvbcPclPlncddppLTdppd
|
||||
tVMQhFtjjWmsFJsmsW
|
||||
trRtvNhfJhSzzSTFVhQQZQhHGphP
|
||||
CnLMBWLwDMgMcwwdngdHGPVTQGpTHZdGPGpd
|
||||
LLDqcDgwqCMnLWqtvzrzbbtJqPjJ
|
||||
wQQwHNQLmbWQbQRHwHNFBbwqPfjqlzRMGRqzpSfvPlzplM
|
||||
nCtGCZZtsGsrtDMZpfMpSlMlvlZq
|
||||
cJctJC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FCgBLFLFzFtsQRCd
|
||||
NpMJHpnMrDpJGTHqTTmJHTPjfcvbWfrffVzvZfVWSbjz
|
||||
wFwpqWwwpqwtqqrbCFtptDmCcfNhNRzRBZRRJRChVNBZBJ
|
||||
svlvjHsQlvdlvMLdlvPSSLtzzczcNhJthfNtRcNMJNMc
|
||||
HvvPLSHjgltjsvqwbbnmWmDpgwTT
|
||||
zhCmPVwwChdCBtsWnNWswBWr
|
||||
GJJSfSgFpjJjGgpfpgrcNNstvnBHNnHLtFHr
|
||||
jgDTfjpMgZMGMGJTMMJRhzZPCzbhVlPqdNCbhd
|
||||
bDbQQmVDRpDNbRQlfQQZnfwTlllfsT
|
||||
FChzzBWhVzrgMwffJwlnngnTlJ
|
||||
MCvqvhFzcHCChjtpNNVLppGmbq
|
||||
bZZzJnccqdzcLhrcQDLrDs
|
||||
FfCfWVfjWTFClClfwjWCfGGwhZSDhSLsSSRpZprLph
|
||||
mFmTMmFjMMWFfZtttflWjmWTngNHJHggJJHtzgnJvBtBgHdv
|
6
day3/input.txt.test
Normal file
6
day3/input.txt.test
Normal file
@ -0,0 +1,6 @@
|
||||
vJrwpWtwJgWrhcsFMMfFFhFp
|
||||
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
|
||||
PmmdzqPrVvPwwTWBwg
|
||||
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
|
||||
ttgJtRGJQctTZtZT
|
||||
CrZsJsPPZsGzwwsLwLmpwMDw
|
47
day3/src/main.rs
Normal file
47
day3/src/main.rs
Normal file
@ -0,0 +1,47 @@
|
||||
use std::{collections::HashSet, fs::read_to_string};
|
||||
|
||||
use color_eyre::{eyre::*, Result};
|
||||
use itertools::Itertools;
|
||||
|
||||
fn priority(item: &char) -> usize {
|
||||
('a'..='z')
|
||||
.position(|c| *item == c)
|
||||
.map(|i| i + 1)
|
||||
.or_else(|| ('A'..='Z').position(|c| *item == c).map(|i| i + 27))
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
fn initial(input: &str) -> (usize, usize) {
|
||||
let output1 = input
|
||||
.lines()
|
||||
.map(|line| {
|
||||
let (compartment1, compartment2) = line.split_at(line.len() / 2);
|
||||
let compartment1 = compartment1.chars().collect::<HashSet<_>>();
|
||||
let compartment2 = compartment2.chars().collect::<HashSet<_>>();
|
||||
compartment1
|
||||
.intersection(&compartment2)
|
||||
.map(priority)
|
||||
.sum::<usize>()
|
||||
})
|
||||
.sum();
|
||||
let output2 = input
|
||||
.lines()
|
||||
.chunks(3)
|
||||
.into_iter()
|
||||
.map(|group| {
|
||||
group
|
||||
.map(|line| line.chars().collect::<HashSet<_>>())
|
||||
.coalesce(|a, b| Ok(a.intersection(&b).copied().collect()))
|
||||
.map(|set| set.iter().map(priority).sum::<usize>())
|
||||
.sum::<usize>()
|
||||
})
|
||||
.sum();
|
||||
(output1, output2)
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let input = read_to_string("input.txt").wrap_err("reading input.txt")?;
|
||||
let output = initial(&input);
|
||||
println!("output: {output:?}");
|
||||
Ok(())
|
||||
}
|
1
day4/.gitignore
vendored
Normal file
1
day4/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day4/Cargo.toml
Normal file
8
day4/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day4"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day4/src/main.rs
Normal file
3
day4/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day5/.gitignore
vendored
Normal file
1
day5/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day5/Cargo.toml
Normal file
8
day5/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day5"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day5/src/main.rs
Normal file
3
day5/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day6/.gitignore
vendored
Normal file
1
day6/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day6/Cargo.toml
Normal file
8
day6/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day6"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day6/src/main.rs
Normal file
3
day6/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day7/.gitignore
vendored
Normal file
1
day7/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day7/Cargo.toml
Normal file
8
day7/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day7"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day7/src/main.rs
Normal file
3
day7/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day8/.gitignore
vendored
Normal file
1
day8/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day8/Cargo.toml
Normal file
8
day8/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day8"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day8/src/main.rs
Normal file
3
day8/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
1
day9/.gitignore
vendored
Normal file
1
day9/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
8
day9/Cargo.toml
Normal file
8
day9/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "day9"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
3
day9/src/main.rs
Normal file
3
day9/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
Loading…
Reference in New Issue
Block a user