coder/decoder
unknown
python
2 years ago
901 B
6
Indexable
#A.V.V from random import shuffle def code(input_string): shuffled_string = list(input_string) shuffle(shuffled_string) shuffled_string = ''.join(shuffled_string).replace(' ', '') # Shuffled input string sh_dict = dict(enumerate(shuffled_string)) sh_dict = {v: k for k, v in sh_dict.items()} # Change key and value res = 'print(' for sym in input_string: if sym == ' ': res +=" ' '," else: res += f"((lambda x: list(enumerate(' '.join(map(str, [i for i in x if x])).strip().split())))('{shuffled_string}'))[{sh_dict[sym]}][1]," res += " sep='')" return res def decode(input_string): return eval(input_string) def main(): coded_message = code(input("Введите сообщение: ")) print() print(coded_message) if __name__ == '__main__': main()
Editor is loading...