ruby - Get all possible permutations of bigger array -


i trying take array of strings ["-", "+", "*"] , figure out combinations of them given size. possible doing following:

arr = ["-", "+", "*"] perms = arr.permutation(2).to_a # => [["-", "+"], ["-", "*"], ["+", "-"], ["+", "*"], ["*", "-"], ["*", "+"]] 

however, want results array bigger given array. e.g., arr.permutations(4).to_arr. possible?

yes, it's possible.

perms = arr.repeated_permutation(4).to_a 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -