Last active
November 6, 2023 01:41
-
-
Save ar1ja/19f92820713b7b0b5770ea4d9e888519 to your computer and use it in GitHub Desktop.
cody .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <time.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#define MIN_VAL 5 | |
#define MAX_VAL 50 | |
static void swap(char *x, char *y) { | |
char c = *x; | |
*x = *y; | |
*y = c; | |
} | |
static void slowsort(char *buf, size_t left, size_t right) { | |
size_t mid; | |
if (left >= right) | |
return; | |
mid = left + (right - left) / 2; | |
slowsort(buf, left, mid); | |
slowsort(buf, mid + 1, right); | |
if (buf[mid] > buf[right]) | |
swap(&buf[mid], &buf[right]); | |
slowsort(buf, left, right - 1); | |
} | |
static void sort(char *buf, size_t len) { slowsort(buf, 0, len - 1); } | |
static char *cody_by_size(size_t len) { | |
if (len <= MIN_VAL) | |
return "^w^"; | |
else if (len <= (MAX_VAL / 3)) | |
return "^-^"; | |
else if (len <= (MAX_VAL / 2)) | |
return "O~O"; | |
else | |
return "x~x"; | |
} | |
int main(void) { | |
char *buf; | |
size_t len, total = 0; | |
srand(time(NULL)); | |
setbuf(stdout, NULL); | |
puts("\\(^-^) Hey, I'm cody!"); | |
sleep(3); | |
puts(",(o~o), Soon, I won't be so well... Gigabytes of data will go " | |
"through me..."); | |
sleep(2); | |
puts("(,-,) Here we go I guess."); | |
sleep(1); | |
do { | |
len = (rand() % (MAX_VAL - MIN_VAL + 1)) + MIN_VAL; | |
total += len; | |
buf = malloc(len); | |
printf("\r~(%s)~ There's currently %zu bytes being fed through me. In " | |
"total %zu bytes were fed through me.", | |
cody_by_size(len), len, total); | |
sort(buf, len); | |
free(buf); | |
} while (1); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <time.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#define MIN_VAL 5000 | |
#define MAX_VAL 50000 | |
static void bullshit_sort(char *buf, size_t len) { | |
size_t idx, jdx, kdx; | |
char tmp; | |
for (kdx = 0; kdx < len; ++kdx) { | |
for (idx = 0; idx < len; ++idx) { | |
for (jdx = 0; jdx < len - idx; ++idx) { | |
if (buf[jdx] > buf[jdx + 1]) { | |
tmp = buf[jdx]; | |
buf[jdx] = buf[jdx + 1]; | |
buf[jdx + 1] = tmp; | |
} | |
} | |
} | |
} | |
} | |
static char *cody_by_size(size_t len) { | |
if (len <= MIN_VAL) | |
return "^w^"; | |
else if (len <= (MAX_VAL / 3)) | |
return "^-^"; | |
else if (len <= (MAX_VAL / 2)) | |
return "O~O"; | |
else | |
return "x~x"; | |
} | |
int main(void) { | |
char *buf; | |
size_t len, total = 0; | |
srand(time(NULL)); | |
setbuf(stdout, NULL); | |
puts("\\(^-^) Hey, I'm cody!"); | |
sleep(3); | |
puts(",(o~o), Soon, I won't be so well... Gigabytes of data will go " | |
"through me..."); | |
sleep(2); | |
puts("(,-,) Here we go I guess."); | |
sleep(1); | |
do { | |
len = (rand() % (MAX_VAL - MIN_VAL + 1)) + MIN_VAL; | |
total += len; | |
buf = malloc(len); | |
printf("\r~(%s)~ There's currently %zu bytes being fed through me. In " | |
"total %zu bytes were fed through me.", | |
cody_by_size(len), len, total); | |
bullshit_sort(buf, len); | |
free(buf); | |
} while (1); | |
return 0; | |
} |
Author
ar1ja
commented
Nov 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment