Advertisement
mike-rg

holamundo.py

Sep 18th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. #miguel.alberto.maldonado@gmail.com
  2. dictionary = {}
  3. dictionary_abc = {}
  4. def discard_count_repeated_char(phrase):
  5.     for k in phrase:
  6.         dictionary[k] = dictionary.get(k,0)+1
  7.     return dictionary.keys()
  8. def create_new_dictionary(keys):
  9.     if keys == []:
  10.         return False
  11.     else:
  12.         dictionary_abc[len(dictionary_abc)] = keys[0]
  13.         return create_new_dictionary(keys[1:])
  14.  
  15. def phrase_decoding(phrase_to_decode):
  16.     if phrase_to_decode == "":
  17.         return False
  18.     else:
  19.         if phrase_to_decode[0] == "0":
  20.             print dictionary_abc[(int(phrase_to_decode[1:2]))]
  21.         else:
  22.             print dictionary_abc[(int(phrase_to_decode[:2]))]
  23.         return phrase_decoding(phrase_to_decode[2:])
  24.  
  25. def main():
  26.     phrase = 'nothing better than python its very simple for you, get in, do it'
  27.    
  28.     keys = discard_count_repeated_char(phrase)
  29.     create_new_dictionary(keys)
  30.  
  31.     phrase_to_decode = "08111000010916120411"
  32.     phrase_decoding(phrase_to_decode)
  33. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement