#!/usr/bin/perl

$|=1;

%let = (0, "A",
1, "B",
2, "C",
3, "D",
4, "E",
5, "F",
6, "G",
7, "H",
8, "I",
9, "J",
10, "K",
11, "L",
12, "M",
13, "N",
14, "O",
15, "P",
16, "Q",
17, "R",
18, "S",
19, "T",
20, "U",
21, "V",
22, "W",
23, "X",
24, "Y",
25, "Z",
	);

# Dictionary must be in all caps
while(<>){
    chop;
    $x = "";
    for $l ("A".."Z"){
	$ct = (s/$l/$l/g);
	$ct = 0 if (!$ct);
	$x .= "$ct ";
    }
    $exists{$x} = $_;
    $sv{$_} = $x;
    push(@words, $_);
    $ict++;
    if(($ict%50)==0){
	print "$ict $_\n";
    }
    # Change this if you want to use more words...
    last if (/^B/);
}

for $w (@words){
    for $r (0..25){
	$v = &makevec($sv{$w});
	@v = @$v;
	@other = @v;
	if($v[$r] >0){
	    $other[$r]--;
	    if($exists{&svec(@other)}){
		print "$let{$r} ", $exists{&svec(@other)}, " $w\n";
		}
	}
    }
}

sub makevec {
    $v = shift;
    my $newv;
    my @v = split(" ", $v);
    return \@v;
}

sub svec {
    @foo = @_;

    return join(" ", @foo)." ";
}

sub dist {
    $v1 = shift;
    $v2 = shift;
    @v1 = @$v1;
    @v2 = @$v2;
    my $dist=0;
    for $n (0..$#v1){
	$dist += abs($v1[$n]-$v2[$n]);
    }
    $dist;
}

__END__

Solution:
F ARMOIRE AERIFORM
U ACCESS ACCUSES
R ACE ACRE
T AMID ADMIT
H ACRES ARCHES
E ARTIST ATTIRES
R ACCUSED ACCURSED
