silkfire Posted February 17, 2012 Share Posted February 17, 2012 I searched online and seen some complex c and c# code which I didn't understand much of. But how do I generate an array with all string combinations based on length and from a charset? E.g. charset = {'a', 'b', 'c'} Length = 2. Then it should generate first all 1-char strings: a b c Then all 2-char strings: aa ab ac ba bb bc ca cb cc And then all added to the same array. I think there's some way of doing it with recursion but to me it's like thinking with a 4th dimension my mind can't grasp this logic! Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 17, 2012 Share Posted February 17, 2012 There have been numerous posts on this forum in the past for similar things. But, if you are planning to do this with anything more than a small subset of characters and character count it is not realistic. The permutations will expand exponentially. Here are a few related posts: http://www.phpfreaks.com/forums/index.php?topic=346630.0 http://www.phpfreaks.com/forums/index.php?topic=298656.0 http://www.phpfreaks.com/forums/index.php?topic=135633.0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.