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

Re: [FWP] nuts is stun spelled backwards



Ronald J Kimball wrote:

> > Peter's spec does not say anything about the ordering of the words
> > w/in the pair.  I believe Ilmari's putt reaches the hole.
> 
> I believe you're splitting hairs.  What's the point of sorting
> alphabetically by the word that comes second alphabetically?
> 
> Ronald


The project specification doesn't say what the point of having the
list sorted is at all, so the contractor has no way of telling if sorting
by the first or second alphabetically of the pair matters.


I have figured
out a way to use Abigail's Manoeuvre on this problem, by introducing a second
container that gets explicitly sorted, so we don't depend on sorted data

 perl -ple'$h{$_}=$h{$r=reverse}?$v{"$r $_"}=1:1}for(sort keys%v){' /usr/dict/words 
 perl -ple'$h{$_}=$h{$r=reverse}?push@v,"$r $_":1}for(sort@v){' /usr/dict/words 


Here are two more approaches that fail to gain anything and cost much 
extraneous spew:

 perl -ple'$h{$_}=$h{$r=reverse}?$v[$.]="$r $_":1}for(sort@v){' /usr/dict/words
 perl -ple'$h{$_}=$h{$r=reverse}?"$r $_":1}for(sort values%h){' /usr/dict/words
-- 
                          David Nicol 816.235.1187 nicold@umkc.edu
                "After jotting these points down, we felt better."

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