Advertisement
Guest User

monoalfabetico

a guest
Jan 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. def cripta():
  2.     a=open('arminuta.txt')
  3.     p=a.read()
  4.     a.close()
  5.     criptato=''
  6.     for i in p:
  7.         if i in chiave:
  8.             criptato+=chiave[alf.find(i)]
  9.         else:
  10.             criptato+=i
  11.     return criptato
  12.    
  13. def decripta(p,chiave):
  14.     decriptato=''
  15.     for i in p:
  16.         if i in chiave:
  17.             decriptato+=alf[chiave.find(i)]
  18.         else:
  19.             decriptato+=i
  20.     return decriptato
  21.  
  22.  
  23. def intell():
  24.     p=cripta()
  25.     alf='abcdefghilmnopqrstuvz'
  26.     a=open('parole.txt')
  27.     b=a.read()
  28.     a.close()
  29.     listap=b.split('\n')
  30.     voc=''.join(listap)
  31.  
  32.     statistica={}
  33.     tot=len(voc)
  34.     for l in alf:
  35.         statistica[l]=(voc.count(l)-1)/tot
  36.     print(statistica)
  37.  
  38.     dalfip={}
  39.     tot=len(p)
  40.     for l in alf:
  41.         dalfip[l]=p.count(l)/tot
  42.     print(dalfip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement