Results 1 to 26 of 26
  1. Collapse Details
    Pascal's triangle 
    #1
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    Motivated by the Hacker News challenge in http://news.ycombinator.com/item?id=3429466 I just made this.


    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #define NTH_IN_ROW(r, n) (((r) * (r) + (r)) / 2 + (n))
    int main() {
            long *a, i, j, r;
            scanf("%ld", &r);
            a = malloc(sizeof(long) * ((r + 1) * (r + 1) + r + 1) / 2);
            for (i = 0; i <= r; i++) {
                    a[NTH_IN_ROW(i, 0)] = 1;
                    a[NTH_IN_ROW(i, i)] = 1;
                    if (i > 1)
                            for (j = 1; j < i; j++)
                                    a[NTH_IN_ROW(i, j)] =
                                            a[NTH_IN_ROW(i - 1, j)] +
                                            a[NTH_IN_ROW(i - 1, j - 1)];
            }
            for (j = 0; j <= r; j++)
                    printf("%ld ", a[NTH_IN_ROW(r, j)]);
            putchar('\n');
            return 0;
    }
    Code:
    program Pascal;
    
    var counter as integer;
    var ptLine as integer[20];
    
    procedure Step(istep as integer);
    var couter as integer;
    begin
    ptLine[istep] := 1;
    if (istep<>1) then write( " " + ptLine[1]);
    if (istep>=3) then begin
    for couter := 2 to istep-1 do begin
        ptLine[couter] = ptLine[couter] + ptLine[couter-1];
        write(" " + ptLine[couter]);
        end;
    end;
    writeln(" " + ptLine[istep]);
    end;
    
    begin
    for counter:=1 to 20 do begin
        Step(counter);
        end;
    end.
    Opinions? Post you're own solutions.
    Last edited by Dustin; 01-06-2012 at 06:05 AM.
    Reply With Quote
     

  2. Collapse Details
     
    #2
    Breathe 🌊 Desolation's Avatar
    Join Date
    Dec 2011
    Posts
    10,077
    Looks like we have our very own zero cool! Watch your back, Milkshake
    Reply With Quote
     

  3. Collapse Details
     
    #3
    friends with english jon's Avatar
    Join Date
    Dec 2011
    Location
    alcatraz
    Posts
    4,510
    my first opinion is you're a faggot and my second opinion is anyone who writes a pascal program and calls it "Pascal" is thinking that other people won't recognize the language and is an even bigger faggot for being so condescending

    so the only question is: do we have one faggot here, or one faggot who simply copied the comment another faggot made, and therefore two faggots

    and if you get this question wrong you have failed the interview and may go home
    Reply With Quote
     

  4. Collapse Details
     
    #4
    friends with english jon's Avatar
    Join Date
    Dec 2011
    Location
    alcatraz
    Posts
    4,510
    plus you didn't newline between then/begin and you didn't use caps for the keywords so you're not even a very good pascal programmer, probably just one of those delphi faggots that pretends they used to use tp4
    Reply With Quote
     

  5. Collapse Details
     
    #5
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    just one faggot, clay told me the limit was one so I couldn't bring my friends.
    Reply With Quote
     

  6. Collapse Details
     
    #6
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    Also no need to be so mean gosh, I was under the impression that this is a friendly forum.
    Reply With Quote
     

  7. Collapse Details
     
    #7
    my weapons turn me into a m0nde's Avatar
    Join Date
    Dec 2011
    Location
    every once in a while
    Posts
    29,860
    oh shit, terms and arrays!
    Reply With Quote
     

  8. Collapse Details
     
    #8
    king steveyos clay's Avatar
    Join Date
    Dec 2011
    Posts
    4,591
    Quote Originally Posted by Cody View Post
    You were trolled.
    government was trolled when they wrote male on your birth cert
    Reply With Quote
     

  9. Collapse Details
     
    #9
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    Quote Originally Posted by Cody View Post
    You were trolled.
    Oh no not again
    Reply With Quote
     

  10. Collapse Details
     
    #10
    my weapons turn me into a m0nde's Avatar
    Join Date
    Dec 2011
    Location
    every once in a while
    Posts
    29,860
    don't worry. you weren't really. he's just trying to troll you.
    Reply With Quote
     

  11. Collapse Details
     
    #11
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    Well that's good to hear I was worried for a moment.
    Reply With Quote
     

  12. Collapse Details
     
    #12
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    What a rude poster, clay you should make a new section called "I'm rude and I know it" and only let Cody post in it. Then you should make one about programming and Jon is forced to look at arrays I made in C++ that are all wrong. ( I don't know C++ ) heh
    Reply With Quote
     

  13. Collapse Details
     
    #13
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    Quote Originally Posted by Cody View Post
    You should take a plastic bag, make a section of it covered in superglue, put it over your head, and smash it down on your face.
    Typical, mad cuz bad.
    Reply With Quote
     

  14. Collapse Details
     
    #14
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    literally went on a forum wide rant
    Reply With Quote
     

  15. Collapse Details
     
    #15
    DogManz maks's Avatar
    Join Date
    Dec 2011
    Location
    Lud, Midworld
    Posts
    99,256
    people still use pascal?
    Reply With Quote
     

  16. Collapse Details
     
    #16
    my weapons turn me into a m0nde's Avatar
    Join Date
    Dec 2011
    Location
    every once in a while
    Posts
    29,860
    \n
    Reply With Quote
     

  17. Collapse Details
     
    #17
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    Quote Originally Posted by maks View Post
    people still use pascal?
    lolno
    Reply With Quote
     

  18. Collapse Details
     
    #18
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    C is where its at anyway
    Reply With Quote
     

  19. Collapse Details
     
    #19
    my weapons turn me into a m0nde's Avatar
    Join Date
    Dec 2011
    Location
    every once in a while
    Posts
    29,860
    #include <pascal.h>
    Reply With Quote
     

  20. Collapse Details
     
    #20
    ᕦ(ò__ó)ᕤ rootbeer's Avatar
    Join Date
    Dec 2011
    Location
    Iron Hands fried chicken Chiang Mai technical college
    Posts
    11,875
    :snickerz:
    Reply With Quote
     

  21. Collapse Details
     
     

  22. Collapse Details
     
    #22
    Member Beef Sister's Avatar
    Join Date
    Dec 2011
    Posts
    46
    Quote Originally Posted by clay View Post
    government was trolled when they wrote male on your birth cert
    Reply With Quote
     

  23. Collapse Details
     
    #23
    I am postulate one blumpkin blownuts's Avatar
    Join Date
    Jan 2012
    Location
    subspace
    Posts
    7,162
    fuck HLL's other than lisp
    machine code owns j00 if I cared id rewrite your routine in 68k and have like a tenth of your instructions in native code
    Reply With Quote
     

  24. Collapse Details
     
    #24
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    do it then
    Reply With Quote
     

  25. Collapse Details
     
    #25
    DogManz maks's Avatar
    Join Date
    Dec 2011
    Location
    Lud, Midworld
    Posts
    99,256
    fyi I compiled and ran your c code, it doesn't do shit
    Reply With Quote
     

  26. Collapse Details
     
    #26
    Pariah :Care:y Plug Drugs's Avatar
    Join Date
    Dec 2011
    Location
    an edgecastle for edgelords
    Posts
    11,801
    was the point of this thread to show off our skills?
    i only read the first 2 replies and glanced at the tarantino spider
    Reply With Quote
     

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •