day10 part 2

This commit is contained in:
Johannes
2018-12-11 09:35:19 +01:00
parent 4eb90ac047
commit 6d4bdccc6e

View File

@@ -27,20 +27,22 @@ pub fn task1() {
// }
let mut old_area = get_area(&lights);
let mut time = 0;
loop {
time += 1;
let new_lights = lights.iter().map(|light| light.move_copy()).collect();
// print_lights(&new_lights);
let new_area = get_area(&new_lights);
// println!("Area: {} ", new_area);
if new_area > old_area {
println!("Found a minimum..");
print_lights(&lights);
break;
} else {
lights = new_lights;
old_area = new_area;
}
}
println!("Found a minimum after {} seconds", time - 1);
print_lights(&lights);
}
fn get_area(lights: &Vec<Light>) -> usize {