Advertisement
here2share

# base_N_by_L.py

Jan 27th, 2022 (edited)
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. # base_N_by_L.py
  2.  
  3. def base2index(combo):
  4.     i = combo[-1]
  5.     c = combo[:-1]
  6.     for k,v in enumerate(c[::-1]):
  7.         i += int(v * base ** (k + 1))
  8.     return i
  9.  
  10. def index2base(n):
  11.     results = []
  12.     for z in '.' * baselength:
  13.         results.append(int(n % base))
  14.         n //= base
  15.     return list(reversed(results))
  16.  
  17. base = 12
  18. baselength = 12
  19. i = base2index([base-1 for i in '.' * baselength])
  20. print i
  21. while 1:
  22.     aaa = index2base(i)
  23.     bbb = base2index(aaa)
  24.     print 'from '+str(bbb).zfill(16), 'to', aaa
  25.     print '.....'+str(i).zfill(16)
  26.     print
  27.     i -= 1
  28. 0
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement