Skip to content

Commit

Permalink
Fixed edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecardleitao authored and jorgecarleitao committed Jan 28, 2024
1 parent 937e7ac commit a404a66
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/legs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ pub fn all_legs(mut positions: impl Iterator<Item = Position>) -> Vec<Leg> {
sequence.push(position.clone());
}
if landed(&prev_position, &position) {
legs.push(Leg {
positions: std::mem::take(&mut sequence),
});
if !sequence.is_empty() {
legs.push(Leg {
positions: std::mem::take(&mut sequence),
});
}
}
prev_position = position;
});
Expand Down

0 comments on commit a404a66

Please sign in to comment.