working 15part2, but slower

This commit is contained in:
foosinn 2020-06-03 23:20:36 +02:00
parent f2ad6c7ad8
commit 84fce2b379

View file

@ -52,6 +52,7 @@ impl Map {
fn walk(&mut self, start: &XY, computer: &intcode::Computer, steps: usize) -> Option<usize> {
let steps = steps + 1;
let mut result = None;
for dir in 1..=4 {
let direction = Direction::from(dir);
let xy = start.add((&direction).into());
@ -66,17 +67,17 @@ impl Map {
match status {
Status::HitWall => (),
Status::MoveComplete => match self.walk(&xy, &computer, steps) {
Some(i) => return Some(i + 1),
Some(i) => result = Some(i + 1),
None => (),
},
Status::Finished => return Some(1),
Status::Finished => result = Some(1),
_ => unreachable!("unknown status"),
}
} else {
unreachable!("computer unexpectedly halted");
}
}
None
result
}
fn fill(&mut self) -> usize {