philRG

Bijective numeration

Apr 22nd, 2021 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. import sys
  2. import math
  3.  
  4. b = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'A': 10}
  5.  
  6. count = int(input())
  7. liste = []
  8. for decimary in input().split():
  9.     dec = sum([b[d]*10**k for k, d in enumerate(decimary[::-1])])
  10.     liste.append(dec)
  11.  
  12. r = sum(liste)
  13.  
  14. print(r, file=sys.stderr)
  15.  
  16.  
  17. result = []
  18. u = r
  19. while u > 0:
  20.     k = int(math.log10(u))
  21.     d = u // 10 ** k
  22.     u -= d * 10 ** k
  23.     d = 'A' if d == 1 else str(d)
  24.     result.append(d)
  25.  
  26. r = ''.join([d for d in result])
  27.  
  28. print(result, file=sys.stderr)
  29.  
  30. print(r)
  31.  
Add Comment
Please, Sign In to add comment