WIP making it work.
This commit is contained in:
parent
5117d318ee
commit
88549528a8
@ -28,4 +28,9 @@ fn main() {
|
||||
let max_part1 = prob4::solve(file_path, &prob4::mutual_inclusion);
|
||||
println!("Solution for problem 4 part 1: {max_part1}");
|
||||
}
|
||||
{
|
||||
let file_path = "prob4_part1.txt";
|
||||
let max_part1 = prob4::solve(file_path, &prob4::complete_overlap);
|
||||
println!("Solution for problem 4 part 2: {max_part1}");
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,10 @@ pub fn mutual_inclusion(first_pair: &[u32], second_pair: &[u32]) -> bool {
|
||||
|| (second_pair[0] <= first_pair[0] && second_pair[1] >= first_pair[1])
|
||||
}
|
||||
|
||||
pub fn complete_overlap(first_pair: &[u32], second_pair: &[u32]) -> bool {
|
||||
(second_pair[0] <= first_pair[0] && first_pair[0] <= second_pair[1]) || (second_pair[0] <= first_pair[1] && first_pair[1] <= second_pair[1])
|
||||
}
|
||||
|
||||
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.")
|
||||
|
Loading…
Reference in New Issue
Block a user