New golf was Re: New Perl magazine
Tony Bowden
tony at kasei.com
Sun Feb 3 06:21:11 CST 2002
On Sat, Feb 02, 2002 at 09:10:25PM +0000, Liyang Hu wrote:
> 1234567890123456789012345678901234567890123456789012345
> -F// -pae'map{$i=$i*36+("A"le$_?-55+ord$_:$_)}@F;$_=$i'
> -F// -pae'map{$i*=36;$i+="A"le$_?-55+ord$_:$_}@F;$_=$i'
> 55 characters[0]. Can't think of any other way to shorten that, I'm
> afraid.
Well, you could switch the order of the ternary, and rely on the
implicit $_ that ord gets (saving 2 strokes)
> 1234567890123456789012345678901234567890123456789012345
> -F// -pae'map{$i*=36;$i+="A"gt$_:$_?-55+ord}@F;$_=$i'
And without strict you don't need the quotes round that "A" (although
you'll need a space before the gt, so you'll only save 1 more stroke)
> 1234567890123456789012345678901234567890123456789012345
> -F// -pae'map{$i*=36;$i+=A gt$_:$_?-55+ord}@F;$_=$i'
> [0] How does golf work again? Do I include the switches in the
> character count? And the quotes?
Yep.
Tony
More information about the Belfast-pm
mailing list