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

Re: [FWP] comm Golf



>>>>> "Peter" == Peter Scott <Peter@PSDT.com> writes:
    Peter> Just shaving a bit off your score here down to 101, still
    Peter> playing the hole the same way:

Likewise. Under a 100 now.

    Peter> perl -e'open B,pop;@a=<>;while(<B>){print shift@a while
    Peter> $a[0]lt$_&&@a;print"\t",$a[0]eq$_?"\t".shift@a:$_}'

    perl -e'open B,pop;@a=<>;for(<B>){print shift@a while
    $a[0]lt$_&&@a;print"\t",$a[0]eq$_?"\t".shift@a:$_}'

Except that testing this I discovered a flaw.  It doesn't drain @a
after processing <B>.

    perl -e'open B,pop;@a=<>;for(<B>){print shift@a while
    $a[0]lt$_&&@a;print"\t",$a[0]eq$_?"\t".shift@a:$_}print@a;'

fixes it.

-- 
Stephen

"If I claimed I was emperor just cause some moistened bint lobbed a
scimitar at me, they'd put me away"

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