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
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Jan 10 18:34:00 2015 | |
@author: matt | |
""" | |
from __future__ import print_function | |
from functools import wraps | |
from collections import defaultdict | |
path = "../localanagrampage/wordswithfriends.txt" |
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 itertools | |
nationalities = ["Brit", "Dane", "Norwegian", "German", "Swede"] | |
# assign arbitrary number to each nationality | |
Brit, Dane, Norwegian, German, Swede = range(len(nationalities)) | |
# this returns an iterater over all the permutations of 5 numbers | |
choices = lambda: itertools.permutations(range(len(nationalities))) | |
next_to_ltor = lambda l, r: l - 1 == r | |
next_to = lambda l, r: abs(l - r) == 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
# -*- coding: utf-8 -*- | |
from __future__ import division | |
import struct | |
import zlib | |
def yield_block(header, data): | |
assert len(header)==4, 'header must be 4 bytes!' | |
# length: | |
yield struct.pack('! L', len(data)) | |
# chunk type, 4 byte header |
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
# how exactly do conditions work?? | |
from threading import Thread, Condition, Lock | |
import logging | |
logging.basicConfig() | |
log = logging.root | |
log.setLevel(logging.DEBUG) | |
mylock = Lock() | |
def wait_for_cond(c, msg): |
NewerOlder