Skip to content

Instantly share code, notes, and snippets.

Created February 10, 2012 21:39
Show Gist options
  • Save anonymous/1793135 to your computer and use it in GitHub Desktop.
Save anonymous/1793135 to your computer and use it in GitHub Desktop.
Embedly problem 3 in python
import math
totalWords = 0
for denominator in range(1, 901):
numOccurrences = 2520.0 / denominator
numOccurrences = math.floor(numOccurrences + 0.5)
totalWords = totalWords + numOccurrences
print 'the text has %d total words' % totalWords
halfTheWords = totalWords / 2
for denominator in range(1, 901):
halfTheWords -= 2520 / denominator
print "round %d: %d" % ( denominator, halfTheWords )
if halfTheWords < 0:
print denominator
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment