-
Notifications
You must be signed in to change notification settings - Fork 0
/
day3.py
executable file
·54 lines (46 loc) · 1.17 KB
/
day3.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
with open('day3.txt') as f:
lines = f.readlines()
input = []
for str in lines:
input.append(str.strip())
print(input)
# score = 0
# test = ["vJrwpWtwJgWrhcsFMMfFFhFp",
# "jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL",
# "PmmdzqPrVvPwwTWBwg",
# "wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn",
# "ttgJtRGJQctTZtZT",
# "CrZsJsPPZsGzwwsLwLmpwMDw"]
# for cargo in input:
# n = len(cargo)
# l, r = set(cargo[:n//2]), set(cargo[n//2:])
# for char in cargo:
# if char in l and char in r:
# duplicate = char
# break
# if char.isupper():
# score += ord(char) - 38
# else:
# score += ord(char) - 96
# print(score)
score = 0
test = ["vJrwpWtwJgWrhcsFMMfFFhFp",
"jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL",
"PmmdzqPrVvPwwTWBwg",
"wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn",
"ttgJtRGJQctTZtZT",
"CrZsJsPPZsGzwwsLwLmpwMDw"]
i = 0
while i < len(input):
group = input[i:i+3]
two, three = set(group[1]), set(group[2])
for char in group[0]:
if char in two and char in three:
break
print(char)
if char.isupper():
score += ord(char) - 38
else:
score += ord(char) - 96
i += 3
print(score)