the_hawk_1 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

I've just discover this great 'sport', but actually, I so dumb that I can't golf right!

for example, I've tried the Roman-Decimal code golf challenge, but I ended up with a code around 200 bytes, wich is far away the 59 record.

Where can I learn to code golf right?

If you wanna look my code:

#!perl $a=uc($ARGV[0]); %y=(I,1,V,5,X,10,L,50,C,100,D,500,M,1000); for(;$i<length($a);) { $H=$y{substr($a,$i,1)}; $L=$y{substr($a,++$i,1)}; $H < $L?$H*=-1:$H; $m+=$H; } print "$m\n";
I know, all the spaces ans line feed could be remove, but still be around 190 bytes...

Replies are listed 'Best First'.
Re: Perl golf lessons
by lin0 (Curate) on Jun 28, 2007 at 15:13 UTC