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

Pascal's triangle

Name: Anonymous 2012-01-05 17:41

Motivated by the Hacker News challenge in http://news.ycombinator.com/item?id=3429466 I just made this.


#include <stdio.h>
#include <stdlib.h>

int64_t* next_pascal_row(int64_t* previous_row, int64_t previous_size)
{
  int64_t* retval = (int64_t*)malloc(sizeof(int64_t)*(previous_size+2));
  int64_t i;
  for (i=0;i<previous_size+1;i++) {
    if (i==0 || i == previous_size) {
      retval[i] = 1;
    } else {
      retval[i] = previous_row[i-1] + previous_row[i];
    }
  }
  return retval;
}

void print_row(int64_t* row, int64_t size)
{
  int64_t i;
  for(i = 0; i < size; i++) {
    printf("%lld ",row[i]);
  }
  printf("\n");
}

int main()
{
  int64_t* first_row = (int64_t*)malloc(sizeof(int64_t));
  int64_t* previous_row;
  int64_t* next_row;
  int64_t i,size;
  first_row[0] = 1;
  size = 1;
  print_row(first_row,size);
  previous_row = first_row;
  for(i = 0; i<30;i++) {
    next_row = next_pascal_row(previous_row,size);
    size++;
    print_row(next_row,size);
    free(previous_row);
    previous_row = next_row;
  }
  free(next_row);
}

Opinions? Yeah, int64_t is probably a GNU extension, I don't care as long as it works with gcc. U mad? Also, post you're own solutions. If you can't do the Pascal, you can just go ahead and apply to your're nearest McDonald's, because you ain't worth shit.

Name: Anonymous 2012-01-08 19:53

>>118
I find it kind of funny how >>109 hasn't posted a solution yet.

Name: Anonymous 2012-01-08 19:54

>>120
sure you do, keep telling that to yourself and one day it may come true.

Name: Anonymous 2012-01-08 19:55

ITT kodak-san can't do pascal's triangle

Name: Anonymous 2012-01-08 19:55

>>121
Yeah, the binary tree we use is

      1
     / \
    2   3

Name: Anonymous 2012-01-08 19:57

>>122
Again, you still haven't cited the passage in C89 or C99 that supports your assertion.

Name: Anonymous 2012-01-08 19:57

>>122
Now, for the 4th time you fucking retard, tell us what you do for a living.

Name: Anonymous 2012-01-08 19:58

>>125
You forgot your tripcode jobless_programmer.

thanks for making it clear you take it off to try to get your points across in a lame attempt to make it seem like other people agree with you.

Name: Anonymous 2012-01-08 19:59

>>127
Well, again, for like the 5th time you ADD fucker, you still haven't cited the C89 or C99 passage that supports your asssertion. And you still haven't told us what you do for a living.

Are these questions too difficult for you to answer you fucking retarded stupid shit?

Name: Anonymous 2012-01-08 19:59

>>126
What do you do for a living? I scrub women's toilets.

Name: Anonymous 2012-01-08 20:00

>>128
I made 0 claims that need me to cite C89 or C99

All i said was return 0 and be done with it.

Learn to read faggots.

Name: Anonymous 2012-01-08 20:01

>>130
And I said that isn't standard C you fucking nigger.

Name: Anonymous 2012-01-08 20:01

>>121
>>118 and >>109 are both me and I wasn't aware that >>111 was asking me to solve the problem.

Name: Anonymous 2012-01-08 20:03

>>129
You're more than welcome to come up to Kodak Gallery here on 63rd and Hollis in Emeryville, CA to see what I do on a regular basis you idiot.

Name: Anonymous 2012-01-08 20:03

tripfags and their haters ruin yet another thread.

Back to /g/ with both of you, please.

Name: Anonymous 2012-01-08 20:04

>>133
Give me your room number kodak-san and your name.
I'll gladly take a drive up to Emeryville CA just to see no kodak-san.

I do like how you keep forgetting to put on your trip.

Name: Anonymous 2012-01-08 20:04

>>132
Well you made light of the Pascal's Triangle problem. So I decided to post a problem that you might kind non trivial. I was really expecting a person of your caliber to have posted a solution by now.

Name: Anonymous 2012-01-08 20:06

>>135

I do like how you keep forgetting to put on your trip.

I do it to pass the filters.

Name: Anonymous 2012-01-08 20:06

>>133
You're more than welcomed to post your badge + timestamp to prove you even work anywhere in the corporate world

Name: Anonymous 2012-01-08 20:07

>>136
Like I said, I missed the part where you said, "solve this problem", or "can you solve this?", because you never did, and if you did I would probably reply "are you offering me a job?"

Name: Anonymous 2012-01-08 20:08

>>137
So you purposely try to ruin /prog/ by annoying everyone that you can?

Name: Anonymous 2012-01-08 20:10

>>140
Nah. I'm just annoyed with this uneducated burger flipper. Seriously. This guy needs to learn something otherwise he will be working some shit hourly job for the rest of his life.

Name: Anonymous 2012-01-08 20:13

>>137
Only a mental midget would think of that. Start scrubbing another toilet!

Name: Anonymous 2012-01-08 20:15

>>142
Stop stealing my one liners and come up with your own you dumb jew.

Name: Anonymous 2012-01-08 20:18

>>140
Kodak-san is mai waifu, I will not have you speak ill of him.

Name: Anonymous 2012-01-08 20:21

kodak-san how does it feel to:

--> Have no job
--> Live in your parents basement
--> Spend your entire day on /prog/ and probably an imageboard
--> Be less intelligent than the great FrozenShit
--> Have to make fun of people just to sleep at night without crying about your shitty life

Name: Anonymous 2012-01-08 20:25

>>145
How dare you attack mai waifu like that?

Dear Anonymous (>>145), how does it feel to:

--> have no life
--> be fat
--> be ugly
--> never kissed a girl
--> never hugged a girl
--> never had a girlfriend
--> spend your entire day on /prog/ and probably an imageboard
--> scrub toilets all day erry day
--> be a mental midget
--> attack your betters

I wouldn't know because I'm a superior specimen of the human species and so is mai waifu.

Name: Anonymous 2012-01-08 20:27

>>146
mai waifu

It's okay that you're all of those points, not everyone is a sad lonely faggot such as yourself. Please finish scrubbing my toilet and suck on my big meaty balls.

Name: Anonymous 2012-01-08 20:29

>>147
Prepare to defend yourself, I will not have you tarnish the reputation of mai waifu in this manner.

FOR KODAK-SAAAAAAAAAAAAAAAAAAAAAAAAAAN

Name: Anonymous 2012-01-08 20:36

I think Kodak-san is kind of cute, he's just tsundere.

Name: Anonymous 2012-01-08 20:43

>>141

alas, kodak-san's motivations are revealed. I always knew you were trying to help us, berating us while nudging us towards enlightenment.

Name: Anonymous 2012-01-08 20:47

>>150
Wow he actually is tsundere.

Name: Anonymous 2012-01-08 20:47

>>147
Go run off and make some more uneducated statements about C you homo.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-08 20:49

>>147

See, the people in
>>148
>>150

actually do like me!

Name: Anonymous 2012-01-08 20:50

>>150
Maybe he is a really intelligent burger flipper who never got an education because he had to help his single mother pay for the bills while she worked as a stripper at a local bar who now knows the true value of education and work experience but doesn't have the opportunity to get it himself so he helps us with our C programs since he's read the standards and understand them.

That's so cute, thank you Kodak-san ^_^

Name: Anonymous 2012-01-08 21:18

Name: Anonymous 2012-01-08 21:32

>>153
I-it's not like I like you or anything, you m-mental midget.

Name: kodak_gallery_programmer !!kCq+A64Losi56ze 2012-01-09 15:42

>>147

See, the people in
>>148
>>150

actually do like me!

Name: VIPPER 2012-01-09 15:47

>>154
Or maybe his father killed himself, while his mom just watched TV, drank booze and smoked shit all day long just like the rest of /prog/ and he picked up some C on the side.

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