Skip to content

Commit

Permalink
git
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrogs committed Oct 1, 2024
1 parent 50041e1 commit d5fdacf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/iter/combinations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ where
let k = indices.as_mut().len();
let total = checked_binomial(n, k).expect(OVERFLOW_MSG);
match offset.cmp(&total) {
Ordering::Less => {
Ordering::Equal => {
unrank(indices.as_mut(), offset - 1, n);
Self {
indices,
n,
position: IndicesPosition::End,
}
}
Ordering::Equal => {
Ordering::Less => {
unrank(indices.as_mut(), offset, n);
Self {
indices,
Expand Down Expand Up @@ -549,6 +549,8 @@ fn decrement_indices(indices: &mut [usize], n: usize) {

// Decrement index, and reset the ones to its right
indices[i] -= 1;
for (j, index) in indices.iter_mut().enumerate().skip(i + 1) {
*index = n - k + j;
for (j, index) in indices.iter_mut().enumerate().skip(i + 1) {
*index = n - k + j;
}
Expand Down

0 comments on commit d5fdacf

Please sign in to comment.