Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Elegant as fuck

Name: Anonymous 2011-05-15 20:42

def fib(times):
    a, b = 0,1
    for _ in range(times):
        a, b = b, a+b
    return a


I think I just creamed my pants.

Name: Anonymous 2011-05-17 0:16

>>40
First, for the second command, you would use fibs !! 1000000000, as fibs is a list, not a function.
No shit, I was joking. Not to mention that you shouldn't even use parentheses for function calls in Haskell.

Name: Anonymous 2011-05-17 1:26

>>37
(                    
  (     ((   (               (      )))
         (  (  (       )  )))
    (       ( )
      (  (        )   ))))

Name: Anonymous 2011-05-17 1:32

>>42
      (     ):
    , = ,
              (     ):
        , = , +
         

Name: Anonymous 2011-05-17 1:47

>>43
Much better.

Name: Anonymous 2011-05-17 2:24


#include <stdio.h>

#define NMAX 10001

void fib (unsigned int times)
{
    unsigned char a[NMAX] = {0}, b[NMAX] = {0}, temp[NMAX] = {0};
    unsigned int i, t = 0;
    b[0] = 1; b[1] = 0; a[0] = a[1] = 1;
    while (times-- - 1)
    {
        for (i = 0; i < a[0]+1; i++)
            temp[i] = a[i];
        for (i = 1; i <= a[0] || i <= b[0] || t; i++, t /= 10)
            a[i] = (t += a[i] + b[i]) % 10;
        a[0] = i-1;
        for (i = 0; i < a[0]+1; i++)
            b[i] = temp[i];
    }
    for (i = a[0]; i > 0; i--)
        printf ("%d", a[i]);
}

int main (void)
{
    fib (1000);
    return 0;
}


There, now it works with bignums, not very elegant though. (I'm the C guy from >>13)

Name: Anonymous 2011-05-17 2:45

>>45
fib(18446744073709551617)

Name: Anonymous 2011-05-17 8:14

>>45
#        <     . >

#                

         (                  )
{
                   [    ] = { },  [    ] = { },     [    ] = { };
                  ,   =  ;
     [ ] =  ;  [ ] =  ;  [ ] =  [ ] =  ;
          (     -- -  )
    {
            (  =  ;   <  [ ]+ ;  ++)
                [ ] =  [ ];
            (  =  ;   <=  [ ] ||   <=  [ ] ||  ;  ++,   /=   )
             [ ] = (  +=  [ ] +  [ ]) %   ;
         [ ] =  - ;
            (  =  ;   <  [ ]+ ;  ++)
             [ ] =     [ ];
    }
        (  =  [ ];   >  ;  --)
               ("% ",  [ ]);
}

         (    )
{
        (    );
            ;
}

Name: Anonymous 2011-05-17 8:35

>>47
still better than lisp

Name: Anonymous 2011-05-17 9:13

>>48
Lol no. At least lisp is consistent with its parenthesis.

Name: Anonymous 2011-05-17 9:17

>>49
#        (     . )

#               

         (                  )
(
                   (    ) = ( ),  (    ) = ( ),     (    ) = ( );
                  ,   =  ;
     ( ) =  ;  ( ) =  ;  ( ) =  ( ) =  ;
          (     -- -  )
    (
            (  =  ;   <  ( )+ ;  ++)
                ( ) =  ( );
            (  =  ;   <=  ( ) ||   <=  ( ) ||  ;  ++,   /=   )
             ( ) = (  +=  ( ) +  ( )) %   ;
         ( ) =  - ;
            (  =  ;   <  ( )+ ;  ++)
             ( ) =     ( );
    )
        (  =  ( );   >  ;  --)
               ("% ",  ( ));
)

         (    )
(
        (    );
            ;
)

Name: Anonymous 2011-05-17 9:37

>>50
Invalid C code.

Name: Anonymous 2011-05-17 9:46

>>51
Valid gay poster.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List