Skip to content

Instantly share code, notes, and snippets.

@lessandro
Created February 10, 2012 23:00
Show Gist options
  • Save lessandro/1793818 to your computer and use it in GitHub Desktop.
Save lessandro/1793818 to your computer and use it in GitHub Desktop.
embedly challenge
# 1
def d(n):
return sum([int(m) for m in str(n)])
i = 1
n = 1
while True:
n *= i
if (d(n) == 8001):
print 'FOUNDDD'
print i
i += 1
#############
# 2
t = open('2.txt').read()
i = -1
d = 0
while True:
i += 1
if t[i:i+2] == '</':
d -= 1
continue;
if t[i:i+3] == '<p>':
print d
if t[i:i+1] == '<':
d += 1
# then i copy/pasted the output into wolfram alpha to get the std.
################
# 3
def z(n):
f = 2520.0
a = [f / i for i in xrange(1, n+1)]
h = sum(a)/2
print h
s = 0
for i,v in enumerate(a):
s += v
print i+1, v, s, h, s > h
z(900)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment