Skip to content

Instantly share code, notes, and snippets.

@yrik
Created February 11, 2012 13:59
Show Gist options
  • Save yrik/1799533 to your computer and use it in GitHub Desktop.
Save yrik/1799533 to your computer and use it in GitHub Desktop.
embed.ly tasks
from math import factorial
for n in range(150, 955):
fact = factorial(n)
print 'len=', len(str(fact))
sum = 0
for s in str(fact):
sum += int(s)
print 'sum=', sum
if sum >= 8001:
print 'WOHHO, input=', n
print fact
break
from BeautifulSoup import BeautifulSoup
import urllib2
from math import sqrt
doc = urllib2.urlopen('http://apply.embed.ly/static/data/2.html').read()
soup = BeautifulSoup(doc)
p_elements = soup.findAll('p')
arr = []
for p in p_elements:
print p
n = len(p.findParents()) - 3 # do not calch tml & body objects
print n
arr += [n, ]
print '--' * 8
print arr
avg = sum(arr) / len(arr)
print 'avg=', avg
ss = 0
for x in arr:
ss += (x - avg) * (x - avg)
deviation = sqrt(ss / len(arr))
print 'deviation =', deviation
s = 0
for x in range(1, 901):
s += 1/float(x)
total = s
print 'total', total
s = 0
for x in range(1, 901):
s += 1/float(x)
if s >= total/2:
print 'x=', x
print 's=', s
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment