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
#!/usr/bin/env python | |
# Simulation of the 'Can you cross the river' riddler problem: | |
# https://fivethirtyeight.com/features/night-falls-a-storm-rolls-in-can-you-cross-the-river/ | |
# | |
# n | |
# / | \ | |
# a - b - c | |
# | | | | |
# d - e - f | |
# \ | / |
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 __future__ import division, print_function | |
from itertools import permutations, combinations_with_replacement, product | |
def guarded_exponentiation(a,b): | |
""" | |
Raise a to the power of b, but only if the result won't be silly large, as | |
silly largeness slows us way down. | |
""" | |
if (a > 1 or a < -1) and b > 1000: | |
raise OverflowError |
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
### Keybase proof | |
I hereby claim: | |
* I am yourcelf on github. | |
* I am cfd (https://keybase.io/cfd) on keybase. | |
* I have a public key whose fingerprint is A1F8 409D BC1A 0A62 AD20 EC7F 2BAC A497 F566 4872 | |
To claim this, I am signing this object: |
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
=> Started proxy. | |
=> Meteor 0.9.1.1 is available. Update this project with 'meteor update'. | |
=> Started MongoDB. | |
npm: updating npm dependencies -- temp, path, request, twilio, googleapis... | |
I20140912-15:30:22.408(-6)? [velocity] PWD /home/dev/git/Admit | |
I20140912-15:30:22.518(-6)? Check for test package configs... [ 'packages/HTML5-History-API/smart.json', | |
I20140912-15:30:22.518(-6)? 'packages/autoform/smart.json', | |
I20140912-15:30:22.519(-6)? 'packages/blaze-layout/smart.json', | |
I20140912-15:30:22.519(-6)? 'packages/bootstrap-3/smart.json', | |
I20140912-15:30:22.527(-6)? 'packages/bootstrap3-wysihtml5/smart.json', |
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
I20140910-08:17:22.677(-6)? [velocity] retrying mirror at http://localhost:5000/ connect ECONNREFUSED | |
npm: updating npm dependencies -- temp, path, request, twilio, googleapis... | |
I20140910-08:17:37.236(-6)? Jasmine-Unit is loaded | |
I20140910-08:17:37.463(-6)? [PackageStubber] custom stub found for core package jquery | |
I20140910-08:17:37.463(-6)? [PackageStubber] custom stub found for core package underscore | |
I20140910-08:17:37.465(-6)? [PackageStubber] community stub found for iron-core | |
I20140910-08:17:37.466(-6)? [PackageStubber] community stub found for iron-router | |
I20140910-08:17:37.466(-6)? [PackageStubber] community stub found for router | |
I20140910-08:17:37.466(-6)? [PackageStubber] won't auto-stub these packages: [ 'jasmine-unit', | |
I20140910-08:17:37.466(-6)? 'jasmine', |
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
# Obtained from http://code.activestate.com/recipes/252124-latex-codec/ | |
latex_equivalents = { | |
0x0009: ' ', | |
0x000a: '\n', | |
0x0023: '{\#}', | |
0x0026: '{\&}', | |
0x00a0: '{~}', | |
0x00a1: '{!`}', | |
0x00a2: '{\\not{c}}', | |
0x00a3: '{\\pounds}', |
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
# Find unintentional palindromes in a text file. | |
import re | |
import argparse | |
from collections import defaultdict | |
parser = argparse.ArgumentParser(description="Find unintentional palindromes in a text file.") | |
parser.add_argument("filename", help="The name of the file to look in.") | |
parser.add_argument("--min", help="Minimum length", default=4) | |
parser.add_argument("--max", help="Maximum length", default=500) |
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
#!/usr/bin/env python | |
import sys | |
import subprocess | |
ports = sys.argv[1:] or [8000] | |
procs = [] | |
for port in ports: | |
procs.append( |
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
#!/usr/bin/env python | |
from __future__ import print_function | |
import sys | |
import subprocess | |
import argparse | |
import textwrap | |
import signal | |
stations = { |
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
#!/usr/bin/env python3.2 | |
import os | |
import sys | |
import hashlib | |
import argparse | |
from functools import partial | |
def md5sum(filename): | |
# http://stackoverflow.com/a/7829658 |
NewerOlder