Created
February 11, 2012 20:50
-
-
Save yassersouri/1804152 to your computer and use it in GitHub Desktop.
Embedly's Challenge
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
def main(): | |
i = 1 | |
while True: | |
i += 1 | |
print i | |
if s(factorial(i)) == 8001: | |
print 'YES' | |
break | |
def factorial(n): | |
fact = 1 | |
for x in range(1, n+1): | |
fact *= x | |
return fact | |
def s(n): | |
return sum(map(int,str(n))) | |
if __name__ == '__main__': | |
main() |
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 HTMLParser import HTMLParser | |
from numpy import array | |
global nums | |
nums = [] | |
class MyHTMLParser(HTMLParser): | |
global i | |
i = 0 | |
def handle_starttag(self, tag, attrs): | |
global i | |
i += 1 | |
if tag == 'p': | |
global nums | |
nums.append(i) | |
def handle_endtag(self, tag): | |
global i | |
i -= 1 | |
def main(): | |
parser = MyHTMLParser() | |
data = "<p>ncetta. Velit ribeye shoulder, et ball tip venison incididunt ut pork chop exercitation spare ribs f</p><div><span>lit ribeye shoulder,</span><p>owl, turducken flank ball tip adipisicing short ribs ham hock anim. Pastrami elit jowl, esse ground </p><span>aola ground round ba</span><span>ccaecat. Adipisicing</span></div><span> aliqua occaecat. Ad</span><div><span>aboris jerky ham sin</span><span>nt laborum id pork l</span></div><span>boris jerky ham sint</span><span>ound round ball tip</span><p> mollit laboris jerky ham sint nisi turkey aliqua. Pig non velit pork jowl, turducken flank ball tip</p><span>t jowl, esse ground</span><span>e tongue short ribs </span><p> t-bone excepteur magna ullamco sausage drumstick pancetta. Velit ribeye shoulder, et ball tip venis</p><p>ncetta incididunt nulla. Quis in t-bone excepteur magna ullamco sausage drumstick pancetta. Velit ri</p><p>is jerky ham sint nisi turkey aliqua. Pig non velit pork jowl, turducken flank ball tip adipisicing </p><p>adipisicing, hamburger ad fugiat pork loin venison aute bresaola ground round ball tip prosciutto t-</p><p>Ribeye ut pig aliqua occaecat. Adipisicing voluptate fatback, mollit laboris jerky ham sint nisi </p><p>am sint nisi turkey aliqua. Pig non velit pork jowl, turducken flank ball tip adipisicing short ribs</p><div><p>ken consequat meatloaf brisket pancetta incididunt nulla. Quis in t-bone excepteur magna ullamco sau</p><p>incididunt upork chop exercitation spare ribs fatback. Voluptate officia adipisicing, hamburger ad</p><p>llamco sausage drumstick pancetta. Velit ribeye shoulder, et ball tip venison incididunt ut pork cho</p><div><span> ground round deseru</span><p>ne. Swine consequat ex reprehenderit. Leberkase eu laborum et, irure tongue short ribs ham hock labo</p><p> adipisicing, hamburger ad fugiat pork loin venison aute bresaola ground round ball tip prosciutto t</p><p>iat pork loin venison aute bresaola ground round ball tip prosciutto t-bone. Swine consequat ex repr</p><div><p>is jerky ham sint nisi turkey aliqua. Pig non velit pork jowl, turducken flank ball tip adipisicing </p><p><span>non velit pork jowl,</span>t. Leberkase eu laborum et,irure tongue short ribs ham hest esse.R</p><p>giat pork loin venison aute bresaola ground round ball tip prosciutto t-bone. Swine consequat ex rep</p><p> prosciutto est esse. Ribeye ut pig aliqua occaecat. Adipisicing voluptate fatback, mollit laboris</p><p>llamco drumstick pancetta. Velit ribeye shoulder, et ball tip venison incididunt ut pork cho</p><div><p>oluptate fatback, mollit laboris jerky ham sint nisi turkey aliqua. Pig non velit pork jowl, turduck</p><p> velit pork jowl, turducken flank ball tip adipisicing short ribs ham hock anim. Pastrami elit jowl,</p><p>ipisicing short ribs ham hock anim. Pastrami elit jowl, esse ground</p><p>elit pork jowl, turducken flank ball tip adipisicing short ribs ham hock anim. Pastrami elit jowl, e</p></div></div></div></div><span>af brisket pancetta </span><p>isicing voluptate fatback, mollit laboris jerky ham sint nisi turkey aliqua. Pig non velit pork jowl</p><p>pancetta incididunt nulla. Quis in t-bone excepteur magna ullamco sausage drumstick pancetta. Velit</p><p>nisi turkey aliqua. Pig non velit pork jowl, turducken flan ball tip adipisicing short ribs ham hoc</p><span>cing short ribs ham </span><p>ciutto est esse. Ribeye ut pig aliqua occaecat. Adipisicing voluptate fatback, mollit laboris jerky</p><p>rehenderit. Leberkase eu laborum et, irure tongue short ribs ham hock labore capicola prosciutto est</p><div><span>atback. Voluptate of</span><p>nsequat ex reprehenderit. Leberkase eu laborum et, irure tongue short ribs ham hock labore capicola </p><span>lder, et ball tip ve</span></div><span>wine consequat ex re</span><p> et, irure tongue short ribs ham hock labore capicola prosciutto est esse. Ribeye ut pig aliqua occ </p><p>pork jowl, turducken flank ball tip adipisicing short ribs ham hock anim. Pastrami elit jowl, esse g</p><span>k loin venison aute </span><p>at ex reprehenderit. Leberkase eu laborum et, irure tongue short ribs ham hock labore capicola prosc</p><p>t pancetta incididunt nulla. Quis in t-bone excepteur magna ullamco sausage drumstick pancetta. Veli</p><div><p>ound round ball tip prosciutto t-bone. Swine consequat ex reprehenderit. Leberkase eu laborum et, ir</p></div><span>ure tongue short rib</span><div><span>ut pork chop exercit</span><p> ham, cow consectetur chicken consequat meatloaf brisket pancetta nulla. Quis in t-bone e</p></div><p>nison incididunt ut pork chop exercitation spare ribs fatback. Voluptate officia adipisicing, hambur</p><div><div><span>equat ex reprehender</span><p>a ullamco sausagedrumstick pancetta. Velit ribeye shoulder, et ball tip venison incididunt utpork </p><span>urducken flank ball </span></div></div><p>ll tip venison incididunt ut pork chop exercitation spare ribs fatback. Voluptate officia adipisicin</p>" | |
parser.feed(data) | |
global nums | |
arr = array(nums) | |
print arr.std() | |
if __name__ == '__main__': | |
main() |
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
def find_total(): | |
first = 2520 | |
total = 0 | |
for i in xrange(1,901): | |
current = first/i | |
total += current | |
return total | |
def main(): | |
total = find_total() | |
s = 0 | |
i = 1 | |
while s < total/2: | |
to_add = 2520/i | |
s += to_add | |
print "i: " ,i | |
print "to_add: ", to_add | |
print "s: " ,s | |
i += 1 | |
print "_____________________" | |
print "total: ", total | |
print "half: ", total/2 | |
print "s: ", s | |
print "number of unique words: ", i + 1 | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment