Advertisement
Guest User

Untitled

a guest
Oct 19th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. def abs_sorted_pairs():
  2.     pair_sum = 0
  3.     while True:
  4.         for a in range(pair_sum + 1):
  5.             b = pair_sum - a
  6.             for a_flip in ([1] if a == 0 else [1, -1]):
  7.                 for b_flip in ([1] if b == 0 else [1, -1]):
  8.                     yield a * a_flip, b * b_flip
  9.         pair_sum += 1
  10.  
  11.  
  12. if __name__ == '__main__':
  13.     print('first 100:')
  14.     for i, p in zip(range(100), abs_sorted_pairs()):
  15.         print(p)
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement