develooper Front page | perl.fwp | Postings from December 2001

Re: Santa Hole 5 ( Post Mortem

Thread Previous | Thread Next
Tim Ayers
December 8, 2001 04:28
Re: Santa Hole 5 ( Post Mortem
Message ID:
>>>>> "R" == Rick Klement <> writes:
R> Since I'm going through "Golf withdrawal":

No kidding. As an alternative to cold turkey, I've wasted a little
time with the following...

Given Andrew's Post Mortem listings of everyone's solutions, print out
each unique solution sorted in ascending length. Assume the list is
normalized such that the she-bang line is #!perl, i.e. run the list
thru "perl -pe's/#!.*perl/#!perl/'" before dealing with it.

I have two variations one stroke different from each other.

 -ne'/ \d+/?$c=!($a{$c}=$&):($c.=$_);END{print sort{$a{$b}<=>$a{$a}}keys%a}'

 -ne'/^-/?$c=$a{$c}="":($c.=$_);END{print sort{length$b<=>length$a}keys%a}'

I'm sure there are smarter approaches that I don't see. Something with
the flip-flop maybe, but I'm not bright enough to use that beyond

Hope you have a very nice day, :-)
Tim Ayers (

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About