This commit is contained in:
Michael Zhang 2020-12-06 02:59:02 -06:00
parent b20b246a88
commit 75f30d2389
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
4 changed files with 3073 additions and 0 deletions

37
5.py Normal file
View file

@ -0,0 +1,37 @@
def search(n):
first7 = n[:7]
lo = 0
hi = 128
for c in first7:
mid = (lo + hi) // 2
if c == "F":
hi = mid
elif c == "B":
lo = mid
x = lo
last3 = n[-3:]
lo = 0
hi = 8
for c in last3:
mid = (lo + hi) // 2
if c == "L":
hi = mid
elif c == "R":
lo = mid
y = lo
id = 8 * x + y
return id
ids = []
with open("5.txt") as f:
for line in f:
line = line.strip()
id = search(line)
ids.append(id)
ids.sort()
print(ids)
print("ajsdoifapjds")
for i in range(len(ids) - 3):

782
5.txt Normal file
View file

@ -0,0 +1,782 @@
FBBBFBBLRR
BFFFBBFLRR
BFBFBBFLLR
BBFFFFBLLR
FBBFBBFRLL
BBFFFFBRLL
FBBFBFFLLR
BFFBBBFRRL
FFBFBFFRLR
FBFFFFBLLL
FBFFFFFLRL
FFFBFBBRLR
FFBFFFFLLL
BFBBBFFLLL
FFBBBFBRLR
BFFBFBFLLL
FBFBFFFLLL
BBFFBBBRRL
FBFFBFBLLL
BFFBFBFRRL
FBFBFFFRLR
BFBBBFBRLL
FFBBFBFLRL
FBBFFBFRRR
BFBBBBBLRL
FFBFBFBLRL
FFBFFFFLRL
BFBFBFBRRR
FBBBBBBRRR
BFBFFBBRLL
BBFFBFBLLL
BFBFBBFRLL
FBFBBBBRLR
BFFBBFBRRL
BFBBBFBRRR
FBBBFBBLRL
BBFFBBBLRL
FFBBFFFRRR
FBFFBFFLLL
FBFFBBFRLL
FBBBFBFRLL
BFFBBFFLRL
FFFBFBBRRR
BFBBBBFRLR
FBFBFBBRRL
BFFFFFFRRL
BFBBBBFRRL
FBFBBFFRRL
FBFFBFFRLR
FBBFFBBRRR
FBFBBFFRRR
FFFBBFFRLR
BBFFBFBRRL
FBBBBBFRRR
BFBBBBBRLL
B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RR
FFBBBBFLRR
BBFFFBBLLL
FBBBFBBLLL
FFBBBFBLRR
BFBFBFFRLR
BBFBFBBLLR
BFBFFBFLLL
FBFBBFFRLL
FBFBFBFLRL
FBBFFFBLRR
BFBFFBBRRL
FFBFBFFLLR
FFBBFFBLLR
FFFBBBFRRR
BFFBFBBRRR
FFFBBBBLRL
FBBBBBBLRR
FBBBFBFLRR
FFBBBBFRRR
FFBFFBFLLL
BBFFBBFRLR
FBFFFFFRRR
FBBBFFFLRL
BFFBFFBRLR
FBFFFBFRRL
BBFFFFFLLL
FFBBFBFLLL
BFFBFFBRLL
FFBBFFBLLL
BBFFFBFLLR
FBBFBFBLLL
BFFFFFBRRR
BFBFBBBLRL
FBBFFBBRLL
BFFBFFFRLL
BFFBFFFLRR
BFFBBBFRLL
FBFBBFFLLL
FBFBFBFRRL
BFBBFBBLLR
FBFBBBBLRL
BFFFBFBRLR
FFFBFBFRRL
BBFBBFFLLR
FBBFBFFLRL
FFBBBBBLRR
FBBBBFBRLL
BBFBFBFRLR
BFBBBBBLLL
FBBBFBBLLR
FFFBBFFRLL
FFFBFBBRLL
FFBFFBFLLR
BBFFFFFRRR
BBFFBFFLRL
FBFFFFBRRR
BFBFFFBLRL
BBFFBFBLRR
FFBBBFBRRL
FBFFBFBLRL
FBBFBFBRLR
BFBFBFFRRL
BFFFBFBRRL
BFFFBFFRLR
BBFBFBFLRL
FBBFBFFRRL
BFBBFBBRRL
BFFFFBFLLL
FBBFBBBLRR
BFBFFFFLLL
FFBBBBBLRL
BFBFFBBLLR
FBFBFBFLLR
FFBFFFBRLR
FBBFFFFRRR

15
6.py Normal file
View file

@ -0,0 +1,15 @@
with open("6.txt") as f:
data = f.read().split("\n\n")
def process(lines):
return len(set("".join(lines.split("\n"))))
print(sum(map(process, data)))
from functools import reduce
with open("6.txt") as f:
data = f.read().split("\n\n")
def process(lines):
lines = lines.strip()
letters = reduce(set.intersection, map(set, map(list, lines.split("\n"))))
print(repr(lines), letters)
return len(letters)
print(sum(map(process, data)))

2239
6.txt Normal file

File diff suppressed because it is too large Load diff