From e32002c0c5156325c1f469103f663f63fef81309 Mon Sep 17 00:00:00 2001 From: Florent DENEF Date: Fri, 9 Dec 2022 16:10:13 +0100 Subject: [PATCH] Commit edited manually. --- src/prob4/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/prob4/mod.rs b/src/prob4/mod.rs index 42d5816..6219ab8 100644 --- a/src/prob4/mod.rs +++ b/src/prob4/mod.rs @@ -1,9 +1,9 @@ -fn mutual_inclusion(first_pair: &[u32], second_pair: &[u32]) -> bool { +pub fn mutual_inclusion(first_pair: &[u32], second_pair: &[u32]) -> bool { (first_pair[0] <= second_pair[0] && first_pair[1] >= second_pair[1]) || (second_pair[0] <= first_pair[0] && second_pair[1] >= first_pair[1]) } -pub fn solve_part1(file_path: &str) -> i32 { +pub fn solve(file_path: &str, unary_operator: &dyn Fn(&[u32], &[u32]) -> bool) -> i32 { std::fs::read_to_string(file_path) .expect("Please provide a text file as an argument.") .lines() @@ -29,7 +29,7 @@ pub fn solve_part1(file_path: &str) -> i32 { .expect("Parsing number in first pair failed") }) .collect::>(); - if mutual_inclusion(&first_pair, &second_pair) { + if unary_operator(&first_pair, &second_pair) { 1 } else { 0 @@ -38,4 +38,4 @@ pub fn solve_part1(file_path: &str) -> i32 { .collect::>() .iter() .sum() -} +} \ No newline at end of file