Created
February 13, 2012 00:44
-
-
Save oneporter/1812238 to your computer and use it in GitHub Desktop.
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
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 |
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 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) |
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
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