Created
August 20, 2010 00:58
-
-
Save ShimmerFairy/539337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
my $phrase = prompt "Enter what you wish to anagram: "; | |
say "Removing everything except letters"; | |
$phrase ~~ s:g/<-alpha>//; | |
die("You didn't enter any letters!") if $phrase.chars == 0; | |
say "String to be anagrammed: $phrase"; | |
$phrase = $pharse.lc; | |
say "{[*] 1..$phrase.chars} possibilities (counting the original string)"; | |
my $arraylength = $phrase.chars; | |
my @anagrams; | |
while @anagrams.elems < $arraylength { | |
$_ = $phrase.comb.pick(*); | |
@anagrams.push($_) if !([+] ($_ «==« @anagrams)); | |
} | |
say "Results:"; | |
say @anagrams.join(" "); | |
say "DONE!"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment