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
import sys | |
import pickle | |
import json | |
def usage(): | |
print("Usage:") | |
print(f"\t{sys.argv[0]} --tojson [PICKLE FILES]") | |
print(f"\t{sys.argv[0]} --topickle [JSON FILES]") | |
JD = json.JSONDecoder() |
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> | |
#include <time.h> | |
unsigned long long counts[6] = {0}; | |
unsigned long long trials = 0; | |
void | |
roll_dice(void) | |
{ |
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> | |
#define FIRST(N, ...) (N) | |
#define foreach(X, F, ...) \ | |
for (init_##F(__VA_ARGS__), X = F(FIRST(__VA_ARGS__));\ | |
FIRST(__VA_ARGS__)->_running;\ | |
X = F(FIRST(__VA_ARGS__))) | |
struct count_state { | |
int _running; |
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
import numpy as np | |
from svg import * | |
compose = lambda f: lambda g: lambda *a, **k: f(g(*a, **k)) | |
PURPLE = '#6a1eb0' | |
ORANGE = '#ff824a' | |
BLUE = '#75c1ff' | |
VP_WIDTH = 2.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
anyp(pred, seq) := lreduce(lambda([P, x], P or pred(x)), seq, false); | |
allp(pred, seq) := lreduce(lambda([P, x], P and pred(x)), seq, true); | |
walklength(seq) := (length(seq)-1)/2; | |
walkverts(seq) := makelist(seq[2*i-1], i, 1, walklength(seq)+1); | |
walkedges(seq) := makelist(seq[2*i], i, 1, walklength(seq)); | |
closedp(seq) := is(first(seq) = last(seq)); | |
vertexset(G) := first(G); | |
edgeset(G) := second(G); |
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 <stdint.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#define POOL_NODE_HEADERS struct pool_node *prev, *next | |
struct pool_node { | |
POOL_NODE_HEADERS; | |
}; |
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> | |
#define BUF_SZ (1 << 16) | |
size_t | |
find_unicode(char *p, size_t n) | |
{ | |
size_t i; | |
for (i = 0; i < n; ++i) { | |
if (p[i] & 128) |
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
.PHONY: default | |
default: menger8.png | |
%.png: %.pbm | |
convert $^ $@ | |
menger%.pbm: menger | |
./$^ $* > $@ | |
menger%.svg: menger.py |
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
.PHONY: default | |
default: keys | |
./keys | |
keys: CFLAGS += -lcrypto |
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 list_entry { | |
struct list_entry *next; | |
int value; | |
}; | |
struct list { | |
struct list_entry *head; |