Algorithm to return all combinations of k elements from n

Posted by IQue on Stack Overflow See other posts from Stack Overflow or by IQue
Published on 2008-09-24T15:02:24Z Indexed on 2010/03/13 13:15 UTC
Read the original article Hit count: 444

Filed under:
|

I want to write a function that takes an array of letters as an argument and a number of those letters to select.

Say you provide an array of 8 letters and want to select 3 letters from that. Then you should get:

8! / ((8 - 3)! * 3!) = 56

Arrays (or words) in return consisting of 3 letters each.

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about combinations