Skip to content

Instantly share code, notes, and snippets.

@iconjack
iconjack / flaw.py
Created January 1, 2016 15:45
shows what happens when you mix large and small sample sizes
import matplotlib.pyplot as plt
from pylab import savefig
import numpy as np
from numpy.random import rand, randint
def flipsome(n):
flip = lambda: randint(0,2)
return sum(flip() for _ in range(n)) / float(n)
interval = 1000
@iconjack
iconjack / kenled
Created July 31, 2014 05:06
Solutions to Ken's LED Puzzle
digits = [
# B C D A B C A B C
# E F F F F
# G H H H H
# I L L J K J K
# M N N M N
# O P P O P
# R S T Q R S T Q R S
from math import sqrt
from itertools import permutations
def squarable(sides):
area = sum(map(lambda (a,b): a*b, sides))
S = sqrt(area)
if S == int(S):
# check Ken's conditions
@iconjack
iconjack / ibm.py
Created May 30, 2013 22:40
just a test
from fractions import gcd
M = 19*41*47*61
totient = 18*40*46*60
def p(n):
return (n*n*n*n + n*n + n + 1) % M
# compute inverse of a mod M
# or None if no inverse exists