Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. import re
  2. my_text = ' In England, there is a big "Sherlock Holmes Society". Members of the Society take the stories very seriously. They have meetings and discussions, where they talk about the books, and discuss some of the problems that still exist. For example, in one of the stories, Holmes took a train from London to Paris, but arrived in Paris before the train! How did he do it? One member looked at the train timetables of the , and found an explanation: He could have changed trains at Reading, near London, to arrive at the coast more quickly! Its elementary of course, for Sherlock HolmesSherlock Holmes has passed on his remarkable methods to Scotland Yard. His analysis is based on the most detailed research. Holmes made famous the arts of observation and deduction.When he met Doctor Watson, his friend and assistant, for the first time, he said ; "I see you have been to Afghanistan," But how did he know? Watson looked like a medical and a military man. He had a dark skin, but his arms were white. His left arm was hurt. So Holmes concluded that he was an English army doctor, and he had recently come back from a hot country, with an injured arm. The only possible country, at the time was Afghanistan!"Elementary, my dear Watson!Another example: when Dr. Watson showed him his watch, Holmes said: "I see that this watch belonged to your elder brother, who is now dead. He was an untidy man, and he was very poor, but he had periods of prosperity. At the end of his life he drank too much." Again, the explanation was elementary!Stanley MacKenzie, president of the Sherlock Holmes Society, said: "Holmes is a mental superman and an eccentric. I envy his facility for solving problems in his armchair, with his eyes closed and his hands joined.'.lower()
  3. clear_text = ''.join(re.findall('[a-z]',my_text))
  4. my_key = 'lazyc'
  5. alphabet = 'abcdefghijklmnopqrstuvwxyz'
  6. shifr = ''
  7. for i in range(len(clear_text)):
  8. shifr+=alphabet[(alphabet.index(clear_text[i])+alphabet.index(my_key[i%len(my_key)]))%26]
  9. print(shifr)
  10. array = [i for i in range(31)]
  11. for r in range(2,31):
  12. array[r]=0
  13. for i in range(len(shifr)-r):
  14. if shifr[i]==shifr[i+r]:
  15. array[r] += 1
  16. new_arr = []
  17. for i in range(5):
  18. new_arr.append(shifr[i::5])
  19. print(new_arr)
  20. real_key = ''
  21. for i in new_arr:
  22. arr2 = {}
  23. for j in alphabet:
  24. bukva = i.count(j)
  25. arr2[bukva] = j
  26. print(arr2[max(arr2)])
  27. real_key += alphabet[(alphabet.index(arr2[max(arr2)])-alphabet.index('e'))%26]
  28. print(real_key)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement