-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_checksum_b.py
More file actions
33 lines (30 loc) · 1.05 KB
/
02_checksum_b.py
File metadata and controls
33 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import itertools
list_words = []
def compare(str1, str2):
# print(str1 == str2)
if str1 != str2:
# print("{} and {}".format(str1, str2))
zipped = zip(str1, str2)
x = []
for i,j in zipped:
if i==j:
x.append(j)
return x
else:
return [1]
if __name__ == "__main__":
with open('data_02.txt', 'r') as file:
data = file.read().splitlines()
# for box in data:
comparaison_number = 0
print("Word length: {}".format(len(data[0])))
for i in range(len(data)):
for j in range(len(data)):
comparaison_number+=1
result = compare(data[i],data[j])
if len(result) > 24:
print("\n*********\nComparaison #{}:".format(comparaison_number))
print("{} and {}".format(data[i], data[j]))
print("\n{}".format(result))
print("\nLength = {}".format(len(result)))
print("Result is: {}".format(''.join(result)))