ploffie

Taxicab fast method

Nov 11th, 2012
45
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from collections import defaultdict
  2.  
  3. N =700
  4. ntriples = 3 # for original Ramanujan problem set to 2
  5.  
  6. results = defaultdict(list)
  7. for x in range(0, N):
  8.     x3 = x ** 3
  9.     for y in range(x, N):
  10.         results[x3 + y ** 3].append((x, y))
  11.  
  12. for key in sorted(results.keys()):
  13.     if len(results[key]) == ntriples:
  14.         print key, results[key]
RAW Paste Data