summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Games/Word.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Games/Word.pm b/lib/Games/Word.pm
index d9f4801..89610d4 100644
--- a/lib/Games/Word.pm
+++ b/lib/Games/Word.pm
@@ -2,7 +2,7 @@
package Games::Word;
require Exporter;
@ISA = qw/Exporter/;
-@EXPORT_OK = qw/random_permutation is_permutation/;
+@EXPORT_OK = qw/random_permutation is_permutation all_permutations/;
use strict;
use warnings;
@@ -36,6 +36,14 @@ sub is_permutation {
return eq_deeply(\@word_letters, bag(@perm_letters));
}
+sub all_permutations {
+ my $word = shift;
+ my @ret = ();
+ push @ret, random_permutation($word, $_)
+ for (0..(factorial(length($word)) - 1));
+ return @ret;
+}
+
=head1 NAME
Games::Word - ???