Skip to content

Instantly share code, notes, and snippets.

class Trie():
def __init__(self, words=()):
self.root = {}
for word in words:
self.add(word)
def add(self, word):
current = self.root
for letter in word:
from collections import deque
from itertools import combinations
try:
from itertools import ifilter
except ImportError:
ifilter = filter # python 3
import timeit
def abarnert(n, r):
def good(combo):
@BlckKnght
BlckKnght / TitleWorld.as
Created June 10, 2012 23:09
My version of Mobias's TitleWorld class
package
{
import flash.display.Graphics;
import net.flashpunk.Entity;
import net.flashpunk.FP;
import net.flashpunk.Graphic;
import net.flashpunk.graphics.Image;
import net.flashpunk.graphics.Text;
import net.flashpunk.Tween;
import net.flashpunk.tweens.misc.VarTween;
@BlckKnght
BlckKnght / infinity.py
Created May 28, 2012 07:38
Face to Face rolls using Neutronicus's formulas
def binomial_coefficient(n, k):
"""Returns the binomial coefficient, "n choose k"."""
if k > n-k: # if k is greater than n/2, swap it for n-k which will be
k = n-k
result = 1;
for i in range(k): # loop from 0 to k-1
result *= (n-i) / (i+1) # multiply in one term of the result
return result