#!/usr/bin/perl use strict; # NPR puzzler helper, 11/23/2003 # rewritten 12/15/2003 around 4 am. # Find a pair of words, [X]rn and [X]m, which are antonyms. # We can pull all such pairs from /usr/share/dict/words. open(FH,"/usr/share/dict/words"); my (@rn_words, @solutions); @rn_words = grep /([a-zA-Z]*rn$)/, ; chomp(@rn_words); seek FH,0,0; my $ptr = 0; my $this = substr($rn_words[$ptr],0,-2).'m'; LOOP: while () { chomp; next LOOP if ($_ lt $this); if ($_ eq $this) { push @solutions, "$rn_words[$ptr] / $_\n"; } $ptr++; $this = substr($rn_words[$ptr],0,-2).'m'; last unless defined $rn_words[$ptr]; } close FH; print @solutions;