Skip to content

Commit

Permalink
faster ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieupoumeyrolsonos authored and kali committed Apr 11, 2024
1 parent 18217f6 commit 4a83533
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions core/src/model/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,11 @@ where
.iter()
.filter(|n| !ups[*n].iter().any(|up| todo.contains(*up)))
.min_by_key(|&candidate| {
let mut state = todo.clone();
state.remove(candidate);
state
.iter()
todo.iter()
.filter(|it| *it != candidate)
.flat_map(|down| ups[down].iter().copied())
.filter(|up| !state.contains(*up))
.sorted()
.dedup()
.filter(|up| *up == candidate || !todo.contains(*up))
.unique()
.map(|n| costs[n])
.sum::<usize>()
})
Expand Down

0 comments on commit 4a83533

Please sign in to comment.