in reply to Re^2: 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

I'm not sure what you mean by duplicate items. List::Permutor uses each element of the list and doesn't discard duplicates, which is probably what the original poster wants. If that's not the case and he wants only unique letters, a quick filter discards duplicates before he gets started.

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review
  • Comment on Re^3: scrambling all letters in a word until all combinations are found (duplicates)

Replies are listed 'Best First'.
Re^4: scrambling all letters in a word until all combinations are found (duplicates)
by pKai (Priest) on Jan 23, 2006 at 22:22 UTC

    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"; }