- or download this
use strict;
use Algorithm::Loops qw( NextPermute );
- or download this
my @list= sort ('A'..'B'); # Find unique permutations for AB?
my $cnt;
my @list1;
- or download this
# $l represents one blank tile cycling thru all letter values
for my $l ('A'..'Z') {
- or download this
@list1 = sort(@list,$l); # Very important to sort
print"@list1\n"; # Show what's happening
- or download this
printf"%5d. ", ++$cnt;
print"@list1\n"; # Display permutations
} while( NextPermute( @list1 ) );
}
- or download this
print"Counted $cnt unique permutations";
print $/;
- or download this
A A B
1. A A B
2. A B A
...
...
...
Counted 150 unique permutations