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
n = 9001 | |
total = 0.0 | |
for k in range(1, n+1): | |
total += (-1.0)**(k+1.0)/(2.0*k-1.0) | |
print "Using {0} terms of the series:".format(n) | |
print "Half-tau (a.k.a. pi) ≈ {0}".format(total * 4) | |
print "Tau ≈ {0}".format(total * 8) |
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
HOMEBREW_VERSION: 0.9.5 | |
ORIGIN: https://github.com/Homebrew/homebrew | |
HEAD: 44a59fb8e2575651714d8de186a312ab8f4336bf | |
HOMEBREW_PREFIX: /usr/local | |
HOMEBREW_CELLAR: /usr/local/Cellar | |
CPU: quad-core 64-bit haswell | |
OS X: 10.9.4-x86_64 | |
Xcode: 6.0.1 | |
CLT: 6.0.0.0.1.1410400753 | |
Clang: 6.0 build 600 |
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 copy, itertools, os, random, re, shutil, string | |
from PIL import Image | |
dirs = [ f for f in os.listdir('.') if os.path.isdir(f) and '-' in f ] | |
# Split pairwise data into individual classes. | |
for d in dirs: | |
classes = d.split('-') |
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
function [J, grad] = costFunction(theta, X, y) | |
%COSTFUNCTION Compute cost and gradient for logistic regression | |
% J = COSTFUNCTION(theta, X, y) computes the cost of using theta as the | |
% parameter for logistic regression and the gradient of the cost | |
% w.r.t. to the parameters. | |
% Initialize some useful values | |
m = length(y); % number of training examples | |
% You need to return the following variables correctly |
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 hashlib, sys | |
words = open('/usr/share/dict/words', 'r').read().splitlines() | |
hashes = [ hashlib.md5(w).hexdigest() for w in words ] | |
dictionary = dict(zip(hashes, words)) | |
try: | |
print dictionary[sys.argv[1]] | |
except: | |
print "Could not decrypt hash." |
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, math | |
# Determines the width/height of a square board. | |
def size(board): | |
return int(math.sqrt(len(board))) | |
# Determines whether a flat bingo board (list of length size**2) has five | |
# in a row on any row, column, or diagonal. | |
def bingo(board): | |
s = size(board) |
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 string | |
a = "fouric" | |
b = "nocyno" | |
name_sum = "" | |
name_difference_ab = "" | |
name_difference_ba = "" | |
alphabet = string.ascii_lowercase | |
for index in range(len(a)): |
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 collections | |
import random | |
import re | |
import string | |
alphabet = string.ascii_lowercase | |
# Make a counter for each lowercase letter, and add a count to it | |
# whenever a letter follows it in /usr/share/dict/words | |
counters = {letter: collections.Counter() for letter in alphabet} |
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
n = int(input("Enter a number: ")) | |
def perfect(n): | |
total = 0 | |
for k in range(1, n): | |
if n % k == 0: total += k | |
return total == n | |
message = 'yes' if perfect(n) else 'no' |
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
highest = int(input("Enter a number: ")) | |
def perfect(n): | |
total = 0 | |
for k in range(1, n): | |
if n % k == 0: total += k | |
return total == n | |
for n in range(1, highest+1): |
OlderNewer