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

Re: [FWP] comm Golf



tayers@bridge.com writes:
> perl -e'open A,$ARGV[0];open B,$ARGV[1];$a=<A>;$b=<B>;($a ne$b?$a lt$b?($_=$a,$a=<A>):($_="\t$b",$b=<B>):($_="\t\t$a",$a=<A>,$b=<B>),print)while$a&&$b;print$a,<A>,$\="\t",$b,<B>'

You can save a few bytes:

BEFORE: open A,$ARGV[0];open B,$ARGV[1]
AFTER:  $A='A';map{open$A++,$_}@ARGV;

My entries, showing the evolution of my techniques:

  perl -e'open A,shift;$h{$_}=1 while<A>;$h{$_}|=2 while<>;map{print"\t"x($h{$_}-1),$_}sort keys%h'

  perl -e'$h{$_}|=2-@ARGV while<>;print"\t"x($h{$_}-1),$_ for sort keys%h'

  perl -ne'$h{$_}|=2-@ARGV;END{print"\t"x($h{$_}-1),$_ for sort keys%h}'

Curse you for making me lose the morning :-)

Nat

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