add solution 5, parts 1 and 2

This commit is contained in:
randomuser 2021-07-20 12:55:01 -05:00
parent ef268438b6
commit b616d265a2
2 changed files with 891 additions and 0 deletions

839
2020/5/input Normal file
View File

@ -0,0 +1,839 @@
BFBFFFFLLL
BBFBBFBRLL
BFBBFFFRRR
FBFFBBBLLL
FFBBFBBRLL
BBBFFFFLRL
BFBBBFBRRR
FBBFFFBLRL
FFBFBBFLLR
FBFFFFBLRL
BBFFBBFRLL
BBFBBBBLLR
FFBBBBFRLR
BBFFBFFRLR
BFFBBFFRRL
BBFBBBFLLR
FBFBBBBRRL
BFFFBFFLRL
FBFFFBFRLL
FBBBFFBLRR
FFFBFBBRLR
FBBFBBFLLR
FBFBFFFLRL
BFFBFBFLLR
BBFBFBBRRL
BFFBBFBRLR
FBFBFFFRRL
BFBFFBBRRL
FBFBFBFLLL
BFFBFFBRRL
FFBBBBBRRL
FFFBFBFRLR
BBFFFBBLRL
BFBFBFFRLL
BFBFFFBRLR
FBBBFFFRRR
BBFFFBFRLL
FBBBFBFRLL
FFBBBFFLRR
FBFBBFBLRL
FBBBBBFLLR
FBFFBBBLRL
FFFBBFFRRL
FBBBFFFRLR
BBFBFFFRLR
BBFBBFBLLL
FBFFBBBRRL
BFFFFBFRRR
FBBFFBFLRR
FBFBBBFLRL
BFBBBBBRRL
BBFFFFBLRL
FBFFFBFLLL
FFFBBFFLLR
FBBBFBFLRR
BBBFFBFRRL
BFBFFFFRLR
FFBFFFBRLR
FBFFBFBRLL
FBBFFFFRLL
FFFBBFBRRR
FBBBBFFLRR
BFBBBFBRLR
BFFFFFFRRR
FFBBBBFRRR
BFFBFBFRRL
BFFBFFFRLR
BBFFBFBLRR
FBFFFBBLLL
FBFFFFFRLR
BFBBFBFLRR
FBBBBBBLRL
BFFFFBBLRR
BFFBFFFRRR
FBFFFBFLRL
BFBBFFBLRR
BBFBBBBLLL
BBFBBBFRRL
FBBBBBBRLR
BFFBFBFLRR
BFFBFFFLLR
FBBBBBFLRL
FBFFFBF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FBFRRR
FFBFFBFRLL
FBBFFBBLRR
FBBBFBFRLR
BFBBBBFLRR
FFBFBBBLLR
BFFFBBFRRR
FBBBFFBRLL
FBFBBBFLRR
BBFFBFFRLL
FBFFFFBRLL
FBFFBFBLRL

52
2020/5/solution.py Normal file
View File

@ -0,0 +1,52 @@
import itertools
def half(list, direction):
length = len(list)
num = int(length / 2)
if direction == 'F' or direction == 'R':
return list[0:num]
else:
return list[num:]
def pos(directions):
rows = [i for i in range(128)]
cols = [i for i in range(8)]
for i in directions:
if i == "F" or i == "B":
rows = half(rows, i)
elif i == "L" or i == "R":
cols = half(cols, i)
return (rows[0], 7 - cols[0])
def id(coord):
return (coord[0] * 8) + coord[1]
fd = open('input', 'r')
lines = fd.readlines()
def part1():
greatest = 0
for i in lines:
i = i.rstrip()
if id(pos(i)) > greatest:
greatest = id(pos(i))
def part2():
rows = []
cols = []
grandlist = [['.' for i in range(8)] for j in range(128)]
for i in lines:
i = i.rstrip()
item = pos(i)
grandlist[item[0]][item[1]] = 'X'
print("1 2 3 4 5 6 7 8")
cnt = 1
for i in grandlist:
print(' '.join(i) + ' ' + str(cnt))
cnt += 1
# it's 81, 3 (you have to look at the chart)
print(id((80, 2)))
part2()