rust(day09): Optimize further
This commit is contained in:
parent
a84c3e49f5
commit
ff1d3a67e5
1 changed files with 7 additions and 3 deletions
|
@ -381,16 +381,20 @@ mod day09 {
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
fn part1(numbers: &[usize]) -> usize {
|
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 {
|
for x in i - COUNT..i {
|
||||||
|
if numbers[x] > numbers[i] {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for y in x + 1..i {
|
for y in x + 1..i {
|
||||||
if numbers[x] + numbers[y] == n {
|
if numbers[x] + numbers[y] == numbers[i] {
|
||||||
continue 'outer;
|
continue 'outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return numbers[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
panic!();
|
panic!();
|
||||||
|
|
Loading…
Reference in a new issue