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

Re: [FWP] nuts is stun spelled backwards



On Mon, Oct 16, 2000 at 07:31:07PM -0700, Peter Scott wrote:
> After a friend discovered that 'dessert' is 'stressed' spelled backwards 

'desserts' 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

In the golf theme:

perl -nle'$h{$r=reverse}?push@w,"$r $_":$h{$_}++;END{map print,sort@w}'


Ronald

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