From cf6303a5bc1558ebdb7b467da38f74cd3ac3a9b1 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 5 Dec 2022 19:46:06 +0100 Subject: Add 2022 --- day6/Cargo.toml | 8 -------- day6/input.txt | 1 - day6/src/main.rs | 36 ------------------------------------ 3 files changed, 45 deletions(-) delete mode 100644 day6/Cargo.toml delete mode 100644 day6/input.txt delete mode 100644 day6/src/main.rs (limited to 'day6') diff --git a/day6/Cargo.toml b/day6/Cargo.toml deleted file mode 100644 index 89d04ae..0000000 --- a/day6/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[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] diff --git a/day6/input.txt b/day6/input.txt deleted file mode 100644 index de918c7..0000000 --- a/day6/input.txt +++ /dev/null @@ -1 +0,0 @@ -1,1,3,5,1,1,1,4,1,5,1,1,1,1,1,1,1,3,1,1,1,1,2,5,1,1,1,1,1,2,1,4,1,4,1,1,1,1,1,3,1,1,5,1,1,1,4,1,1,1,4,1,1,3,5,1,1,1,1,4,1,5,4,1,1,2,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,1,1,1,1,1,2,2,1,1,1,1,1,5,1,1,1,3,4,1,1,1,1,3,1,1,1,1,1,4,1,1,3,1,1,3,1,1,1,1,1,3,1,5,2,3,1,2,3,1,1,2,1,2,4,5,1,5,1,4,1,1,1,1,2,1,5,1,1,1,1,1,5,1,1,3,1,1,1,1,1,1,4,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,2,1,1,1,1,2,2,1,2,1,1,1,5,5,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,1,4,2,1,4,1,1,1,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,5,1,1,1,1,1,1,1,1,3,1,1,3,3,1,1,1,3,5,1,1,4,1,1,1,1,1,4,1,1,3,1,1,1,1,1,1,1,1,2,1,5,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1 diff --git a/day6/src/main.rs b/day6/src/main.rs deleted file mode 100644 index 46a148c..0000000 --- a/day6/src/main.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::fs::File; -use std::io::{BufRead, BufReader}; - -fn main() -> std::io::Result<()> { - let file = File::open("input.txt")?; - let mut reader = BufReader::new(file); - let mut buffer = String::new(); - - reader.read_line(&mut buffer)?; - - let mut lanternfishes: Vec<_> = buffer - .trim() - .split(',') - .map(|x| x.parse::().unwrap()) - .collect::>(); - - for _ in 0..80 { - let mut n = 0; - for lanternfish in lanternfishes.iter_mut() { - if *lanternfish == 0 { - *lanternfish = 6; - n += 1; - } else { - *lanternfish -= 1; - } - } - - for _ in 0..n { - lanternfishes.push(8); - } - } - - println!("{}", lanternfishes.len()); - - Ok(()) -} -- cgit v1.2.3-18-g5258