5/6
This commit is contained in:
41
6/6.py
Executable file
41
6/6.py
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
L = []
|
||||
with open(sys.argv[1], 'r') as f:
|
||||
L = f.readlines()
|
||||
L = [x.strip() for x in L]
|
||||
|
||||
|
||||
# part 1
|
||||
groups = [set()]
|
||||
for i in L:
|
||||
if i == '':
|
||||
groups.append(set())
|
||||
else:
|
||||
for ii in i:
|
||||
groups[-1].add(ii)
|
||||
total = 0
|
||||
for i in groups:
|
||||
total += len(i)
|
||||
print(total)
|
||||
|
||||
# part 1
|
||||
groups = [{'people': 0}]
|
||||
for i in L:
|
||||
if i == '':
|
||||
groups.append({'people': 0})
|
||||
else:
|
||||
groups[-1]['people'] += 1
|
||||
for ii in i:
|
||||
if ii not in groups[-1]:
|
||||
groups[-1][ii] = 1
|
||||
else:
|
||||
groups[-1][ii] += 1
|
||||
total = 0
|
||||
for i in groups:
|
||||
for ii in i:
|
||||
if ii != 'people' and i[ii] == i['people']:
|
||||
total += 1
|
||||
print(total)
|
||||
2198
6/input.txt
Normal file
2198
6/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user