boris-vlasenko

2to8

Dec 4th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. bi = input()
  2. while bi[0]==0:
  3.     bi.pop(0)
  4. bi = '0'*(3-len(bi) % 3) +  bi
  5. oct_dig = ['000','001','010','011','100','101','110','111']
  6. res = ''
  7. while bi:
  8.     res += str(oct_dig.index(bi[-3:]))
  9.     bi = bi[:-3]
  10. print(res)
Advertisement
Add Comment
Please, Sign In to add comment