Welcome to the Monastery  
PerlMonks 
Re^6: Challenge: 8 Letters, Most Wordsby LanX (Chancellor) 
on Oct 05, 2013 at 13:19 UTC ( #1057028=note: print w/replies, xml )  Need Help?? 
> In other words, choose all combinations of any 8 chars out of the following string: "aaaabbbcccddddeeeeffffgggghhhiiijjkkkllllmmmnnnnoooopppqrrrrssssstttuuuuvvwwwxxyyyzzzz" The point is to handle duplications, if all letters are unique the answer is simply (26 over 8)
Reasoning is simple, it calculates all binary vectors of length 26 with exactly 8 1bits. But with duplications its more complicated, e.g. 4 out of "aabcd" is not (5 over 4)=5
cause the first 2 solutions are identical. Generating all combinations and filtering the unique once is normally not very clever, cause the overhead can be enormous.
And I'm stuck finding a formula which calculates all unique solutions, but generating is easier, just don't allow bitvectors with "gaps" between identical letters: so
I will update this post with a loop generating all possibilities soon.
updateindeed L~R's number of 12461993 possibilities is correct The following (nonoptimized) code took 3 minutes to calculate them:
Cheers Rolf ( addicted to the Perl Programming Language)
In Section
Seekers of Perl Wisdom

