Solve some warnings

This commit is contained in:
JonOfUs 2024-12-06 15:30:11 +01:00
parent 686ec4ed0e
commit 03fd24f930
4 changed files with 6 additions and 10 deletions

View file

@ -44,15 +44,15 @@ pub fn solve() {
let result = reports let result = reports
.iter() .iter()
.filter(|r| { .filter(|r| {
if safe(r.clone().to_vec(), false) { if safe((*r).clone().to_vec(), false) {
return true; return true;
} }
let mut r2 = r.clone().to_vec(); let mut r2 = (*r).clone().to_vec();
r2.remove(0); r2.remove(0);
if safe(r2, true) { if safe(r2, true) {
return true; return true;
} }
let mut r3 = r.clone().to_vec(); let mut r3 = (*r).clone().to_vec();
r3.remove(1); r3.remove(1);
safe(r3, true) safe(r3, true)
}) })

View file

@ -6,7 +6,6 @@ pub fn solve() {
let contents = fs::read_to_string(path).expect("Something went wrong reading the file"); 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 mults = get_mults(contents.as_str());
let result = mults.iter().map(|(a, b)| a * b).sum::<usize>(); let result = mults.iter().map(|(a, b)| a * b).sum::<usize>();

View file

@ -3,9 +3,7 @@ use std::{
fs, fs,
}; };
use rayon::iter::{ use rayon::iter::{ParallelBridge, ParallelIterator};
IndexedParallelIterator, IntoParallelRefIterator, ParallelBridge, ParallelIterator,
};
pub fn solve() { pub fn solve() {
let path = "res/06/input"; let path = "res/06/input";
@ -67,8 +65,6 @@ pub fn solve() {
let result: usize = guard_positions.len(); let result: usize = guard_positions.len();
println!("Result 1: {}", result); println!("Result 1: {}", result);
let mut obstacle_positions: HashSet<(isize, isize)> = HashSet::new();
let obstacle_positions: Vec<Vec<(isize, isize)>> = map let obstacle_positions: Vec<Vec<(isize, isize)>> = map
.iter() .iter()
.enumerate() .enumerate()
@ -76,6 +72,7 @@ pub fn solve() {
.map(|(i, row)| { .map(|(i, row)| {
row.iter() row.iter()
.enumerate() .enumerate()
.par_bridge()
.filter(|(j, cell)| { .filter(|(j, cell)| {
if !*cell && (i as isize, *j as isize) != init_pos { if !*cell && (i as isize, *j as isize) != init_pos {
let mut new_map = map.clone(); let mut new_map = map.clone();

View file

@ -4,7 +4,7 @@ extern crate scan_fmt;
use std::time::Instant; use std::time::Instant;
fn main() { fn main() {
//days::d03::solve() //days::d06::solve()
_all_days() _all_days()
} }