diff --git a/src/day1.rs b/src/day1.rs index 3ea16c7..f82dcfc 100644 --- a/src/day1.rs +++ b/src/day1.rs @@ -1,6 +1,4 @@ use aoc_runner_derive::aoc; -use std::io::{BufRead, BufReader, Lines}; -use std::time::{Duration, Instant}; // PROBLEM 1 solution #[aoc(day1, part1)] @@ -16,7 +14,7 @@ pub fn part1(input: &str) -> u64 { let add_val = match sign.as_bytes()[0] { b'R' => num_val, b'L' => mod_val - (num_val % mod_val), - c => panic!("Invalid direction {}", c), + c => panic!("Invalid direction {c}"), }; val = (val + add_val) % mod_val; if val == 0 { @@ -65,7 +63,7 @@ pub fn part2(input: &str) -> i64 { let (new_val, add_pass) = match sign.as_bytes()[0] { b'R' => advance::<100>(val, num_val), b'L' => advance::<100>(val, -num_val), - c => panic!("Invalid direction {}", c), + c => panic!("Invalid direction {c}"), }; val = new_val; pass += add_pass; @@ -77,7 +75,7 @@ pub fn part2(input: &str) -> i64 { mod tests { use crate::day1::*; - const EXAMPLE: &str = &"L68 + const EXAMPLE: &str = "L68 L30 R48 L5 diff --git a/src/day2.rs b/src/day2.rs index b3510d7..75ce09f 100644 --- a/src/day2.rs +++ b/src/day2.rs @@ -1,6 +1,5 @@ use aoc_runner_derive::{aoc, aoc_generator}; use itertools::Itertools; -use std::cmp::{max, min}; use std::ops::RangeInclusive; #[aoc_generator(day2)] diff --git a/src/lib.rs b/src/lib.rs index ce5ab10..a228b5c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ +mod day1; mod day2; -pub mod day1; use aoc_runner_derive::aoc_lib; diff --git a/utils/grid/lib.rs b/utils/grid/lib.rs index ba73c4f..67f810c 100644 --- a/utils/grid/lib.rs +++ b/utils/grid/lib.rs @@ -321,7 +321,13 @@ impl Grid { self.data .iter() .enumerate() - .find_map(|(pos, val)| if val == haystack { Some(pos as i64) } else { None }) + .find_map(|(pos, val)| { + if val == haystack { + Some(pos as i64) + } else { + None + } + }) .unwrap_or(-1), ) } @@ -330,7 +336,10 @@ impl Grid { } pub fn forward_slice(&self, start: &C, len: i64) -> Option<&[T]> { - let pos = (self.valid_pos(start), self.valid_pos(&(start.x() + len - 1, start.y()))); + let pos = ( + self.valid_pos(start), + self.valid_pos(&(start.x() + len - 1, start.y())), + ); match pos { (Some(pos1), Some(pos2)) => Some(&self.data[pos1..pos2 + 1]), _ => None, @@ -406,7 +415,10 @@ impl Display for Grid { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { for y in 0..self.height() { for x in 0..self.width() { - f.write_fmt(format_args!("{}", *self.get(&(x as i64, y as i64)).unwrap() as char))?; + f.write_fmt(format_args!( + "{}", + *self.get(&(x as i64, y as i64)).unwrap() as char + ))?; } f.write_char('\n')?; }