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>) {
|
||||
for previous_position in moves.values() {
|
||||
elves.remove(previous_position);
|
||||
}
|
||||
|
||||
for new_position in moves.keys() {
|
||||
elves.insert(*new_position);
|
||||
for (to, from) in moves.iter() {
|
||||
elves.remove(from);
|
||||
elves.insert(*to);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue