Skip to content

Instantly share code, notes, and snippets.

@jakedobkin
Created January 4, 2012 02:52
Show Gist options
  • Save jakedobkin/1558222 to your computer and use it in GitHub Desktop.
Save jakedobkin/1558222 to your computer and use it in GitHub Desktop.
Euler 85
# 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