-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAOCDay6.py
executable file
·37 lines (31 loc) · 909 Bytes
/
AOCDay6.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 6 01:03:41 2020
@author: ethanhowell
"""
import collections
with open("/Users/ethanhowell/Documents/AOCInputs/DAY6.txt", "r") as f:
data = f.read()
groupData = data.split('\n\n')
newData = []
for ii in groupData:
tempLine = ''.join(ii.split('\n'))
newData.append(tempLine)
summation = 0
for ii in newData:
thisDict = collections.Counter(ii)
summation+=len(thisDict.keys())
print(summation)
summation = 0
for ii in groupData:
tempLine = ii.split('\n')
if len(tempLine) == 1:
thisDict = collections.Counter(tempLine[0])
summation+=len(thisDict.keys())
else:
thisDict = collections.Counter(''.join(tempLine))
if '' in tempLine:
tempLine.remove('')
summation+=len([xx for xx, yy in thisDict.items() if yy == len(tempLine)])
print(summation)