Counting rectangles
Problem 85
By counting carefully it can be seen that a rectangular grid measuring 3 by 2 contains eighteen rectangles:

Although there exists no rectangular grid that contains exactly two million rectangles, find the area of the grid with the nearest solution.
def rectangles(x, y):
count = 0
for i in range(y + 1):
for j in range(x + 1):
count += (i * j)
return count
def run():
result = []
# Limit 100 found by trial and error
for x in range(1, 100):
for y in range(x, 100):
tmp = rectangles(x, y)
# Limit found by trial and error
if tmp > 1999000 and tmp < 2001000:
result = [x, y, tmp]
x, y, tmp = result
return x * y