-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6b.py
More file actions
40 lines (35 loc) · 998 Bytes
/
6b.py
File metadata and controls
40 lines (35 loc) · 998 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
35
36
37
38
39
40
#Advent of code
# 12/13/2020 day6 6b
filename = "data6.txt"
file = open(filename)
filestr = file.read()
a_list = filestr.split("\n\n")
maxindex = len(a_list)
print(a_list)
print(f"maxindex={maxindex}, maxcolumns={len(a_list[0])}")
# ['abc', 'a\nb\nc', 'ab\nac', 'a\na\na\na', 'b']
b_list = []
for b in a_list:
# combine all members of each group together.
b_new = b.replace("\n", " ")
b_list.append(b_new)
# ['abc', 'a b c', 'ab ac', 'a a a a', 'b']
print(b_list)
totalCount = 0
for b in b_list:
letters = [0]*27
group_list = b.split(" ")
print(f"group_list={group_list}")
count = 0
for i in range(ord('a'), ord('z')+1):
saidYes = True
for personstring in group_list:
#chr(i)
if chr(i) not in personstring:
saidYes = False
break
if saidYes:
count = count + 1
print(f"b={b}, count={count}")
totalCount = totalCount + count
print(f"totalCount = {totalCount}")