From 03fd24f9309193aaaf007e08fa4bf07c83a3a8c1 Mon Sep 17 00:00:00 2001 From: JonOfUs Date: Fri, 6 Dec 2024 15:30:11 +0100 Subject: [PATCH] Solve some warnings --- src/days/d02.rs | 6 +++--- src/days/d03.rs | 1 - src/days/d06.rs | 7 ++----- src/main.rs | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/days/d02.rs b/src/days/d02.rs index 77c7931..dd60f5a 100644 --- a/src/days/d02.rs +++ b/src/days/d02.rs @@ -44,15 +44,15 @@ pub fn solve() { let result = reports .iter() .filter(|r| { - if safe(r.clone().to_vec(), false) { + if safe((*r).clone().to_vec(), false) { return true; } - let mut r2 = r.clone().to_vec(); + let mut r2 = (*r).clone().to_vec(); r2.remove(0); if safe(r2, true) { return true; } - let mut r3 = r.clone().to_vec(); + let mut r3 = (*r).clone().to_vec(); r3.remove(1); safe(r3, true) }) diff --git a/src/days/d03.rs b/src/days/d03.rs index ea849b4..c4b865b 100644 --- a/src/days/d03.rs +++ b/src/days/d03.rs @@ -6,7 +6,6 @@ pub fn solve() { let contents = fs::read_to_string(path).expect("Something went wrong reading the file"); - let re = Regex::new(r"mul\((\d{1,3}),(\d{1,3})\)").unwrap(); let mults = get_mults(contents.as_str()); let result = mults.iter().map(|(a, b)| a * b).sum::(); diff --git a/src/days/d06.rs b/src/days/d06.rs index 9865ce3..c72aed0 100644 --- a/src/days/d06.rs +++ b/src/days/d06.rs @@ -3,9 +3,7 @@ use std::{ fs, }; -use rayon::iter::{ - IndexedParallelIterator, IntoParallelRefIterator, ParallelBridge, ParallelIterator, -}; +use rayon::iter::{ParallelBridge, ParallelIterator}; pub fn solve() { let path = "res/06/input"; @@ -67,8 +65,6 @@ pub fn solve() { let result: usize = guard_positions.len(); println!("Result 1: {}", result); - let mut obstacle_positions: HashSet<(isize, isize)> = HashSet::new(); - let obstacle_positions: Vec> = map .iter() .enumerate() @@ -76,6 +72,7 @@ pub fn solve() { .map(|(i, row)| { row.iter() .enumerate() + .par_bridge() .filter(|(j, cell)| { if !*cell && (i as isize, *j as isize) != init_pos { let mut new_map = map.clone(); diff --git a/src/main.rs b/src/main.rs index 64d1cf9..5622a0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ extern crate scan_fmt; use std::time::Instant; fn main() { - //days::d03::solve() + //days::d06::solve() _all_days() }