Advertisement
here2share

# base_sorted_index.py

Mar 6th, 2023
771
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. # base_sorted_index.py -- important: for a seemingly unique AI project in mind
  2.  
  3. maximum = 4095
  4.  
  5. def base12(n, b=1,length=12):
  6.     b += 1
  7.     if n == 0:
  8.         return [0]*length
  9.     values = []
  10.     for z in 'z'*length:
  11.         r = n % b
  12.         n = int(n/b)
  13.         values.append(r)
  14.     return values[::-1]
  15. 0
  16.  
  17. ttt = []
  18. i = 0
  19. while 1:
  20.     t = base12(i)
  21.     ttt += [t]
  22.     if t == [1]*12:
  23.         break
  24.     i += 1
  25. 0
  26. pos = ttt[:]
  27. ttt.sort(key=sum)
  28.  
  29. for t in ttt:
  30.     print(''.join([str(i) for i in t]), sum(t), pos.index(t))
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement