Created
January 4, 2012 02:52
-
-
Save jakedobkin/1558222 to your computer and use it in GitHub Desktop.
Euler 85
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
# http://projecteuler.net/problem=85 | |
# notes- formula to count boxes is just x * x+1 / 2 * y * y+1 /2 | |
# this is triangle number x * triangle number y | |
def triangle(n): | |
return n*(n+1)/2 | |
# i found the ranges by trial and error, starting at 100 each | |
min = 2000000 | |
for a in range (0,37): | |
for b in range (0,78): | |
rect = abs(2000000-(triangle(a)*triangle(b))) | |
if rect < min: | |
min = rect | |
print min,a*b | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment