Advertisement
here2share

# combosia.py

Jul 16th, 2022 (edited)
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. # combosia.py -- maybe a new algorithm by Kirk Lawrence
  2.  
  3. def index_to_combo(index):
  4.     idx = index + 3
  5.     default_combo = [0,1,2] # if index = 0
  6.     rrr = 1
  7.     n = rrr
  8.     i = 3
  9.     while 1:
  10.         rrr += i
  11.         if rrr > idx:
  12.             break
  13.         n = rrr
  14.         i += 1
  15.     combo = list(range(i))
  16.     combo.pop(n-idx-1)
  17.     return combo
  18. 0
  19.  
  20. for i in range(490):
  21.     print( index_to_combo(i) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement