1
0
Fork 0

day(23): refactor execution

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2023-07-02 23:12:54 +02:00
parent b49833f6f5
commit ff519603f6
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -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);
} }
} }