Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Solving 85, woot

  • Loading branch information...
commit 791ad71a863886ae066f05cb0e7024f37ab129b7 1 parent 9df60a7
Charles Leifer authored May 08, 2012

Showing 1 changed file with 22 additions and 0 deletions. Show diff stats Hide diff stats

  1. 22  problem85.py
22  problem85.py
... ...
@@ -0,0 +1,22 @@
  1
+#!/usr/bin/env python
  2
+
  3
+def ct(m, n):
  4
+    return ((n*n + n) * (m*m + m)) / 4
  5
+
  6
+diff = 1000000
  7
+bits = None
  8
+
  9
+# don't know how to calculate the minimum of
  10
+# (n^2 + n)(m^2 + m) - 4000000 = 0
  11
+
  12
+# know that 1, 2000 = 2001000, so we can assume
  13
+# upper bound is 2000
  14
+
  15
+for i in range(2, 2000):
  16
+    for j in range(i, 2000):
  17
+        x = ct(i, j)
  18
+        new_diff = abs(2000000 - x)
  19
+        if new_diff < diff:
  20
+            diff = new_diff
  21
+            bits = x, i, j, i*j 
  22
+print '%s...%s * %s = %s' % bits

0 notes on commit 791ad71

Please sign in to comment.
Something went wrong with that request. Please try again.