Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Scrabble word arrangements with blank tiles

by Moriarty (Abbot)
on Nov 14, 2005 at 06:14 UTC ( #508221=note: print w/ replies, xml ) Need Help??


in reply to Re: Scrabble word arrangements with blank tiles
in thread Scrabble word arrangements with blank tiles

The more I think about it, the more I think I've got it completely wrong, but then, I think the OPs figure are also wrong

Looking at the simplest of the OPs figures, 2 tiles where one is blank, there must be at least 76 unique combinations ('A' | blank, 'A' + blank and blank + 'A' where bank can't equal 'A') so I can't see how the OP came up with their figures.

I haven't come up with a formula to match this premise as yet, but I'm sure my original formula is totally wrong. I would like some clarification from the OP before I try to figure out the correct formula.


Comment on Re^2: Scrabble word arrangements with blank tiles
Re^3: Scrabble word arrangements with blank tiles
by Anonymous Monk on Nov 14, 2005 at 09:13 UTC
    To clarify the problem, assume we are trying to arrange 7 tiles that already have been chosen.
    ABCDEFG generates 7! = 5,040 unique permutations
    ABCDEF? generates 115,920 unique permutations and not 6!*26=18,720
    ABCDE?? <-- This is the stumper!

    The keyword is "unique" permutations.

    For example, permuting ABC? where ? represents a blank tile A..Z results in 624 arrangements but only 588 are unique permutations. Duplicate arrangements like AABC AABC AACB AACB ABAC ABAC ABBC ABBC ... must be culled to get the unique set.

    Algorithm-Loops has a neat permute function which I used to check racks with one blank tile.
    It generates the unique permutations that I am looking for.
    Here is an example for a simple rack AB?:

    use strict; use Algorithm::Loops qw( NextPermute );

    my @list= sort ('A'..'B'); # Find unique permutations for AB? my $cnt; my @list1;

    # $l represents one blank tile cycling thru all letter values for my $l ('A'..'Z') {

    @list1 = sort(@list,$l); # Very important to sort print"@list1\n"; # Show what's happening

      do {

    printf"%5d. ", ++$cnt; print"@list1\n"; # Display permutations } while( NextPermute( @list1 ) ); }

    print"Counted $cnt unique permutations"; print $/;

    prints:

    A A B 1. A A B 2. A B A 3. B A A A B B 4. A B B 5. B A B 6. B B A A B C 7. A B C 8. A C B 9. B A C 10. B C A 11. C A B 12. C B A A B D 13. A B D 14. A D B 15. B A D 16. B D A 17. D A B 18. D B A ... ... ... Counted 150 unique permutations

    Any suggestions on how to code this for 2 blank tiles without getting "Out of memory" failure?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://508221]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-08-23 21:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls