feat: Initial commit

This commit is contained in:
2024-03-22 17:01:42 +01:00
parent 954985f39a
commit c343ff6e93
106 changed files with 143428 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
def loadMorse(filename: str, to_ascii: bool):
fio = open(filename, "r")
conv_table = {}
for line in fio:
line = line.split()
if to_ascii:
conv_table[line[1].upper()] = line[0]
else:
conv_table[line[0]] = line[1].upper()
conv_table[" "] = " "
return conv_table
def main():
to_ascii = input("Vuoi decodificare un file? ") == "si"
in_file = input("Inserisci il nome del file: ")
conv_table = loadMorse("morse.txt", to_ascii)
with open(in_file, "r") as fio:
in_str = fio.readline()
if to_ascii:
for char in in_str.split():
print(conv_table[char], end="")
else:
in_str = list(in_str.upper())
for char in in_str:
print(conv_table[char], end=" ")
main()