rust(day09): Optimize further
This commit is contained in:
parent
a84c3e49f5
commit
ff1d3a67e5
|
@ -381,16 +381,20 @@ mod day09 {
|
|||
use std::time::{Duration, Instant};
|
||||
|
||||
fn part1(numbers: &[usize]) -> usize {
|
||||
'outer: for (i, &n) in numbers.iter().enumerate().skip(COUNT) {
|
||||
'outer: for i in COUNT..numbers.len() {
|
||||
for x in i - COUNT..i {
|
||||
if numbers[x] > numbers[i] {
|
||||
continue;
|
||||
}
|
||||
|
||||
for y in x + 1..i {
|
||||
if numbers[x] + numbers[y] == n {
|
||||
if numbers[x] + numbers[y] == numbers[i] {
|
||||
continue 'outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
return numbers[i];
|
||||
}
|
||||
|
||||
panic!();
|
||||
|
|
Loading…
Reference in New Issue