Skip to content

Instantly share code, notes, and snippets.

@zrbecker
zrbecker / test.cpp
Last active December 14, 2015 09:08
#include <GL/glfw.h>
#include <math.h>
#if defined(_WIN32)
#include <windows.h>
extern int main(int argc, char* argv[]);
### Graphics Variables
from Tkinter import *
WIDTH = 500.0
HEIGHT = 500.0
root = Tk()
canvas = Canvas(width=WIDTH, height=HEIGHT, bg="black")
moonshape = 0
function range(start, stop, step) {
if (typeof stop == 'undefined') {
stop = start;
start = 0;
}
if (typeof step == 'undefined')
step = 1;
if ((step > 0 && start >= stop) || (step < 0 && start <= stop))
return [];
def rwh_primes(n):
sieve = [True] * n
for i in xrange(3,int(n**0.5)+1,2):
if sieve[i]:
sieve[i*i::2*i]=[False]*((n-i*i-1)/(2*i)+1)
return [2] + [i for i in xrange(3,n,2) if sieve[i]]
n = 10 ** 7
q = 11
primes = rwh_primes(n)
/*
* PNGImage.cpp
*
* Created on: Jul 16, 2012
* Author: zrbecker
*/
#include "PNGImage.h"
#include <png.h>
/*
* == Altered ==
* assign() is overloaded in c++. Changed assign(n, u) to
* assign_val(n, u);
*
* The insert and erase function use index instead of iterator
* to determine where stuff is inserted/erased
*
* == Not implemented ==
* any operator overloading, obviously
#include <stdlib.h>
#include <stdio.h>
#define max(x, y) ((x) > (y)) ? (x) : (y)
#define C_VECTOR(T) \
typedef struct _c_vector_##T { \
size_t capacity; \
size_t size; \
@zrbecker
zrbecker / turing.py
Created June 17, 2012 19:59
Turing Machine
class TapeException(BaseException):
pass
class Machine:
def __init__(self, state, tape, machine, negsize=1):
self.state = state
self.tape = tape
self.machine = machine
self.negsize = negsize
@zrbecker
zrbecker / graphs.c
Created February 28, 2012 21:20
Disjoint Set System
#include <stdio.h>
#include <stdlib.h>
typedef struct edge_s {
int i;
int j;
} Edge;
typedef struct graph_s {
@zrbecker
zrbecker / expire.py
Created February 5, 2012 09:40
Expiration Date
def Permute(list):
if len(list) == 0:
return []
elif len(list) == 1:
return [list]
else:
perms = []
for n in list: