Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #miguel.alberto.maldonado@gmail.com
- dictionary = {}
- dictionary_abc = {}
- def discard_count_repeated_char(phrase):
- for k in phrase:
- dictionary[k] = dictionary.get(k,0)+1
- return dictionary.keys()
- def create_new_dictionary(keys):
- if keys == []:
- return False
- else:
- dictionary_abc[len(dictionary_abc)] = keys[0]
- return create_new_dictionary(keys[1:])
- def phrase_decoding(phrase_to_decode):
- if phrase_to_decode == "":
- return False
- else:
- if phrase_to_decode[0] == "0":
- print dictionary_abc[(int(phrase_to_decode[1:2]))]
- else:
- print dictionary_abc[(int(phrase_to_decode[:2]))]
- return phrase_decoding(phrase_to_decode[2:])
- def main():
- phrase = 'nothing better than python its very simple for you, get in, do it'
- keys = discard_count_repeated_char(phrase)
- create_new_dictionary(keys)
- phrase_to_decode = "08111000010916120411"
- phrase_decoding(phrase_to_decode)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement