-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.py
More file actions
34 lines (29 loc) · 892 Bytes
/
2.py
File metadata and controls
34 lines (29 loc) · 892 Bytes
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
34
file = open("2.txt", "r")
ids = file.read().split("\n")
have2 = 0
have3 = 0
for word in ids:
hasExactly2 = False
hasExactly3 = False
for char in word:
# print("word: ", word)
# print("char: ", char)
# print("count: ", word.count(char))
if word.count(char) == 2:
hasExactly2 = True
elif word.count(char) == 3:
hasExactly3 = True
if hasExactly2:
have2 += 1
# print("have2: ", have2)
if hasExactly3:
have3 += 1
# print("have3: ", have3)
checksum = have2 * have3
print("checksum: ", checksum)
for word in ids:
for otherWord in ids:
diff = [i for i in range(len(word)) if word[i] != otherWord[i]]
if len(diff) == 1:
letters = [word[i] for i in range(len(word)) if word[i] == otherWord[i]]
print("Common letters: ",''.join(letters))