Created
February 10, 2012 21:39
-
-
Save anonymous/1793135 to your computer and use it in GitHub Desktop.
Embedly problem 3 in python
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
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