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
<html> | |
<head> | |
<script type="text/javascript" | |
src="http://d3js.org/d3.v3.min.js" | |
charset="utf-8"> | |
</script> | |
<style type="text/css"> | |
.two-col { | |
display: -ms-flex; |
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 operator import itemgetter | |
def inefficient_most_common(d, n): | |
""" | |
Returns the n most common words in a dictionary. | |
Args: | |
d: A dictionary of the frequencies or counts. | |
n: An integer representing the number of words to be returned. |
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 random import randint | |
from sys import maxint | |
import tempfile | |
import array | |
def write_a_million_ints(): | |
f = file("ints.bin", "wb") | |
ints = array.array('i', [randint(-maxint + 1, maxint - 1) for i in range(1000000)]) | |
ints.tofile(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
{ | |
"metadata": { | |
"name": "" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Jun 27 09:46:27 2013 | |
@author: joshua | |
""" | |
import matplotlib.pyplot as plt | |
vectors = [[1, 2], [3, 4], [-2, -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
import random | |
def initialize_urn(): | |
reds = ["red" for i in range(50)] | |
blacks = ["black" for i in range(50)] | |
return reds + blacks | |
def get_pair(urn): | |
choice_1 = random.choice(urn) | |
urn.remove(choice_1) |
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 math import sqrt | |
# A dictionary of movie critics and their ratings of a small set of movies | |
critics={'Lisa Rose': {'Lady in the Water': 2.5, 'Snakes on a Plane': 3.5, | |
'Just My Luck': 3.0, 'Superman Returns': 3.5, 'You, Me and Dupree': 2.5, | |
'The Night Listener': 3.0}, | |
'Gene Seymour': {'Lady in the Water': 3.0, 'Snakes on a Plane': 3.5, | |
'Just My Luck': 1.5, 'Superman Returns': 5.0, 'The Night Listener': 3.0, | |
'You, Me and Dupree': 3.5}, | |
'Michael Phillips': {'Lady in the Water': 2.5, 'Snakes on a Plane': 3.0, |
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
""" | |
Student was an AI program developed in the late sixties which used | |
pattern matching to solve basic algebraic word problems. This an | |
attempt to implement Student in Python through study of the Common | |
Lisp imlpementation outlined in Paradigms of Artificial Intelligence | |
Programming: Case Studies in Common Lisp (PAIP) by Peter Norvig. | |
""" | |
import operator | |
import re |
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
(ns paip.eliza | |
(:require [clojure.string :as string]) | |
(:gen-class)) | |
(defn index-of | |
"Returns the index of item. If start is given indexes prior to | |
start are skipped." | |
([coll item] (.indexOf coll item)) | |
([coll item start] |
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 datetime | |
from dateutil.relativedelta import relativedelta | |
def relative_month(d, months): | |
"""Accepts a datetime or date object and returns another datetime object. | |
The returned datetime is the start of the datetime n months away. This does | |
not have side effects. | |
Args: | |
d - a date or datetime object |
NewerOlder