Reputation: 2549
I am trying to take an array of strings ["-", "+", "*"]
and figure out all combinations of them for a given size. This is possible by doing the following:
arr = ["-", "+", "*"]
perms = arr.permutation(2).to_a
# => [["-", "+"], ["-", "*"], ["+", "-"], ["+", "*"], ["*", "-"], ["*", "+"]]
However, I want to get results for an array bigger than the given array. E.g., arr.permutations(4).to_arr
. Is this possible?
Upvotes: 0
Views: 86
Reputation: 16331
No, not through any built in library or statistical method.
The Combination and Permutation methods implement standard probability theory functions. That is, "A things taken B at a time." You cannot create combinations or permutations using these standard methods to take more "things" than you actually have in the set.
Upvotes: 0