Combinations
Posted: Wed Jan 15, 2014 8:49 am
Hello all. This is the first time I am posting on this forum - but that's only because I've always found a pertinent thread that has answered all my questions. So firstly, thank you! The forum has grown quite exhaustive since the first time I used it in 2008.
I was wondering whether there was any efficient method of calculating a string of all possible combinations of length k from a string of variables of length n. My solution would be a set of loops with nested if functions and a string that archives the combinations created and checks every new combination against that combination to see whether it already exists. However I feel that this repeated looking up of the string will not be efficient and would possibly slow the program down, so wondering whether anyone can think of an algorithm that cuts down on the number of steps while creating the string of all possible combinations. As an illustration n=50 and k=5.
Thanks a ton!
I was wondering whether there was any efficient method of calculating a string of all possible combinations of length k from a string of variables of length n. My solution would be a set of loops with nested if functions and a string that archives the combinations created and checks every new combination against that combination to see whether it already exists. However I feel that this repeated looking up of the string will not be efficient and would possibly slow the program down, so wondering whether anyone can think of an algorithm that cuts down on the number of steps while creating the string of all possible combinations. As an illustration n=50 and k=5.
Thanks a ton!