Skip to content

Commit

Permalink
Merge pull request #641 from Marcos-cat/choose
Browse files Browse the repository at this point in the history
ensure that tuples returns an integer
  • Loading branch information
kaikalii authored Dec 30, 2024
2 parents 4a4abf6 + 692fa00 commit a7e5534
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/algorithm/tuples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ fn combinations(n: usize, k: usize, same: bool) -> f64 {
let calc_n = if same { n + k - 1 } else { n };
(1..=k.min(calc_n - k))
.map(|i| (calc_n + 1 - i) as f64 / i as f64)
.product()
.product::<f64>()
.round()
}

fn permutations(n: usize, k: usize) -> f64 {
Expand Down
1 change: 1 addition & 0 deletions tests/optimized.ua
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ F ← ⬚10(/+◌1⊞(ׯ))
⍤⤙≍ ⊃⧅≥⧅(∘≥) 3 4
⍤⤙≍ ⊃⧅≠⧅(∘≠) 3 5
⍤⤙≍ ⊃⧅<⧅(∘<) 3 5
⍤⤙≍ ⊃⧅<⧅(∘<) 6 12
⍤⤙≍ ⊃⧅≤⧅(∘≤) 3 5
⍤⤙≍ ⊃⧅>⧅(∘>) 3 5
⍤⤙≍ ⊃⧅≥⧅(∘≥) 3 5
Expand Down

0 comments on commit a7e5534

Please sign in to comment.