day(23): refactor execution
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
b49833f6f5
commit
ff519603f6
1 changed files with 3 additions and 6 deletions
|
@ -98,12 +98,9 @@ fn propose_moves(i: usize, elves: &Input) -> BTreeMap<Position, Position> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_moves(elves: &mut Input, moves: &BTreeMap<Position, Position>) {
|
fn execute_moves(elves: &mut Input, moves: &BTreeMap<Position, Position>) {
|
||||||
for previous_position in moves.values() {
|
for (to, from) in moves.iter() {
|
||||||
elves.remove(previous_position);
|
elves.remove(from);
|
||||||
}
|
elves.insert(*to);
|
||||||
|
|
||||||
for new_position in moves.keys() {
|
|
||||||
elves.insert(*new_position);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue