-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecodificador Sistema 1
40 lines (34 loc) · 1.08 KB
/
Decodificador Sistema 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def sum_position(char):
return ord(char.lower()) - ord('a') + 1
def position_to_char(position):
return chr((position - 1) % 26 + ord('a'))
def decode_system_1(text):
decoded_text = ''
for char in text:
if char.isalpha():
position = sum_position(char)
new_position = (position - 3) % 26
if new_position <= 0:
new_position += 26
new_char = position_to_char(new_position)
decoded_text += new_char
else:
decoded_text += char
return decoded_text
def main_menu():
while True:
print("\nDecodificador Método Audrey")
print("1. Frase codificada")
print("2. Salir")
option = input("opción: ")
if option == '1':
text = input("Frase a decodificar: ")
result = decode_system_1(text)
print("Frase decodificada:", result)
elif option == '2':
print("Fin")
break
else:
print("Opción inválida")
if __name__ == "__main__":
main_menu()