Skip to content

Instantly share code, notes, and snippets.

@oneporter
Created February 13, 2012 00:44
Show Gist options
  • Save oneporter/1812238 to your computer and use it in GitHub Desktop.
Save oneporter/1812238 to your computer and use it in GitHub Desktop.
fact = 1
ans = 1
def sum_digits(v):
total = 0
for l in str(v):
total += int(l)
return total
while True:
if ans % 100 == 0:
print("Got to {0}".format(ans))
fact *= ans
if sum_digits(fact) == 8001:
print("Ans is {0}".format(ans))
break
ans += 1
from BeautifulSoup import BeautifulSoup as BS
f = open('2.html').read()
bs = BS(f)
ps = bs.findAll('p')
d_from_a = []
for p in ps:
count = 1
cursor = p.parent
while cursor.name != 'article':
count += 1
cursor = cursor.parent
d_from_a.append( count)
print(d_from_a)
avg = sum(d_from_a)/float(len(d_from_a))
stddev = (sum((d-avg)**2 for d in d_from_a)/float(len(d_from_a)))**0.5
print(stddev)
x = 2520
all_nums = [x/float(i) for i in range(1,901)]
count = 1
while sum(all_nums[:count]) < sum(all_nums)/2:
count+=1
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment