Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. def hamming(str1, str2):
  2.     i = 0
  3.     if not len(str1) - len(str2) == 0:
  4.         if len(str1) - len(str2) < 0:
  5.             for x in range (0,len(str2) - len(str1)):
  6.                 str1 = str1 + " "
  7.         if len(str1) - len(str2) > 0:
  8.             for x in range (0,len(str1) - len(str2)):
  9.                 str2 = str2 + " "
  10.     for x in range(0,len(str1)):
  11.         if not str1[x] == str2[x]:
  12.             i = i + 1
  13.     return i
  14.  
  15. word = input(str)
  16. a = int(input())
  17. min = 999
  18.  
  19.  
  20. for x in range (0,a):
  21.     words = input(str)
  22.     if min > hamming(word,words):
  23.         min = hamming(word,words)
  24.         w = words
  25.  
  26. if a > 0:
  27.     print(w)
  28. if a == 0:
  29.     print("BRAK PODPOWIEDZI")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement