Remove slow day 9 solution

This commit is contained in:
Daniel S. 2020-12-17 03:08:28 +01:00
parent 8d6bd53e85
commit 7acfca5132

View file

@ -37,22 +37,7 @@ pub fn solve_part1(input: &Vec<usize>) -> usize {
panic!("No match found!"); panic!("No match found!");
} }
#[aoc(day9, part2, bruteforce)] #[aoc(day9, part2)]
#[inline(always)]
pub fn solve_part2(input: &Vec<usize>) -> usize {
let inv_num = solve_part1(input);
for start in 0..input.len() {
for length in 2..(input.len() - start) {
let s: Vec<usize> = input.iter().skip(start).take(length).cloned().collect();
if s.iter().sum::<usize>() == inv_num {
return s.iter().max().unwrap() + s.iter().min().unwrap();
}
}
}
panic!("No match found!");
}
#[aoc(day9, part2, faster)]
#[inline(always)] #[inline(always)]
pub fn solve_part2_fast(input: &Vec<usize>) -> usize { pub fn solve_part2_fast(input: &Vec<usize>) -> usize {
let target_num = solve_part1(input); let target_num = solve_part1(input);