Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. from fractions import gcd
  2. from itertools import product
  3.  
  4. def getSelections(stackSize=10, weighings=3):
  5. res = [tuple(0 for i in range(weighings))]
  6. for potential in product(range(-stackSize, stackSize + 1), repeat=weighings):
  7. g = gcd(potential[0], potential[1])
  8. c = 2
  9. while c < len(potential) and abs(g) != 1:
  10. g = gcd(g, potential[c])
  11. c += 1
  12. if abs(g) == 1:
  13. res.append(potential)
  14. return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement