in reply to Re^3: scrambling all letters in a word until all combinations are found (duplicates)
in thread scrambling all letters in a word until all combinations are found

The duplicates tye mentions reside in the result set of a permutation effectivly operating on the (unique) index set of an array, rather than the (maybe) non-unique array members.

For an array qw(n o o n) List::Permutor will list all the 4! == 24 "solutions", of which only 6 are unique:

use strict; use warnings; use Algorithm::Loops qw(NextPermute); use List::Permutor; local $\ = $/; my @x = sort qw(n o o n); # sort required, c/f A::L docs print "Algoritm::Loops::NextPermute says"; do {print "@x"} while NextPermute @x; my $perm = new List::Permutor qw/n o o n/; print "List::Permutor says"; while (my @x = $perm->next) { print "@x"; }

Algoritm::Loops::NextPermute says n n o o n o n o n o o n o n n o o n o n o o n n List::Permutor says n o o n n o n o n o o n n o n o n n o o n n o o o n o n o n n o o o n n o o n n o n n o o n o n o n o n o n n o o o n n o o n n o n n o o n o n n n o o n n o o n o n o n o o n n o n o n o o n