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 <assert.h> | |
#include <stdarg.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
enum type { | |
NIL, |
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
""" | |
a = 1 | |
b = 1 | |
i = 2 | |
n = 10 | |
while i < n | |
c = a + b | |
a = b | |
b = c | |
i = i + 1 |
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 |
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
#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
#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
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
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
<?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
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()) |
OlderNewer