Code Golf

Code golf thread?

Rules of the game:
•Use as few characters as possible
Or
•Use as few variables as possible

For a starter challenge, try calculating the first 40 digits of the Fibonacci sequence.

Other urls found in this thread:

marvellous.itch.io/marvellous-inc
twitter.com/NSFWRedditVideo

Here's my entry

int x=1, y=0;
for(int i=0; i

Wait, sorry, that's the one that only prints the 40th term.

shouldn't it be an entire program though?

at least i tried
a,i;main(b){for(;i

Not really. Only the function needs to be posted.
It's not like you can reduce the boilerplate.

Will that run?
You haven't given a or b an initial value.

a and i are initialized to 0 because they're globals
b is just argc, and should be 1 on normal runs.

hey, guys, what's goin on in here

It's code golf, where you write horrible code in the name of efficiency.
It's fun.

You can compress it a little further:
a,i;main(b){while(i++

Ruby
_=[0,1];p (f=->n{_[n]||=f[n-2]+f[n-1]})[40]

In brainfuck this is just
+>++[-+>+]

undeniable proof that brainfuck is the superior language

def f(i):
return 1 if i

Haskell
f = 0:1:zipWith (+) f (tail f)
fib x = take x f

main = do print $take 40 $fib 0 1 where fib a b = a:fib b (a+b)

>recalculating the fib sequence on each iteration
absolutely pythonic

import numpy
(numpy.matrix([[1,1], [1,0]])**40)[1,0]

You use words oddly. Do you mean to say you want to program your own golf game? I'd suggest learning OpenGL as a first step.

Forth:
: FIB 0 1 ROT 0 DO DUP . SWAP OVER + LOOP ;

40 FIB
you can probably compress it a little more

auto f[&f](int a=1,int b=1,int c=1){
{
cout

That's C++ obviously.

SUPERIOR MATLAB SOLUTION COMING THROUGH, TRY HARDER IDIOTS:

fibonacci(1:40)

0 variables
15 characters (if I counted correctly)

NEXT QUESTION?

import fibonacci

a(40);sub a{my @b=(0,1);for(0..($_[0]-1)){print"$b[0]\n";($b[0],$b[1])=($b[1],($b[0]+$b[1]));}}

oh fug it's not supposed to count 0, last digit is actually the 39th not the 40th.

what is the sauce of this cute emoji blob?

In L++ from the game Marvellous Inc. Only 15 first results, since the numbers are limited to [-999,999]. Ignore the playing field on the right, just picked a random puzzle since I don't think there's a sandbox mode.

bash blob in google gives some results

set /a a=1+0
set /a b=0+0
:1
set /a b=%b% + %a%
set /a a=%b% + %a%
goto :1

hmm

nice.

f

why bother tho

searching Marvellous inc results in some game company not any game that looks like this, wanna help a nigga out

marvellous.itch.io/marvellous-inc

Haven't played all the way trough yet, but I've got a few hours in. Decent "zachlike", as they advertise it. FLOSS too.

cool