Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Perl golf lessons

by the_hawk_1 (Scribe)
on Jun 28, 2007 at 14:40 UTC ( [id://623904]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://623904]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-18 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found