Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # len3_base3_sorted.py
- base = 3
- baselength = 3
- def nbase(n, b=3,length=3):
- b += 1
- if n == 0:
- return [0]*length
- values = []
- for z in 'Z'*length:
- r = n % b
- n = int(n/b)
- values.append(r)
- return values[::-1]
- 0
- ttt = []
- i = 0
- while 1:
- t = nbase(i)
- ttt += [t]
- if t == [base]*baselength:
- break
- i += 1
- 0
- ttt.sort(key=sum)
- for t in ttt:
- print ''.join([str(i) for i in t]),
- '''
- 000 001 010 100 002 011 020 101 110 200 003 012 021 030 102 111 120 201 210 300 013 022 031 103 112 121 130 202 211 220 301 310 023 032 113 122 131 203 212 221 230 302 311 320 033 123 132 213 222 231 303 312 321 330 133 223 232 313 322 331 233 323 332 333
- '''
Add Comment
Please, Sign In to add comment