aufflick has asked for the wisdom of the Perl Monks concerning the following question:
I hesitate to start YAFGT (Yet Another Fibonacci Golf Thread), but I had an interesting idea today: a golfed Fibonacci generator with only one state variable. I ended up with two solutions I like.
The second is shorter, but the first has two nice features: no explicit assignment operators and only one type of quote used which allows easy one-lining:
perl -le 'print$2while s/(\d*):?(\d*)/($1+$2||1).":$1"/e' |head -10 $_="$':".($'+$`||1),print$`while x./:/Both use a single state variable, but it's a colon separated string, so there are still really two state values.
|
---|