I hereby claim:
- I am radcliffe on github.
- I am davidradcliffe (https://keybase.io/davidradcliffe) on keybase.
- I have a public key ASBWhG5ALZNc5XvD37ywxw3cD2PTJ0m8JgLl7saGGXndGgo
To claim this, I am signing this object:
height | n | |
---|---|---|
0 | 1 | |
1 | 1 | |
2 | 2 | |
3 | 5 | |
4 | 10 | |
5 | 18 | |
6 | 32 | |
7 | 59 | |
8 | 102 |
# This Python 3 script solves the "Four Fours" problem and similar problems. | |
# The example at the end of the script generates all combinations of [2,3,5,7] | |
# that equal 10, using the operations of addition, subtraction, multiplication, | |
# and division. | |
# Exact arithmetic is used. Only integer exponents between -99 and 99 are allowed. | |
from fractions import Fraction |
import requests | |
from bs4 import BeautifulSoup | |
def main(): | |
url = 'http://projects.fivethirtyeight.com/2016-election-forecast/mobile-bar.html' | |
r = requests.get(url) | |
soup = BeautifulSoup(r.text, 'lxml') | |
return [(p.contents[0], p.contents[1].text) | |
for p in soup.find_all('p', class_ = 'value-wrap')] |
def isprime(n): | |
"""Check if a number is prime, using trial division""" | |
return n>1 and all(n % d for d in range(2, int(n**.5) + 1)) |
#!/usr/bin/env python | |
# This programs solves additive cryptarithms using brute force. | |
# Example: solve_cryptarithm(['SEND', 'MORE', 'MONEY']) returns a list of | |
# all solutions to the equation SEND + MORE = MONEY, where each letter | |
# stands for a different digit in base 10. Leading zeros are not allowed. | |
from itertools import permutations |
#!/usr/bin/env python | |
# This little Python script was written to explain XKCD comic #1787 (Voice Commands). | |
# In the comic, Cue Ball has reprogrammed his phone to use the Dvorak keyboard layout | |
# for voice recognition. (See http://xkcd.com/1787/) | |
# For those who don't know, the standard keyboard layout in the United States is called | |
# QWERTY, after the first six letters in the first row of letters. But there are a few | |
# enthusiasts who advocate an alternative layout, called Dvorak. These layouts have the | |
# same characters, but in different positions, as shown below. |
year | name | fear | sadness | joy | anger | disgust | |
---|---|---|---|---|---|---|---|
1789 | Washington | 0.431542 | 0.212422 | 0.297166 | 0.155104 | 0.456401 | |
1793 | Washington | 0.170726 | 0.110822 | 0.080267 | 0.238734 | 0.51617 | |
1797 | Adams | 0.482235 | 0.498792 | 0.538104 | 0.094651 | 0.475888 | |
1801 | Jefferson | 0.592254 | 0.539775 | 0.523261 | 0.139209 | 0.172762 | |
1805 | Jefferson | 0.658992 | 0.230946 | 0.508855 | 0.136953 | 0.441134 | |
1809 | Madison | 0.407716 | 0.46959 | 0.503345 | 0.398835 | 0.168831 | |
1813 | Madison | 0.410416 | 0.496523 | 0.167754 | 0.422014 | 0.508343 | |
1817 | Monroe | 0.184481 | 0.188871 | 0.550531 | 0.132109 | 0.445847 | |
1821 | Monroe | 0.135458 | 0.258702 | 0.540292 | 0.135676 | 0.441433 |
StateCode|StateName|StateDate | |
AK|Alaska|1959-01-03 | |
AL|Alabama|1819-12-14 | |
AR|Arkansas|1836-06-15 | |
AZ|Arizona|1912-02-14 | |
CA|California|1850-09-09 | |
CO|Colorado|1876-08-01 | |
CT|Connecticut|1788-01-09 | |
DE|Delaware|1787-12-07 | |
FL|Florida|1845-03-03 |
# Filename: pick_state.py | |
# To run this file, type | |
# python pick_state.py | |
# in a terminal window. | |
# This script requires the file us_states.txt which is available at | |
# https://gist.github.com/Radcliffe/7a3e0fe2efc0a9aeb523abfac67865db | |
import csv |
I hereby claim:
To claim this, I am signing this object: