in reply to base 4 golf

Not as short, but quite elegant I thought.
# 1 2 3 4 # 12345678901234567890123456789012345678901234567 perl -e'$_=sprintf"%b",pop;s/(.)(.)/print$1*2+$2/eg' 62

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: base 4 golf
by thospel (Hermit) on Feb 23, 2003 at 00:04 UTC
    Can be shortened to:
    perl -le'$_=sprintf"%b",pop;s/../$&%8/eg;print'
    Fails in case the binary expension has odd length. can be fixed like this for example:
    perl -le'$_=sprintf"%b",pop;s/..(?=(..)*$)/$&%8/eg;print' 31

    update (broquaint): added formatting