Skip to content

Instantly share code, notes, and snippets.

@mtimkovich
Last active December 9, 2015 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtimkovich/4335880 to your computer and use it in GitHub Desktop.
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
#!/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