[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] nuts is stun spelled backwards



After a friend discovered that 'dessert' is 'stressed' spelled backwards 
and decided to share it with me and a zillion friends, I decided to find 
all of the possible word pairs that share this property.

My best (for golf) code for this is somewhat pedestrian:

perl -nle'$h{$_}=$_;END{$x=reverse$_ and$h{$x}&&delete$h{$_}ne$x&&print"$_ 
$x"for sort keys%h}' word.lst

Assume that words.lst contains words, one per line, all lowercase and no 
punctuation characters (this describes the ENABLE list).  I removed the 
"foo is oof spelled backwards" string as being too long and replaced it 
with a requirement to output each word pair on a new line with a space in 
between.  And they should be in alphabetical order of the first word, and 
there should be no redundant entries.

Fire away.
--
Peter Scott
Pacific Systems Design Technologies


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe