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 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 |
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
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 |
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
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 |
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
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 |
NewerOlder