Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import itertools as it
  2. import numpy as np
  3. import numpy.linalg as la
  4. import queue
  5. from squares import complete_gen1
  6.  
  7. class form:
  8. def __init__(self):
  9. self.cache = dict()
  10. self.n = 0
  11.  
  12. def __getitem__(self, x):
  13. return x*(3*x-1)//2
  14.  
  15. def __contains__(self, x):
  16. while x >= self[self.n]:
  17. self.cache[self[self.n]] = self.n
  18. self.n += 1
  19. return x in self.cache
  20.  
  21. def inv(self, x):
  22. return self.cache[x]
  23.  
  24. f = form()
  25.  
  26. def order():
  27. for a in it.count(2):
  28. for b in range(a, (f[a]-1)//3+1):
  29. yield a, b
  30.  
  31. def form_list():
  32. for a, b in order():
  33. n = f[a] + f[b]
  34. if n in f:
  35. c = f.inv(n)
  36. yield a, b, c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement