Created
June 5, 2016 02:22
-
-
Save DJMcMayhem/e4501fae1be88f45e5b3dceea69b36f9 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
from math import ceil as c | |
def best_score(n): | |
score = lambda l:abs(l[1]-l[0])+(l[0]*l[1]-n) | |
possible = [] | |
for i in range(1,n+1): | |
possible.append((i, c(n/i))) | |
return min(possible, key=score) | |
for i in range(1, 100): | |
print("{}:\t{}".format(i, best_score(i))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment