master
Paul Walko 2020-12-06 10:26:58 -05:00
parent c5c7f19d49
commit c1496e5e9e
4 changed files with 3058 additions and 0 deletions

45
5/5.py Executable file
View File

@ -0,0 +1,45 @@
#!/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 2
ids = []
# part 1
highestId = 0
for l in L:
row = [0, 128]
col = [0, 8]
for i in range(10):
if i < 7:
if l[i] == 'F':
row[1] -= (row[1] - row[0]) / 2
# print('F')
else:
row[0] += (row[1] - row[0]) / 2
# print('B')
# print(row)
else:
if l[i] == 'L':
col[1] -= (col[1] - col[0]) / 2
else:
col[0] += (col[1] - col[0]) / 2
ids.append(row[0] * 8 + col[0])
if ids[-1] > highestId:
highestId = ids[-1]
print(highestId)
# part 2
ids.sort()
prevId = ids[0]
missingPrevIds = []
for id in ids:
if prevId != id and prevId + 1 != id:
missingPrevIds.append(id)
prevId = id
print(missingPrevIds)

774
5/input.txt Normal file
View File

@ -0,0 +1,774 @@
FFFBFBFLRR
FFBBFFFRLL
FBFBFFBRLR
FFFBBFBRRL
BFFFBBFRRL
FFBFBFFLLR
FBFBBFFRLL
FFBBFBBLLL
BFFFBBFLLR
FBBFFBBRLR
FBFBBBBLLL
BFFBBBFLLR
BBFFBFBLRR
FBBBFFBRRL
FFFBFBBLRL
FFBFBFBRLR
FBBBBFFRRL
FBBBBFBLLR
BFBBBBFRRR
BFBFFBBLRL
FBBFBBFRLL
FFBBBFBRLR
FBBFFFBRLL
FBFBBFBLRR
FFFBBBFLLL
FBFFBBFLRL
BFFFBFFLLR
FBFBBBBLRL
FBBFBFFRLR
FBFBBBBRLL
FFBFFBFLLR
BFFBFFBRLL
FBBBBFFLRL
BFFBFBBRLR
FFBFFFFLLR
BBFFBBFRLR
BFBFBBBRRL
BFFBBBBLRR
FFBBBBBRLL
FFFBBFFRLR
BBFFFFBLRL
BFBBFBFRRL
BBFFBBFRRL
FBFFFFBRLR
FBBFBBBRLR
BBFBFFF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FFBBLRR
FFBBFFFRRR
FBFBBBFRLR
BFBBFBFLRR
FBBFBFFRRL
FBFBBFFLRR
FBBFBFBRRR
FBFBBBFLRR
BFBBBBBLLR
FBFFFBFLLR
FBFBBFBLLR
FFBFFFFLRR
BFBFBBBRLR
FBFFFFFRLL
FFBBBBBLRL
BFBBBFFLLL
BBFFFFFLLR
BFFFBBFRRR
FBFBFFBRRL
FFFBBFBRRR
FBBBFBBLLR
BFFFFBFRLL
BFBFBFFRLL
BFBFBBFLRL
FFBBBFFRLR
BFBFBBBLLL
BFFFBBBLRR
BFBBFFFLLL
FBFBFBBRLL
BFFFFFBLLL
BBFBFFFLRR
BFBFFBBRLL
FFBFBBFRRL
FBFBBBFLLL
FBFFFFBLLL
FBFFBFFLLR
FBBFBBFRRL
BBFFBBFRRR
BFFFBFBRRL
BFBFFFBRLR
FBBFFBFLLR
BFBFFFFRLL
BFBFBBBRRR
BFBFFFFRLR
FFBFBFBLLR
FBFFFBFLRR
FFBBBBBRRR
FBBFFFBLRR
FFBFFFBRLR
BFFFBFBRRR
FBBFBBBLLR
BFBBBBBLRL
FBBBFFFLRL
BFFBBFFRRR
BFBBBFFRLL
BFBFFFFLLR
BFFBFFFLRL
BFBFFFFRRR
BBFFFFFRLR
FBFFFBFRLL
FFFBBBFRRR
BFFFBFBLLR
FBBFBFFRLL
FBBBFBBLLL
BFBBBBBRLL
BFFBBBFRRR
FFFBFBFRRR
BFBBBFBRRL
FBFFBFBLLL
FBBBFFFRLR
FBFBBFFRRL
FBBFFBFRRL
FBBFBFBLRR
BFFFFFBLRL
FBBBFBFRRR
BFFFBBBLLL
FFBBBFBRLL

41
6/6.py Executable file
View 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

File diff suppressed because it is too large Load Diff