This file contains 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
typedef unsigned int sz; | |
typedef unsigned short ix; | |
int compare(const char* a, const char* b, sz n) { | |
while (n) { | |
if (*a != *b) { | |
return (unsigned char)*a - (unsigned char)*b; | |
} | |
if (*a == 0) { | |
return 0; |
This file contains 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
module lt | |
data lt : Nat -> Nat -> Set where | |
succ : lt x (S x) | |
widen : lt x y -> lt x (S y) | |
next : lt x y -> lt (S x) (S y) | |
next succ = succ | |
next (widen p) = widen (next p) |
This file contains 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 itertools | |
def read(filename): | |
graph = {} | |
f = open(filename) | |
n = int(f.readline()) | |
for i in range(n-1): | |
line = f.readline() | |
numbers = map(int, line.split()) |
This file contains 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
<?php if ($_SERVER["REQUEST_METHOD"] == "GET") { ?> | |
<form action="stupid.php" method="post"> | |
<textarea name="source" cols="80" rows="15"> | |
input n | |
i = 1;loopi;if i > n fini | |
j = 1;loopj;if j > n finj | |
product = i * j | |
output i * j = product | |
if j == n last | |
output / |
This file contains 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
void move_robot(int direction); | |
int pick(void); | |
void put(void); | |
#define SIZE 1000 | |
enum { LEFT, RIGHT, UP, DOWN }; | |
enum { NOTHING, TREASURE, BOMB }; | |
static int current_x; |
This file contains 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 Lambda(object): | |
pass | |
class Var(Lambda): | |
def __init__(self, var): | |
self.var = var | |
def __repr__(self): | |
return "Var(%r)" % self.var | |
class Abs(Lambda): |
This file contains 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 BASE 10000 | |
struct number { | |
int n; | |
int *a; | |
}; | |
typedef struct number *N; |
This file contains 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
#load "nums.cma";; | |
#load "prime.cmo";; | |
open Big_int;; | |
let p1 () = | |
let sum = ref 0 in | |
for i = 1 to 1000 - 1 do | |
if i mod 3 = 0 || i mod 5 = 0 then sum := !sum + i | |
done; |
This file contains 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
dx = 1e-10 | |
eps = 1e-3 | |
derive f x = (f (x+dx) - f x) / dx | |
improve f guess x = guess - (f guess - x) / derive f guess | |
good f guess x = abs (f guess - x) < eps | |
iter f guess x = if good f guess x then guess else iter f (improve f guess x) x | |
solve f x = iter f 1.0 x | |
square x = x*x | |
cube x = x*x*x | |
main = do print (solve square 2); print (solve cube 3) |
This file contains 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/sh | |
antlr3 test.g | |
g++ *.cc *.c -o t -lantlr3c |