SHARE
TWEET

Untitled

a guest Jan 28th, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. BODO_CODE = {
  2.     'A': '+----',
  3.     'B': '--++-',
  4.     'C': '+-++-',
  5.     'D': '++++-',
  6.     'E': '++---',
  7.     'F': '-+++-',
  8.     'G': '-+-+-',
  9.     'H': '++-+-',
  10.     'I': '-++--',
  11.     'J': '+--+-',
  12.     'K': '+--++',
  13.     'L': '++-++',
  14.     'M': '-+-++',
  15.     'N': '-++++',
  16.     'O': '+++--',
  17.     'P': '+++++',
  18.     'Q': '+-+++',
  19.     'R': '--+++',
  20.     'S': '--+-+',
  21.     'T': '+-+-+',
  22.     'U': '+-+--',
  23.     'V': '+++-+',
  24.     'W': '-++-+',
  25.     'X': '-+--+',
  26.     'Y': '--+--',
  27.     'Z': '++--+',
  28. }
  29.  
  30.  
  31. bodo_rev = {v:k for k, v in BODO_CODE.items()}
  32.    
  33.    
  34.    
  35. def encode_to_bodo(text):
  36.     s = ''
  37.     for el in text.upper():
  38.         s += BODO_CODE[el]
  39.     return s
  40.    
  41.  
  42. def decode_from_bodo(code):
  43.     text = ''
  44.     ms, mk = 0, 5
  45.     for i in range(len(code) // 5):
  46.         text += bodo_rev[code[ms:mk]]
  47.         ms = mk
  48.         mk += 5
  49.     return text.lower()
  50.  
  51.  
  52. print(encode_to_bodo(input()))
  53. print(decode_from_bodo(input()))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top