Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
int getword(char *fmt, int delim, FILE *buf)
{
int c, x;
while (((c = getchar()) != EOF) && (c != delim))
fmt[x++] = c;
return x;
}
void strstrip(int x, char *buf)
{
int i, j;
for (i = 0; i < x; i++) {
for (j = 0; buf[j+1] != '\0'; j++)
buf[j] = buf[j+1];
buf[j] = '\0';
}
}
@aaronryank
aaronryank / node.h
Last active November 30, 2016 05:28
typedef struct node {
long val;
struct node *next;
} node_t;
extern void print_list(node_t *);
extern void push(node_t *, long);
extern int pop(node_t **);
extern int remove_last(node_t *);
extern int remove_by_index(node_t **, int);
// retrieve 'https://gist.githubusercontent.com/aaronryank/28e6786b812ffa7976260aeb1ec1851b/raw/bf88b6c195a5486a98dec294d4ee887e18aa061b/node.h' before compiling
#include "node.h"
#include <stdio.h>
#include <stdlib.h>
void print_list(node_t * head) {
node_t * current = head;
while (current != NULL) {
printf("%ld\n", current->val);
#include <stdlib.h>
#include "include/string.h"
const char *errlist[] = {
"no error (operation succeeded", /* 0 */
"not owner", /* EPERM */
"no such file or directory", /* ENOENT */
"no such process", /* ESRCH */
"interrupted system call", /* EINTR */
"I/O error", /* EIO */
/* apparently I can't write a freaking string-reverse algorithm
stackoverflow.com/a/784567/6850771 */
char *reverse(char *str)
{
char tmp, *src, *dst;
size_t len;
if (str != NULL)
{
len = strlen (str);
if (len > 1) {
#! /bin/bash
# C1R compiler
# remove HTML tags, but replace "<br />" by newlines
function removeHTMLtags() {
sed -e 's~<br */>~\
~g' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'
}
10 TEXT : HOME : PRINT "STD. DEV. = ";: INPUT s1
20 HGR : HCOLOR = 3
30 w = 279: h = 159
40 w0 = w - 100: w1 = w0/10
45 h1 = h - 100: h2 = h - 60
50 k = 0.5: m = 1 / (2 * 3.14159265 * s1 * s1)
60 FOR i = 0 TO 10 STEP k
70 x = 10 * i + 1: y = 10 * i + h1
75 HPLOT x,y
80 FOR j = 0 TO w0 STEP 1
1 GR:POKE-16302,0:I=0:O=15:P=1:Q=1:FORY=7TO47:I=I-1:IF(I<=0)THENI=7:READC:COLOR=C
2 IF(Y<21)THENO=O-((21-Y)/12):GOTO4
3 O=O+P-1:P=P*Q:Q=Q+0.002
4 HLINO,39-O ATY:NEXT:DATA12,13,9,1,3,6:COLOR=0:HLIN16,22 AT7:HLIN18,20 AT8:HLIN16,22 AT47:HLIN18,20 AT46:VLIN14,34 AT32:VLIN15,33AT 31:VLIN16,32 AT30:VLIN18,30 AT29:VLIN22,26 AT28:COLOR=12:FORA=0TO3:VLINA,A+4 AT22-A:NEXT
/* Here are some ways you can golf your program:
Line 11 (in this gist): remove space
Lines 54, 55, 59, 60, 64, 65 - did you count the newlines? They are unnecessary.
Line 69 - might as well change to "g.pgm" or just "g", the full filename and probably the extension are unnecessary. You could probably just include in the answer that it "creates a PGM file (without extension) called g"
Pretty much every line - I see you've got variables named 2-byte names such as m4, vc, xe, etc. Have you really used every single uppercase/lowercase single-byte variable name?
Line 53 - You've got a function `void xw`, can't you save a byte by making it `int` (or three by making it B) and never using the return value?
Line 61 - You've got a variable named `grid`, might as well change this to a one-byte name or at least two-byte
*/
#include<array>