diff --git a/rs/Cargo.lock b/rs/Cargo.lock index 5031871..119551d 100644 --- a/rs/Cargo.lock +++ b/rs/Cargo.lock @@ -6,16 +6,9 @@ version = 3 name = "advent-of-code" version = "0.1.0" dependencies = [ - "anyhow", "clap", ] -[[package]] -name = "anyhow" -version = "1.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" - [[package]] name = "bitflags" version = "1.3.2" diff --git a/rs/Cargo.toml b/rs/Cargo.toml index c8c3d54..f1d4a91 100644 --- a/rs/Cargo.toml +++ b/rs/Cargo.toml @@ -3,8 +3,5 @@ name = "advent-of-code" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -anyhow = "1.0.66" clap = { version = "4.0.29", features = ["derive", "deprecated"] } diff --git a/rs/src/main.rs b/rs/src/main.rs index 31c01c4..86d53e6 100644 --- a/rs/src/main.rs +++ b/rs/src/main.rs @@ -2,7 +2,7 @@ mod y2022; use std::path::{Path, PathBuf}; use std::str::FromStr; -use std::{fmt, fs}; +use std::{fmt, fs, io}; use clap::Parser; @@ -47,7 +47,7 @@ struct Args { files: Vec, } -fn main() -> anyhow::Result<()> { +fn main() -> io::Result<()> { let args = Args::parse(); if args.files.is_empty() { @@ -72,9 +72,9 @@ fn main() -> anyhow::Result<()> { println!("### Solving day {day}"); let input = fs::read_to_string(file)?; match day { - Day::Y2022D01 => y2022::d01::solve(input)?, - Day::Y2022D02 => y2022::d02::solve(input)?, - Day::Y2022D03 => y2022::d03::solve(input)?, + Day::Y2022D01 => y2022::d01::solve(input), + Day::Y2022D02 => y2022::d02::solve(input), + Day::Y2022D03 => y2022::d03::solve(input), } } diff --git a/rs/src/y2022/d01.rs b/rs/src/y2022/d01.rs index f5b2d33..cd08361 100644 --- a/rs/src/y2022/d01.rs +++ b/rs/src/y2022/d01.rs @@ -1,4 +1,4 @@ -pub fn solve(input: String) -> anyhow::Result<()> { +pub fn solve(input: String) { let mut elves = input .trim() .split("\n\n") @@ -18,6 +18,4 @@ pub fn solve(input: String) -> anyhow::Result<()> { // Part 2 let top_three = elves.iter().rev().take(3).sum::(); println!("Part 2: {top_three}"); - - Ok(()) } diff --git a/rs/src/y2022/d02.rs b/rs/src/y2022/d02.rs index f563b1c..21a58da 100644 --- a/rs/src/y2022/d02.rs +++ b/rs/src/y2022/d02.rs @@ -70,7 +70,7 @@ fn read_round(line: &str) -> (Choice, Choice, Outcome) { (l, rc, ro) } -pub fn solve(input: String) -> anyhow::Result<()> { +pub fn solve(input: String) { let matches = input .lines() .map(|l| read_round(l.trim())) @@ -89,6 +89,4 @@ pub fn solve(input: String) -> anyhow::Result<()> { .map(|(l, _, r)| r.against(*l).score() + r.score()) .sum::(); println!("Part 2: {score}"); - - Ok(()) } diff --git a/rs/src/y2022/d03.rs b/rs/src/y2022/d03.rs index 32614d2..f666c58 100644 --- a/rs/src/y2022/d03.rs +++ b/rs/src/y2022/d03.rs @@ -15,7 +15,7 @@ fn highest_score(i: u64) -> u32 { 64 - i.leading_zeros() } -pub fn solve(input: String) -> anyhow::Result<()> { +pub fn solve(input: String) { let backpacks = input.lines().map(|l| l.trim()).collect::>(); // Part 1 @@ -40,6 +40,4 @@ pub fn solve(input: String) -> anyhow::Result<()> { .map(highest_score) .sum::(); println!("Part 2: {score}"); - - Ok(()) }