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

Re^3: Fibo Golf challenge on 3 monkeys

by jdalbec (Deacon)
on Jul 13, 2007 at 23:02 UTC ( [id://626543]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Fibo Golf challenge on 3 monkeys
in thread Fibo Golf challenge on 3 monkeys

I can shave off a couple characters by leveraging the fact that the length of the sequence is even. Also, the OP's sequence starts with F1=1, so if I start there too I don't have to initialize both variables.
perl -e '$a=1;for(A..J){print$a+=$b,$/,$b+=$a,$/}'
Update: Now that the loop is down to 1 statement I can switch to a postfix for. I can also fold the initialization into the loop.
perl -e 'print$a+=$b||1,$/,$b+=$a,$/for A..J'
... and if you feel strongly about starting with F0=0,
perl -e 'print$a+=$b,$/,$b+=$a||1,$/for A..J'

Replies are listed 'Best First'.
Re^4: Fibo Golf challenge on 3 monkeys
by Anonymous Monk on Jul 15, 2007 at 20:51 UTC
    perl -le'print$a+=$b,$/,$b+=$a||1for A..J'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 01:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found