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 | |
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| # Use this with something like | |
| # Vagrant::Config.run do |config| | |
| # config.vm.box = "lucid32" | |
| # config.vm.forward_port 22, 2223 | |
| # config.vm.forward_port 80, 8080 |
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 random | |
| class tt(tuple): | |
| def __str__(self): | |
| pass | |
| empty = None | |
| red, black = range(2) | |
| color, left, root, right = range(4) |
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
| data Tree' a = E' | Tree' (Tree' a) a (Tree' a) | |
| foo' = Tree' E' 0 E' | |
| foo = Tree' (Tree' E' 1 E' ) 0 (Tree' E' 1 (Tree' E' 0 E')) | |
| foo'' = Tree' E' 0 (Tree' E' 1 E') | |
| height t = case t of | |
| E' -> 0 | |
| Tree' s1 x s2 -> if h1 > h2 then h1 + 1 else h2 + 1 | |
| where |
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
| data Tree' a = E' | Tree' (Tree' a) a (Tree' a) | |
| foo' = Tree' E' 0 E' | |
| foo = Tree' (Tree' E' 1 E' ) 0 (Tree' E' 1 (Tree' E' 0 E')) | |
| foo'' = Tree' E' 0 (Tree' E' 1 E') | |
| height t = case t of | |
| E' -> 0 | |
| Tree' s1 x s2 -> if h1 > h2 then h1 + 1 else h2 + 1 | |
| where |
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
| data Tree' a = E' | Tree' (Tree' a) a (Tree' a) | |
| foo' = Tree' E' 0 E' | |
| foo = Tree' (Tree' E' 1 E' ) 0 (Tree' E' 1 (Tree' E' 0 E')) | |
| foo'' = Tree' E' 0 (Tree' E' 1 E') | |
| height t = case t of | |
| E' -> 0 | |
| Tree' s1 x s2 -> if h1 > h2 then h1 + 1 else h2 + 1 | |
| where |
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 random | |
| empty = None | |
| color, left, root, right, red, black = range(6) | |
| rbnode = lambda c, l, t, r: {color: c, left: l, root: t, right: r} | |
| def member(x, tree): | |
| if tree == empty: |
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
| # Inplace quicksort in python | |
| from functools import partial | |
| import operator | |
| import random | |
| import time | |
| def partition(list_, l, r, p): | |
| pVal = list_[p] | |
| list_[p], list_[r] = list_[r], list_[p] |
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
| /* Takes a list of int args to sort */ | |
| #include <stdio.h> | |
| void swap(int array[], int n, int m) { | |
| int tmp = 0; | |
| tmp = array[n]; | |
| array[n] = array[m]; | |
| array[m] = tmp; |
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
| from itertools import islice | |
| import random | |
| def merge_sort(l): | |
| if len(l) <= 1: | |
| return l | |
| left = [] | |
| right = [] | |
| middle = len(l) / 2 |
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 random | |
| def insert_sort(l): | |
| for i, item in enumerate(l): | |
| while i > 0 and l[i - 1] > item: | |
| l[i] = l[i - 1] | |
| i -= 1 | |
| l[i] = item |