Well that's not a perl question, but maybe you are wise to come here nonetheless because perl (and perlmonks) is good at this type of thing. Math isn't my core thing but I like the challenge of seeing how much information I can sieve by googling around. I was able to figure out, from browsing the "see also" section at permutations at mathworld, that for the general case (ie, letters can repeat) you have a multinomial aka multiset problem. So, I concentrated on googling for scrabble multiset and scrabble multinomial.

Now here's my attempt to answer your two questions. I think I got it right but... well, I've been known to bang the hammer on my thumb so it wouldn't hurt to double check my logic.

Permutations of 7 distinct letters out of a set of 26 = P(26,7)=(26!)/(26-7)!

Permutations of 6 distinct letters and one blank out of a set of 26 letters and 1 blank = P(26,6) * C(7,1) * 26 = P(26,6) * 7! / (1!*(7-6)! ) * 26

General formula, with 26 letters, b blanks (maximum 7), and in the rack 7-b distinct letters and b blanks: P(26,7-b) * C(7,b) * 26^b. With no blanks, this reduces to the "permutations of 7 distinct letters" above, and with all blanks this is P(26,0)*C(7,7) * 26^7 = 26^7. I think this answers your first question.

Now, the situation where duplicate letters are allowed is that you have b blanks with duplicates allowed on the other 7-b letters. This is a similar situation to before, only instead of using the permutation formula P we use the multinomial coefficient, which is the number of distinct permutations in a multiset. The multinomial coefficient M(n1,n2,nk) is (n1 + n2 + ... nk)! / (n1!n2!....nk!). IE, with a rack of 5 (for simplicity) if you have 2 as and 3 bs, the number of distinct permutations is ( 2 + 3 )! / (2!3!) = 10. If instead of a and b you take any two distinct letters, the number of permutations increases to 10 * ( 26 * 25 ) = M(2,3) * P(26,2). So, for the general case of a rack of 7 with b blanks and the other 7-b letters some multiset, I think we have M(n1,n2...n sub7-b) * P(26,7-b) * C(7,b) * 26^b. If I'm right about this that answers your second question.

Perl module links that may be of interest:

Algorithm::Permute

Hope this helps... and I'll keep updating this if I figure anything more out. (Already updated several times to cull out less promising search avenues)

UPDATE: Fixed incorrect formula for adding wildcards to the distinct letter scenario.


In reply to Re: Scrabble word arrangements with blank tiles by tphyahoo
in thread Scrabble word arrangements with blank tiles by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.