Advertisement
Guest User

Untitled

a guest
Nov 28th, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. f = open('textik4.txt','r')
  2. count = 0
  3. l = 0
  4. max = 0
  5. alstat = [0]*31
  6. words = []
  7. stat = [0]*31
  8. alph = "AБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЫЬЭЮЯ_"
  9.  
  10. text = f.read()
  11. words = set(text)
  12. n = len(text)
  13. k = len(words)
  14. print("Kolvo vceh cimvolov in text:",n,"Kolvo vceh razn bukv:",k)
  15. words = list(words)
  16. la = list(text)
  17. text = list(text)
  18. for i in range(1,40):
  19.     for j in range(0,n-i-1):
  20.       if text[j] == text[j+i]:
  21.         count += 1
  22.     if count > max:
  23.          max = count
  24.          k = i
  25.     count = 0
  26. print(k)     
  27. nooptext = [0]*len(text)
  28. key = ""
  29. for i in range(0,k):
  30.     for j in range(l,len(text)-k,k):
  31.         alstat[alph.index(text[j])] += 1
  32.         print(alph.index(text[j]))     
  33.     max = 0
  34.     for j in range(len(alstat)):
  35.         if alstat[j] > max:
  36.             max = alstat[j]
  37.             id_max = j
  38.     key += alph[(id_max+1) % len(alph)]
  39.     id_max = 30 - id_max
  40.     j = 1
  41.     for j in range(l,len(text)-k,k):
  42.         nooptext[j] = alph[(alph.index(text[j]) + id_max) % len(alph)]
  43.     l += 1
  44.     alstat = [0]*31
  45. f.close()  
  46. """f = open('open_text.txt','w+')
  47. f.write(nooptext)
  48. f.close()"""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement