in reply to Fibo Golf challenge on 3 monkeys
Let's see. We already have lots of fibonacci generator threads, like (OT) Fibonacci numbers in Ruby - final shot - 24 chars, Golfing a fibonacci number generator, Fibonacci Numbers, Fibonacci numbers (again)1 Fibonacci golf with one state variable1. We can use some ideas from those threads.
Firstly, modifying my dc solution, we get
dc -e1dp[pdsd+ldrlxx]dsxx|head -20
Then there's the ruby one you can adapt
ruby '-wex=i=1;20.times{p x;x+=i=x-i}'
I'll try to improve these and update this node later if I can.
Update: longer variants of the ruby line are:
orruby '-wep 1,x=1;18.times{p x=(x/0.618).round}'
ruby '-we20.times{|x|p((1.61803**x/1.382).round)}'
Update: I forgot to tell, but for just the first twenty numbers, the shorter dc one should work fine as well:
Update: The following which doesn't use head is even shorterdc -e1pd[pdk+Krlxx]dsxx|head -20
The following is yet one character shorter, but it takes some seconds to compute because it computes square roots to thousands of decimal places.dc -e1pd[rpdk+Kd6666\>x]dsxx
Update: Even shorter and does not have the speed penalty is this:dc -e1pd[rpdk+Kdv66\>x]dsxx
dc -e1pd[pdk+KrdZ5\>x]dsxx
Update: And you can cut one more character:
dc -e1d[prdk+KdZ5\>x]dsxx
Update 2008 oct 5: added two links marked by 1.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Fibo Golf challenge on 3 monkeys
by TimToady (Parson) on Oct 08, 2008 at 07:34 UTC | |
Re^2: Fibo Golf challenge on 3 monkeys
by RMGir (Prior) on Jul 17, 2007 at 11:17 UTC | |
by ambrus (Abbot) on Jul 17, 2007 at 12:05 UTC | |
by whio (Beadle) on Jul 30, 2007 at 04:18 UTC | |
by ambrus (Abbot) on Aug 12, 2007 at 11:34 UTC |