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

Pages: 1-4041-

ANY OF U REDDY 2 CHALLENGE ME YET?

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 0:33

CARN

Name: Anonymous 2013-06-20 0:38

What's your challenge?

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 0:40

EEEEEEEH EEEEEEEEEEEEH EEEEEEEEEEEEEEH EEEEEEEEEEEEEEEEEH
http://dis.4chan.org/read/prog/1366682174

Name: Anonymous 2013-06-20 2:13



    >>3
    >LE FRENCH MORON FACE

Name: Anonymous 2013-06-20 3:06

>>3
Your code <https://dis.4chan.org/read/prog/1366682174/12>; is very underwhelming for somebody who has supposedly ``READ DA STANDARD''. I mean, a linked list for a one-page program? Seriously? What's a dynamic array? Have you read the fuqin standard? The Python equivalent would be faster than your C implementation.

Name: Anonymous 2013-06-20 3:33

>>5
Have you read the fuqin standard?
MANY MORE TIMES THAN U HAVE, DATS FOR DAMN SURE. I'VE ALSO TAKEN A SHIT ON IT WAY MORE THAN U HAVE. I TOOK A SHIT ON A DRAFT, RIGHT IN FRONT OF THE C COMMITTEE, BACK BEFORE C89 WAS PUBLISHED. EVER SINCE THEN, I'VE BEEN SHITTING ON EVERY SINGLE VERSION DAT FOUND ITS WAY INTO MY HANDS.

I mean, a linked list for a one-page program? Seriously?
LOOKS LIKE WE HAVE ANOTHER CANDIDATE FOR DA /prog/ AWARD FOR RETOIDATION.

What's a dynamic array?
TRY REEDIN A BOOK YA FUCKIN RETOID.

NOW GIMMIE A CHALLENGE YA FUCKIN RETOIDS.

Name: Anonymous 2013-06-20 3:35

YOU IS NOT ANDRU

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 3:40

>>7
OUT OF MY THRED OR I'LL SHOVE ANDRE THE GIANT'S SKELETON UP UR SCRAWNY ANUS.

Name: Anonymous 2013-06-20 3:44

>>8
spooky scary skeletons~

Name: Anonymous 2013-06-20 3:54

>>6
Here's a challenge: rewrite your shitty little program to use a dynamic array instead of a slow-as-fuck linked list.

Name: Anonymous 2013-06-20 4:09

( ͡° ͜ʖ ͡°)     le prog face

Name: Anonymous 2013-06-20 4:17

check my base >11 dubs

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 4:19

>>10
First explain why you believe the linked list used in that program is slow-as-fuck.

Name: Anonymous 2013-06-20 4:39

>>12
No one is interested in trivial dubs. More interestingly 12 has dubs in base 5 and base 2.

Name: Anonymous 2013-06-20 4:45

Aight, write a red black tree implementation to keep my
rgb 24 bitmap images ordered

Name: Anonymous 2013-06-20 4:53

>>15
and please, keep them ordered by the amount of cum that you can aproximate they show on girls bodies, lets say that those are usually blobs with values ranging from.

Cum:
0xff-0xdf R
0xff-0xdf G
0xff-0xdf B
With a size between (1/8)-(1/32) of the images actual W/H


Surrounded by skin:
0xed-0xdf R
0xda-0xaf G
0xda-0xaf B
and remember that girls bodies are usually petite

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 4:58

>>15,16
REED DA RULES YA FUCKIN RETOID: http://dis.4chan.org/read/prog/1366682174

AND TAKE UR TWISTED FANTASIES OUT OF MY FUCKIN THRED.

Name: Anonymous 2013-06-20 5:04

>>13
Do some benchmarking. Dynamic arrays are always faster than a linked list. Even if the array needs to be resized several times, the difference between O(1) and O(n) is huge. If you ever wrote anything non-trivial with linked lists you'd know that. For something like a video game or GUI where the bottleneck is blitting to the screen, it doesn't matter much, but for a low-level program or a trivial script, a linked list just says ``I can't into memory management and pointer safety''. Plus arrays are primitive, lists are not. They're even simpler to use if you understand them and know how to use them safely. Read the fuqin standard.

Name: Anonymous 2013-06-20 5:08

>>16
I won't write an implementation myself but i'll build yours and test it on said group of images and report results if it's decent.

Make it that receives as single argument a string for directory and applies the algorithm to every *.bmp file.

File structure as: 1st word for W, 2nd word for H, 24b pixels.
Words unsigned btw.

How you display results is up to you but if you're fine with the terminal I'll redirect it a textfile.


Also don't use libraries other than the
standard and avoid obfuscated code, I won't carefully check for weird things and with  that I mean
that as soon as I see a clusterfuck of something I'll stop trying very fast, so apply yourself.

Name: Anonymous 2013-06-20 5:16

>>17
I'll do my part adjusting the files for the test, is up to you to make the code shine and sort properly "Koishis_first_load" so it doesn't appear near "mum_in_weddingdress"

I thought you wanted a challenge, here you have one.
Show me something decent and I'll consider actually engaging in e-peen     competitions.

Name: L. A. C. !!wKyoNUUHDOmjW7I 2013-06-20 5:20

>>18
Even if the array needs to be resized several times, the difference between O(1) and O(n) is huge.
TELL ME, WHAT DA FUCK ARE DESE GROWTH RATES MEANT TO REPRESENT?

Name: Anonymous 2013-06-20 5:22

>>20
HOW MANY ILLITERATE RETOIDS VISIT DIS BOARD?

Name: Anonymous 2013-06-20 5:30

>>22
There are only three people on /prog/.

Name: Anonymous 2013-06-20 5:34

>>23
You, me, and le Sussman. XDDD

Name: Anonymous 2013-06-20 5:38

>>18
Most often you walk across the whole list instead of random access you faglord.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 5:54

>>25
I'LL ASSUME U MEANT TO REFERENCE MY POST.

ANYWAY, NOW UR BEING A BIT LESS VAGUE. OKAY, LET'S ANALYSE MY PROGRAM A BIT, SHALL WE? WE'LL TAKE A LOOK AT DA VARIOUS OPERATIONS WE DO ON DESE LINKED LISTS. WE'LL LOOK AT DIS LINK: http://ideone.com/S9BEkQ

OK, THE OPERATION WE SEE ON LINE 35 IS AN INSERTION OPERATION. WE INSERT TO DA FRONT OF DA LIST. PRETTY FUCKIN COOL. LOOKS LIKE DAT HAS A GROWTH RATE OF O(1). PRETTY FUCKIN SNAZZY HUH?

OK, THE NEXT OPERATION, ON LINE 39, IS A TRAVERSAL. O(n), BUT DATS DA SAME AS IT IS FOR AN ARRAY. U EVER SEE ANYONE TRAVERSE AN ARRAY IN UNDER O(n)? I HAVEN'T. GOTTA BE FUCKIN SUPERMAN TO DO DAT SHIT, RIGHT?

GOT A PROBLEM WITH O(1) INSERTION? GOT A PROBLEM WITH O(n) TRAVERSAL? DON'T THINK SO. SO WATS UR NEXT COMPLAINT ABOUT LINKED LISTS, YA RETOID?

Name: Anonymous 2013-06-20 5:57

>>26
NO, SCRATCH DAT. WATS UR NEXT COMPLAINT ABOUT LINKED LISTS IN MY FUCKING PROGRAM.

Name: Anonymous 2013-06-20 6:01

>>26
I am offended by your pejorative usage of the word "retard".

Name: Anonymous 2013-06-20 6:06

>>28
WHERE DID I USE DAT WORD, YA FUCKIN RETOID? HARH?

Name: Anonymous 2013-06-20 6:20

CARN, >>25. CARN, >>28. TYPE SOME LETTERS.

Name: Anonymous 2013-06-20 6:27

dear LAC~kun.
Theoretical challenge.

It's a regular Saturday at your family's home and your dad is fucking the dog in the ass while the dog does the same with ur mum who also fucks you using your dad strap on25cm PINK RUBBER Salvaje[/u] symbolizing a linked list, could you tell me where should you put ur 3inches to make said linked give the impression it's infinite as we iterate it?

1) Can you write a function
void print_linked_dick(linked_list_node *node, void *wildcard);//Use wildcard as you wish without modifying the list
such that it can iterate through every element, print it and determine if we're looping to exit?

2) Can you do it recursively without the wildcard?


3) And recursively without the wildcard AND without modifying the list?

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 6:35

>>31
HAHAHAHAHAHAHHHAHAHAHHAHAHAA
I'M NOT ACCEPTING A CHALLENGE AS SHITTY AS THAT (REED DA RULES YA RETOID), BUT UR POST WINS A PAGE IN MY FUCKING JOKE BOOK.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 6:43

>>31
O YEA, AND TO ANSWER UR QUESTION, LOOK NO FURTHER THAN DA OUROBOROS. WILLY GOES IN PAPA'S ASS.

Name: !!YtwzkeoLMFQUgZv 2013-06-20 7:57

Challenge:
Write a program that reads a left-to-right text and outputs top-to-bottom.
For example, having read this post up to this point, it would output:

F
Wo
rr
i
te
ex
 a
am
 p
pl
re
o,
g
rh
aa
mv
 i
tn
hg
a
tr
 e
ra
ed
a
dt
sh
 i
as

lp
eo
fs
tt
-
tu
op
-
rt
io
g
ht
th
 i
ts
e
xp
to
 i
an
nt
d,

oi
ut
t
pw
uo
tu
sl
 d
t
oo
pu
-t
tp
ou
-t
b:
o
t
t
o
m
.


Challenge accepted?

Name: Anonymous 2013-06-20 7:59

>>34
The output is correct except the first `F' was supposed to be ` F'. I did not copy it correctly.

Name: Anonymous 2013-06-20 8:06

Name: Anonymous 2013-06-20 9:08

>>34
Collect lines as rows of matrix L, read out rows of LT

Name: !!YtwzkeoLMFQUgZv 2013-06-20 9:19

>>37


Inefficient.


I am challenging Calculus but I'd like you to participate as well. The best solution wins. Yes, L^T is a solution, but if that is what you are going to post, it will not win. Memory, time, true LOC. An obscure solution may also be the winner. Ι did not mention this in my original post because I thought it'd be fucking obvious.

Name: !!YtwzkeoLMFQUgZv 2013-06-20 9:28

>>38
more guidelines:
bugs automatically disqualify the solution, and you don't get a second chance, there should be no memory limitation as to how much can be read from input or minus points, unless of course the cleverness of the solution depends on the finiteness of the buffer used. Also minus points for everything that could be written in a standard manner and is not. I will be the only and final judge, but you are free to make remarks and/or discredit me.

Name: Anonymous 2013-06-20 9:33

>>38
I can see memory being an issue, but it should be rather fast to read out [j i] after you have stored all [i j]. Anyway another way I came up with quick is storing up pointers to the starts of each line and building up lines by traversing one character of each line, defaulting to ' ' once a line has been exhausted.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 12:57

>>34
ACCEPTED.

>>38
The best solution wins.
MAYBE IN UR SHITTY GAME, BUT ALL I'M PARTICIPATING IN IS DA FUCKING CHALLENGE. I'VE POSTED MY RULES EARLIER; IF IT IMPRESSES ME I'M OFF DESE FUCKING BOARDS. NO WINNERS, NO LOSERS.

>>39
MORE BULLSHIT.

>>40
SHUT UP U FUCKING MATH BOY.

ANYWAY, I'M DONE AND UPLOADED TO ideone. TIME FOR U TO POST UR FUCKIN CODE.

Name: Anonymous 2013-06-20 13:05

>>21,25,26
Alright, faggots, you've angered an EXPERT PROGRAMMER.

numelems.h:
#define NUM_ELEMS 10000000

list.c
#include <stdio.h>
#include <stdlib.h>
#include "numelems.h"

typedef struct node {
    int n;
    struct node *next;
} node;

node *new(int n) {
    node *l;

    l = malloc(sizeof(*l));
    l->n = n;
    l->next = NULL;
    return l;
}

int main() {
    int i;
    unsigned long total;
    node *head;
    node *tail;

    head = NULL;
    for (i = 0; i < NUM_ELEMS; ++i) {
        if (head) {
            tail = tail->next = new(i);
        } else {
            tail = head = new(i);
        }
    }
    total = 0;
    tail = head;
    while (tail) {
        total += tail->n;
        tail = tail->next;
    }
    printf("%lu\n", total);
    return 0;
}


array.c
#include <stdio.h>
#include <stdlib.h>
#include "numelems.h"

int main() {
    int *a;
    int i;
    size_t n;
    unsigned long total;

    n = 1;
    a = malloc(n * sizeof(*a));
    for (i = 0; i < NUM_ELEMS; ++i) {
        while (n <= i) {
            n *= 2;
            a = realloc(a, n * sizeof(*a));
        }
        a[i] = i;
    }
    while (--i)
        total += a[i];
    printf("%lu\n", total);
    return 0;
}


I made the initialized the array with a size of 1, so that it needs to be reallocated as often as possible, just to demonstrate how much faster it is regardless.

$ cc -o array array.c
$ cc -o list list.c
$ time ./list
49999995000000
./list  0.71s user 0.15s system 99% cpu 0.869 total
$ time ./list
49999995000000
./list  0.72s user 0.15s system 99% cpu 0.878 total
$ time ./list
49999995000000
./list  0.71s user 0.15s system 99% cpu 0.870 total
$ time ./list
49999995000000
./list  0.71s user 0.15s system 99% cpu 0.873 total
$ time ./list                                                                                                                                 49999995000000
./list  0.71s user 0.15s system 99% cpu 0.871 total
$ time ./array
49999995000000
./array  0.08s user 0.04s system 95% cpu 0.133 total
$ time ./array               
49999995000000
./array  0.08s user 0.04s system 97% cpu 0.131 total
$ time ./array                                                                                                                                49999995000000
./array  0.08s user 0.04s system 94% cpu 0.130 total
$ time ./array                                                                                                                                49999995000000
./array  0.08s user 0.04s system 95% cpu 0.129 total
$ time ./array                                                                                                                                49999995000000
./array  0.08s user 0.04s system 97% cpu 0.129 total


Feel free to do your own benchmarks, listboys.

Name: Anonymous 2013-06-20 13:08

>>42
Also, you'll notice that array.c looks like C, whereas list.c looks more like Javashit.

Name: Anonymous 2013-06-20 13:16

Shit insertion speeds.

Name: !!YtwzkeoLMFQUgZv 2013-06-20 13:35

>>41

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

int main(void) {
  char buf[BUFSIZ] = {0};
  size_t n, i, j, k;
  struct { size_t size, pos; } *m;

  fread(buf, 1, BUFSIZ - 1, stdin);
  n = strlen(buf);
  for(i = j = 0; j < n;
      j += strcspn(buf + j, "\n") + 1, i++);
  assert(i && (m = malloc(sizeof *m * i)));
  for(j = 0; j < i; j++) {
    m[j].pos = (j > 0) ? m[j-1].pos + m[j-1].size + 1 : 0;
    m[j].size = strcspn(buf + m[j].pos, "\n");
  }
  for(j = n = 0; j < i; j++)
    n = (m[j].size > n) ? m[j].size : n;
  for(j = 0; j < n*i; j++) {
    k = j % i;
    if(k == 0 && j != 0) putchar('\n');
    if(m[k].size*i > j)
      putchar(buf[m[k].pos + j/i]);
    else
      putchar(' ');
  }
  putchar('\n');
  free(m);
  return 0;
}

Name: Anonymous 2013-06-20 13:40

>>42
I found this amusing:

array.py:
#!/usr/bin/env python
NUM_ELEMS = 10000000
print sum(range(NUM_ELEMS))


$ time ./array.py
49999995000000
./array.py  0.76s user 0.36s system 99% cpu 1.126 total
$ time ./list
49999995000000
./list  0.71s user 0.15s system 99% cpu 0.860 total
$ time ./array
49999995000000
./array  0.08s user 0.04s system 97% cpu 0.124 total


The linked list is only slightly faster than the equivalent Python code, whereas the dynamic array is almost 10x faster.

Name: Anonymous 2013-06-20 13:52

It's not equivalent Python code because Python "lists" are really dynamic arrays.

Name: Anonymous 2013-06-20 13:55

>>47
They're equivalent in the sense that they do the same thing, retoid.

Name: Anonymous 2013-06-20 13:58

le optmized: printf("49999995000000")

Name: Anonymous 2013-06-20 13:58

>>48
Two pieces of code can do the same thing and not be equivalent. For instance, one piece may be more optimized than the other.

Name: Anonymous 2013-06-20 14:07

>>50
``Equivalent'' means that ==input==> [BLACK BOX 1] ==output==> == <==output== [BLACK BOX 2] <==input==

Name: Anonymous 2013-06-20 14:09

>>51
No, what you described is "do the same thing". If one of them modifies some global state and the other doesn't, they're not equivalent.

Name: Anonymous 2013-06-20 14:11

>>52

. . . . .. . . . . . . . . . . ,.-‘”. . . . . . . . . .``~.,
. . . . . . . .. . . . . .,.-”. . . . . . . . . . . . . . . . . .“-.,
. . . . .. . . . . . ..,/. . . . . . . . . . . . . . . . . . . . . . . ”:,
. . . . . . . .. .,?. . . . . . . . . . . . . . . . . . . . . . . . . . .\,
. . . . . . . . . /. . . . . . . . . . . . . . . . . . . . . . . . . . . . ,}
. . . . . . . . ./. . . . . . . . . . . . . . . . . . . . . . . . . . ,:`^`.}
. . . . . . . ./. . . . . . . . . . . . . . . . . . . . . . . . . ,:”. . . ./
. . . . . . .?. . . __. . . . . . . . . . . . . . . . . . . . :`. . . ./
. . . . . . . /__.(. . .“~-,_. . . . . . . . . . . . . . ,:`. . . .. ./
. . . . . . /(_. . ”~,_. . . ..“~,_. . . . . . . . . .,:`. . . . _/
. . . .. .{.._$;_. . .”=,_. . . .“-,_. . . ,.-~-,}, .~”; /. .. .}
. . .. . .((. . .*~_. . . .”=-._. . .“;,,./`. . /” . . . ./. .. ../
. . . .. . .\`~,. . ..“~.,. . . . . . . . . ..`. . .}. . . . . . ../
. . . . . .(. ..`=-,,. . . .`. . . . . . . . . . . ..(. . . ;_,,-”
. . . . . ../.`~,. . ..`-.. . . . . . . . . . . . . . ..\. . /\
. . . . . . \`~.*-,. . . . . . . . . . . . . . . . . ..|,./.....\,__
,,_. . . . . }.>-._\. . . . . . . . . . . . . . . . . .|. . . . . . ..`=~-,
. .. `=~-,_\_. . . `\,. . . . . . . . . . . . . . . . .\
. . . . . . . . . .`=~-,,.\,. . . . . . . . . . . . . . . .\
. . . . . . . . . . . . . . . . `:,, . . . . . . . . . . . . . `\. . . . . . ..__
. . . . . . . . . . . . . . . . . . .`=-,. . . . . . . . . .,%`>--==``
. . . . . . . . . . . . . . . . . . . . _\. . . . . ._,-%. . . ..`

Name: Anonymous 2013-06-20 14:13

>>53
Yep, kid, it's real life: not all code that "does the same thing" is equivalent. And you will understand that once you have enough experience catchings bugs caused by seemingly innocent changes to code.

Name: Anonymous 2013-06-20 14:15

>>52
To clarify my picard facepalm: In my little world, global states do not exist. It's all de bruijn indices y0.

Name: Anonymous 2013-06-20 14:16

>>54
Okay. Can I now go to my room and play with my TI? Please?

Name: Anonymous 2013-06-20 14:18

>>54
real life
VB is real life. PHP is real life. Java is real life. Your point being? FML I code under my bedsheets with my raspberry.

Name: Anonymous 2013-06-20 14:19

>>42
Let's not forget that in a real program, we'll want to cleanup after ourselves. With the dynamic array, this is as simple as one free

array.c:
#include <stdio.h>
#include <stdlib.h>
#include "numelems.h"

int main() {
    int *a;
    int i;
    size_t n;
    unsigned long total;

    n = 1;
    a = malloc(n * sizeof(*a));
    for (i = 0; i < NUM_ELEMS; ++i) {
        while (n <= i) {
            n *= 2;
            a = realloc(a, n * sizeof(*a));
        }
        a[i] = i;
    }
    while (--i)
        total += a[i];
    printf("%lu\n", total);
    free(a);
    return 0;
}


With the linked-list, of course, you have free every node.

list.c
#include <stdio.h>
#include <stdlib.h>
#include "numelems.h"

typedef struct node {
    int n;
    struct node *next;
} node;

node *new(int n) {
    node *l;

    l = malloc(sizeof(*l));
    l->n = n;
    l->next = NULL;
    return l;
}

int main() {
    int i;
    unsigned long total;
    node *head;
    node *tail;

    head = NULL;
    for (i = 0; i < NUM_ELEMS; ++i) {
        if (head) {
            tail = tail->next = new(i);
        } else {
            tail = head = new(i);
        }
    }
    total = 0;
    tail = head;
    while (tail) {
        total += tail->n;
        tail = tail->next;
    }
    printf("%lu\n", total);
    while (head) {
        tail = head->next;
        free(head);
        head = tail;
    }
    return 0;
}


And let's see how this scales:
time ./array
49999995000000
./array  0.08s user 0.05s system 97% cpu 0.134 total
$ time ./list
49999995000000
./list  1.96s user 0.18s system 99% cpu 2.141 total


OUCH! Two seconds? You mean 10000000 mallocs and frees isn't BLINDING FAST?! Who would have thought?

``B-b-but, muh O(n) traversal.''
-- Lambda A. ``List Boy'' Calculus and his fag buddy

List: O(n) traversal, O(n) allocation, O(n) deallocation, O(n) access.
Array O(n) traversal, O(sqrt n) allocation, O(1) deallocation, O(1) access.

List: non-primitive, requires struct, optional auxiliary functions, etc.
Array: native to C, just declare and use it, fast as FUCK.

Time to the Standard again, Lambda. Maybe work out some Project Euler problems until you understand how to write non-shitty, non-slow, non-bloated, non-standard code.

Name: Anonymous 2013-06-20 14:23

>>55
Go back to your little haskieworld, pussy.

Name: Anonymous 2013-06-20 14:39

Nice to see some actual coding in /prog/.
Good job, guises.

Name: Anonymous 2013-06-20 14:42

>>57
Don't see any contradictions. Any language that allows non-referentially-transparent everywhere is bound to have problems with "does what it's supposed to, but not quite equivalent" code. And any language that runs on machines with finite resources is bound to have them too. For instance, in Haskell there's a lot of referential transparency, but use a foldl instead of foldl', and you'll get a stack overflow.

Name: Anonymous 2013-06-20 14:47

>>61
/I don't write my code to run on machines; I write it to run as a concept. Finiteness of resources is not my problem, unless it is strictly mentioned in the specification/

In any language you'd like to have access to the disk or tape, and that alone is enough to throw away any short of referential transparency. As for haskell, I've never written anything in it. I'm a lisper.

Name: Anonymous 2013-06-20 14:49

>>62
I'm a lisper.
You should've mentioned that up front so I wouldn't waste my time talking to you, wacko.

Name: Anonymous 2013-06-20 16:23

>>63
says the YAHT haskell troll IHBT

Name: Anonymous 2013-06-20 18:14

Nice to see some actual PROGRAMMING (NOT ``CODING'') in /prog/.
Good job, guys (fuck off with your le epic meme ``guise'' bullshit).

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-20 23:11

>>45
I GOTTA SAY, DAT'S PRETTY IMPRESSIVE, THOUGH I THOUGHT IT WAS SUPPOSED TO WORK WITH INPUT OF ANY SIZE. OH WELL. IT'S STILL PRETTY INTERESTING -- I'LL REED INTO IT A BIT MORE.

HERE'S MINE:

TIMESTAMP: http://ideone.com/SnV26P

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

enum {
    SIZE = 8192
};

size_t count(const char *s, int c)
{
    size_t r;

    for (r = 0; *s; r += *s++ == (char) c)
        ;
    return r;
}

size_t max_strcspn(const char *s, int c)
{
    size_t max, tmp;

    for (max = tmp = 0; *s; s++) {
        if (*s != (char) c) {
            tmp++;
            continue;
        }
        if (tmp > max)
            max = tmp;
        tmp = 0;
    }
    return max;
}

char *fill(char *to, size_t longest, size_t lines, const char *from)
{
    char *save = to;
    size_t n;

    for (n = longest; lines; from++)
        if (*from == '\n') {
            memset(to, ' ', n);
            to += n;
            n = longest;
            lines--;
        } else {
            *to++ = *from;
            n--;
        }
    return save;
}

char *readall(FILE *iop)
{
    char buf[SIZE];
    size_t a = 0, n;
    char *r, *tmp;

    for (r = 0; (n = fread(buf, 1, SIZE, iop)) == SIZE; r = tmp) {
        if (!(tmp = realloc(r, a + SIZE))) {
            free(r);
            return 0;
        }
        memcpy(tmp + SIZE, buf, SIZE);
        a += SIZE;
    }
    if (!(tmp = realloc(r, a + n + 1))) {
        free(r);
        return 0;
    }
    memcpy(tmp + a, buf, n);
    tmp[a + n] = '\0';
    return tmp;
}

int main(void)
{
    size_t lines, longest;
    char *ptr, *s;

    if (!(s = readall(stdin))
     || !(ptr = malloc((lines = count(s, '\n')) *
               (longest = max_strcspn(s, '\n'))))) {
        free(s);
        return EXIT_FAILURE;
    }
    fill(ptr, longest, lines, s);
    for (size_t i = 0; i < longest; i++) {
        for (size_t n = 0; n < lines; n++)
            putchar(ptr[longest * n + i]);
        puts("");
    }
    free(s);
    free(ptr);
}


>>46,58
I AINT EVEN GONNA REED DIS SHIT UNTIL YOU POINT OUT WHERE I USE malloc IN MY PROGRAM. QUIT TRYING TO MISREPRESENT MY PROGRAM YA FUCKING COWARD.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-21 0:24

HERE, I HAVE A CHALLENGE FOR ALL OF /prog/. FIND THE CALL TO malloc IN DIS FUCKING PROGRAM:

http://dis.4chan.org/read/prog/1366682174/12%3E

IF ANYONE CAN SHOW ME WHERE DA CALL TO malloc IS IN DAT PROGRAM, I'LL TYPE OUT EVERY PAGE OF C11 AND UPLOAD IT.

SERIOUSLY.

GET TO IT, >>58. GET ON YOUR FUCKING BIKE.

Name: Anonymous 2013-06-21 0:32

>>67
It's when the compiler allocates space to prepare the 501 nodes that you declared.

Name: Anonymous 2013-06-21 0:56

Is LAC some kind of stupid nigger bytefucker?

Name: Anonymous 2013-06-21 1:46

>>68
Isn't that just 1 call instead of using malloc on each node like dynamic array sucker up there.

Name: Anonymous 2013-06-21 1:54

>>70
That would depend on the implementation of the compiler.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-21 2:55

>>68
A COMPILER SIMPLY TRANSLATES A PROGRAM FROM ONE LANGUAGE TO ANOTHER. IT DOESN'T INTERPRET DA FUCKING PROGRAM.

YA DON'T KNO WAT A COMPILER IS, YA DON'T KNO DA DIFFERENCE BETWEEN STATIC AND ALLOCATED STORAGE, AND YAINT RED DA FUCKING STANDARD -- DATS FOR DAMN SURE.

AND ON TOP OF DAT, YAINT EVEN RED MY FUCKIN PROGRAM. DATS 1000 struct nodeS. WAT UR REFERRING TO ARE struct node *S.

Name: Anonymous 2013-06-21 3:07

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-21 3:09

>>73
WANNA SEE MY PECS YA FUCKIN RETOID?

Name: Mod 2013-06-21 3:21

>>74
Stop insulting everyone and writing in caps. This is my first and last warning.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-21 4:02

>>75
I'LL GET RID OF MY CHARACTER IF >>45'S CODE PROVES TO BE A GOOD READ WHEN I STUDY IT THOROUGHLY LATER ON. IF IT DOESN'T, I'LL WAIT FOR SOME OTHER DECENT PROGRAMMER TO SHOW SOME INTERESTING CODE.

OH YEAH, AND IF YOU ARE A REAL MOD, BACK DA FUCK OFF AND GO HASSLE  THOSE FAGGOTS WHO WHINE ABOUT JEWS ALL DAY LONG. DATS MY FIRST AND LAST FUCKING WARNING. MY POSTS ENCOURAGE PEOPLE TO REED DA FUCKING STANDARD, WRITE USEFUL PROGRAMS, AND THINK CAREFULLY ABOUT PROGRAMMING-RELATED TOPICS. IF UR A SOFTIE WHO WANTS TO CRAWL BACK INTO HIS MOTHER'S WOMB WHENEVER I TELL U UR FULL OF SHIT AND NEED TO REED DA FUCKING STANDARD, UR IN DA WRONG FUCKING PLACE. U KNO WHERE UR MEANT TO BE. GIVE UR FUCKING MOTHER A CALL, >>75. U DON'T HAVE WHAT IT TAKES TO BE A PROGRAMMER.

NOW ARE U FUCKING WIMPS GOING TO MAN DA FUCK UP AND TALK ABOUT PROGRAMMING, OR ARE YOU GONNA GO BACK TO TALKING ABOUT WHICH TOOHOO YOU LIKE BETTER? HUH?

Name: Anonymous 2013-06-21 4:26

>>76
Are you /u/POLITE_ALLCAPS_GUY? :3

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-21 4:32

>>77
I DON'T THINK SO. I WAS SUMMONED BY ALL OF DESE RETOIDS: http://dis.4chan.org/read/prog/1338478276

Name: Anonymous 2013-06-21 6:37

>>78
No, you definitely are /u/POLITE_ALLCAPS_GUY! I was your biggest fan when you posted on reddit, I'm so glad you came here <3 Please keep posting! :3

Name: !!YtwzkeoLMFQUgZv 2013-06-21 14:24

>>66
The idea is to track down the positions of the \n's and the lengths of sentences that come before them, which are stored in .pos and .size correspondingly. It's basically what >>40 described, using indices instead of pointers. I could've saved myself a line, and more importantly a needless loop, by having n = m[j].size > n ? m[j].size : n; inside the second loop.

Your (char) cast is sheisty, me thinks. Also, it'd be fun if you'd cast [code]ptr[code] to be a variable length array and used it with its indices instead of multiplying. Props for nice code.

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