Last active
December 9, 2015 22:09
-
-
Save mtimkovich/4335880 to your computer and use it in GitHub Desktop.
Anagram program using the wordlist from http://www.isc.ro/en/commands/lists.html
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 perl | |
use strict; | |
use warnings; | |
my %hash; | |
my $output = 0; | |
open FILE, "TWL06.txt" or die $!; | |
while (<FILE>) { | |
chomp; | |
$_ = lc; | |
push @{$hash{join "", sort(split //)}}, $_; | |
} | |
close FILE; | |
for my $key (sort {@{$hash{$b}} <=> @{$hash{$a}}} keys %hash) { | |
print "$key (" . @{$hash{$key}} . ") => " . join(", ", @{$hash{$key}}) . "\n"; | |
last if ++$output >= 3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment