diff --git a/trabalho1/afreq.py b/trabalho1/afreq.py index 4d2e984..7e5fdce 100644 --- a/trabalho1/afreq.py +++ b/trabalho1/afreq.py @@ -38,9 +38,9 @@ frequencias.reverse() caracteres = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' def afreq(string): - # determinar a frequencia de cada caractere na string - # comparar com a frequencia de cada caractere na lingua portuguesa - # calcular a diferenca entre as frequencias + # determina a frequencia de cada caractere na string + # compara com a frequencia de cada caractere na lingua portuguesa + # calcula a diferenca entre as frequencias str_freq = {} for c in string: @@ -56,9 +56,6 @@ def afreq(string): freq_sorted = [x[0] for x in freq_sorted] freq_sorted.reverse() - print(freq_sorted[0], frequencias[0]) - print(freq_sorted[1], frequencias[1]) - possiveis_chaves = [] for i, c in enumerate(frequencias): @@ -68,7 +65,7 @@ def afreq(string): index_c = caracteres.index(c) index_freq = caracteres.index(freq_sorted[i]) - print(c, index_c, index_freq) + # print(c, index_c, index_freq) possiveis_chaves.append((index_freq - index_c) % 26) # (indice da freq da letra na str - indice da letra em PT) % ignorar letras maiusculas diff --git a/trabalho1/cesar.py b/trabalho1/cesar.py index b54513e..a90d56c 100644 --- a/trabalho1/cesar.py +++ b/trabalho1/cesar.py @@ -56,25 +56,26 @@ def cesar(string, key): new_index = (index + key) % len(caracteres) new_letter = caracteres[new_index] - # # [A-Z, a-z, 0-9] - # if ord('0') <= ord(letter) <= ord('9'): - # if new_letter > ord('9'): - # new_letter += 7 # 9 + 1 = A - # elif new_letter < ord('0'): - # new_letter += 75 # 0 - 1 = z - # elif letter.isupper(): - # if new_letter > ord('Z'): - # new_letter += 6 # Z + 1 = a - # elif new_letter < ord('A'): - # new_letter -= 7 # A - 1 = 9 - # else: - # if new_letter > ord('z'): - # new_letter -= 75 # z + 1 = 0 - # elif new_letter < ord('a'): - # new_letter -= 6 # a - 1 = Z - new_string += new_letter return new_string -print(cesar(string, key)) \ No newline at end of file +print(cesar(string, key)) + + +# # [A-Z, a-z, 0-9] +# if ord('0') <= ord(letter) <= ord('9'): +# if new_letter > ord('9'): +# new_letter += 7 # 9 + 1 = A +# elif new_letter < ord('0'): +# new_letter += 75 # 0 - 1 = z +# elif letter.isupper(): +# if new_letter > ord('Z'): +# new_letter += 6 # Z + 1 = a +# elif new_letter < ord('A'): +# new_letter -= 7 # A - 1 = 9 +# else: +# if new_letter > ord('z'): +# new_letter -= 75 # z + 1 = 0 +# elif new_letter < ord('a'): +# new_letter -= 6 # a - 1 = Z \ No newline at end of file