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
#!/usr/bin/env python3 | |
result = 0 | |
for n in range(1,101): | |
result +=5*n*n | |
print (result) |
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
class Node: | |
def __init__(self, num: int) -> None: | |
self.num = num | |
self.next = None | |
class LinkedList: | |
def __init__(self): | |
self.len = 0 | |
self.head = None |
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 <stdio.h> | |
#include <unistd.h> | |
struct alloc { | |
void* data; | |
long size; | |
}; | |
struct alloc thememory[BUFSIZ]; | |
struct alloc frees[BUFSIZ] = {0}; | |
long num_allocs = 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
#!/bin/bash | |
valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all $@ |
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 <stdio.h> | |
void recur() { | |
printf("me: what's the topic, brearne: recursion"); | |
recur(); | |
} | |
int main() { recur(); } |
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 <stdio.h> | |
#include <stdlib.h> | |
struct pair { | |
int first, second; | |
}; | |
void printpair(const struct pair* apair) { | |
printf("first: %d, second: %d\n", apair->first, apair->second); | |
} |
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 <stdio.h> | |
#include <stdlib.h> | |
#define ADDRESSOF(X) &(X) | |
#define CONTENTSOF(X) *(X) | |
void swap(int* a, int* b) { | |
int temp = *a; | |
*a = *b; | |
*b = temp; |
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 <stdio.h> | |
#include <stdlib.h> | |
/* global variable - you should avoid these especially | |
* with parallel programming as they are hard to debug | |
*/ | |
int i = 42; | |
void printptr(void *ptr) { | |
/* prints the size of a pointer followed by its address. You |
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
#target: prereqs | |
# command | |
CFLAGS=-Wall -Werror -std=gnu99 | |
LDFLAGS=-lm | |
CC=gcc | |
SOURCES=fooimp.c something.c | |
HEADERS=fooimp.h | |
OBJS=fooimp.o something.o |