Skip to content

Commit a7e5534

Browse files
authored
Merge pull request #641 from Marcos-cat/choose
ensure that tuples returns an integer
2 parents 4a4abf6 + 692fa00 commit a7e5534

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/algorithm/tuples.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ fn combinations(n: usize, k: usize, same: bool) -> f64 {
268268
let calc_n = if same { n + k - 1 } else { n };
269269
(1..=k.min(calc_n - k))
270270
.map(|i| (calc_n + 1 - i) as f64 / i as f64)
271-
.product()
271+
.product::<f64>()
272+
.round()
272273
}
273274

274275
fn permutations(n: usize, k: usize) -> f64 {

tests/optimized.ua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ F ← ⬚10(/+◌1⊞(ׯ))
241241
⍤⤙≍ ⊃⧅≥⧅(∘≥) 3 4
242242
⍤⤙≍ ⊃⧅≠⧅(∘≠) 3 5
243243
⍤⤙≍ ⊃⧅<⧅(∘<) 3 5
244+
⍤⤙≍ ⊃⧅<⧅(∘<) 6 12
244245
⍤⤙≍ ⊃⧅≤⧅(∘≤) 3 5
245246
⍤⤙≍ ⊃⧅>⧅(∘>) 3 5
246247
⍤⤙≍ ⊃⧅≥⧅(∘≥) 3 5

0 commit comments

Comments
 (0)