initial commit on day 9

This commit is contained in:
Juan José Gutiérrez de Quevedo Pérez 2020-12-09 09:26:04 +01:00
commit f896e7c753
31 changed files with 8328 additions and 0 deletions

11
1/1.py Normal file
View file

@ -0,0 +1,11 @@
import sys
ns = []
with open("input") as f:
for n in f:
n=int(n)
m = list(filter(lambda x: n + x == 2020, ns))
if m:
print(m[0]*n)
sys.exit(0)
ns.append(n)

18
1/2.py Normal file
View file

@ -0,0 +1,18 @@
import sys
def find_sum(l, total):
for i in l:
m = list(filter(lambda x: i + x == total, l))
if m:
return (i, m[0])
return (None, None)
ns = []
with open("input") as f:
for n in f:
n=int(n)
n1, n2 = find_sum(ns, 2020-n)
if n1:
print(n1*n2*n)
sys.exit(0)
ns.append(n)

200
1/input Normal file
View file

@ -0,0 +1,200 @@
1440
1511
1731
1400
1542
1571
1768
1730
1959
1342
1744
872
1237
1846
1597
1583
1711
1499
1679
1895
1875
1928
1728
1673
481
1934
673
1704
1916
1958
1821
1649
1640
1802
1732
121
1924
1438
1748
1046
1905
1566
1152
1964
1518
1603
1414
1785
1993
1594
1761
1455
1738
1699
1507
1483
1450
1653
1644
19
1340
1227
1353
2009
1188
1228
1898
1941
1515
1766
1351
1980
1378
1702
1620
1729
1279
1384
1894
1770
1853
1161
1970
1986
1669
1938
1602
1190
1822
425
1750
1632
1613
1805
1718
1990
1762
1242
1485
1598
1893
1995
1823
1786
1506
1464
1467
1639
1674
1903
1961
1478
1847
1760
1997
2010
899
2000
1488
1243
1891
1504
1693
1176
1391
1563
692
1497
1428
1745
1368
1723
1989
1930
1171
1840
1372
1987
1952
1842
1967
1759
1929
1945
1919
1333
1692
1811
1221
1520
1920
1093
1618
1795
1686
1369
1820
1857
1356
1562
2004
1519
1628
1831
1687
1792
1948
927
1789
1546
1338
1614
1472
1494
1979
1936
1577
1147
1446
1683
1375
856
1787
1517
1724
1334
1642
1496
1668
1725
1800
1708
1814
1585
1827
1801
1208
1839
1596
1925

16
2/1.py Normal file
View file

@ -0,0 +1,16 @@
def validate(password, rule, letter):
count = password.count(letter[0])
mi, ma = rule.split("-")
if count >= int(mi) and count <= int(ma):
return True
else:
return False
count = 0
with open("input") as f:
for passline in f:
rule, letter, password = passline.split(" ")
if validate(password, rule, letter):
count = count + 1
print(count)

17
2/2.py Normal file
View file

@ -0,0 +1,17 @@
def validate(password, rule, letter):
p1, p2 = rule.split("-")
p1 = int(p1) - 1
p2 = int(p2) - 1
if (password[p1] == letter[0]) != (password[p2] == letter[0]):
return True
else:
return False
count = 0
with open("input") as f:
for passline in f:
rule, letter, password = passline.split(" ")
if validate(password, rule, letter):
count = count + 1
print(count)

1000
2/input Normal file

File diff suppressed because it is too large Load diff

12
3/1.py Normal file
View file

@ -0,0 +1,12 @@
count = 0
width = None
x = 0
with open("input") as f:
for passline in f:
passline = passline.strip()
width = len(passline)
if passline[x] == "#":
count += 1
x = (x + 3) % width
print(count)

23
3/2.py Normal file
View file

@ -0,0 +1,23 @@
def calculate_trees(dx, dy):
count = 0
width = None
x = 0
y = 0
with open("input") as f:
for passline in f:
if not bool(y % dy):
passline = passline.strip()
width = len(passline)
if passline[x] == "#":
count += 1
x = (x + dx) % width
y = y + 1
return(count)
i1 = calculate_trees(1, 1)
i2 = calculate_trees(3, 1)
i3 = calculate_trees(5, 1)
i4 = calculate_trees(7, 1)
i5 = calculate_trees(1, 2)
print(i1*i2*i3*i4*i5)

323
3/input Normal file
View file

@ -0,0 +1,323 @@
......#...........#...#........
.#.....#...##.......#.....##...
......#.#....#.................
..............#.#.......#......
.....#.#...##...#.#..#..#..#..#
.......##...#..#...........#...
.......#.##.#...#.#.........#..
..#...##............##......#.#
.......#.......##......##.##.#.
...#...#........#....#........#
#............###.#......#.....#
..#........#....#..#..........#
..#..##....#......#..#......#..
........#......#......#..#..#..
..#...#....#..##.......#.#.....
.....#.#......#..#....#.##.#..#
......###.....#..#..........#..
.#................#.#..........
.........#..#...#......##......
##...#....#...#.#...#.##..#....
...##...#....#.........###.....
.#.#....#.........##...........
....#.#..#..#...........#......
..#..#.#....#....#...#.........
..........##.....#.##..........
..#.#....#..##......#.#.....##.
..#...#.##......#..........#...
......#....#..#.....#.....#...#
#.#...##.#.##.........#..#.....
...#.#.#.........#.....#.#.#...
..#.........#...............#..
#..##.....#.........#....#.....
...#....##..##...........##..#.
......##.................#.#...
##.......#....#.#.#.....#......
....#.#...#.................##.
#...#.........##.....#.........
#....#.###..#.....##.#....#....
#..#....#...#....#.#.#.........
.......#...........#....#.....#
#...#.............#........#...
.......#.....#...#..#.........#
.##.....##.....##.......#......
....##...##.......#..#.#.....#.
.##.........#......#........##.
.......#...#...###.#..#........
..#..###......##..##...........
.#..#......##..#.#.........#...
...#.......#........#...#.#....
...#....#..#....#.....##.......
............#......#..........#
.#.......#......#.#....#..#.#..
##.........#.#.#..........#....
....##.....#...................
.......#..#........#...........
....##.#..#......###.......#...
....#....#...#.#......#...#...#
.......#.....##..#....#...#....
#...#........#.........#..##...
...........##.........#.#...#..
....................#....#.##..
.#..#..#.........#....#..#..##.
......................#........
..###....#.......#.....###.##..
......#......#.......#.....#..#
.....#...#.##...#......#....#..
.....#.....##.............#....
....#......##..#....#.......#..
.##....#..##......###....#..#..
...###.#.............##...#.#..
.....#.....#.....#...#..#.#....
..#.#.....###......#.......#...
..........#.##......#.........#
..##..#.......................#
........#......#............#..
#..#..#..#.#......#..#....#....
...##......#.............#....#
...........#..#..##.......#....
.....#.........#.#..#..........
##...#.......#.#....#..#..#....
#.#.#...........#.##.#.#..###..
#..#...........#.........##....
............#.#..............#.
.#....#....##.#...........#..#.
....#...#..#...#....#....#.....
....#....#...#..#......#.......
.#.#.........#.......#.##......
.#..##...#........#...........#
##...#..#...#...#.....#...#....
....###.#..#.......##.#..#...#.
...##.......####...##.#........
#....#....#.#............#..#..
#.#.#...#...................##.
##......#...........#..........
#..#..#....#.#...#......#......
.##...#.....#...#........#.....
..#............#..............#
###........#..#....#...#......#
###..##......#.##...........#..
........#......#..#.....#......
...#..........#..#...........#.
....#..#..#....#........#....#.
.#.................#####..##..#
.....#...##..#..........#.##...
..#..............#...####......
.....#.##..................#.#.
...#.#..#..#........#..........
...........#....#.#..#.........
.....##.......#......#..#.#.#..
...#.............##...#........
...............#.......##.##.##
.....#........#........#.#..#..
...#..#.........#...##...###...
...#.#.............###.#.....#.
.#..........#......###.#.#.....
....##..##.............###.....
..#..#.#...##...#.......##.....
..........###........#.....#.#.
#.#....#..#..#......#...#...#..
.........#......##.......#.#..#
...#.....#.........##..#..#....
.....##.#..##.##..##...........
...#.#.##....#..#..#......#..#.
#....#....#.............#...##.
#......#..#.####.#.##.#....##..
##.#.#....##..................#
.....##......#.......##.......#
..#......#.#..#...##......##...
..#....##....#.........#..##...
.###.....#....##...........#...
.........#......#.#........#...
...#...#..#.#....######.#..#...
###......#.#.#.........##.#....
.....#...#.........#...#.......
....#.............#.#.........#
..##...#...#.......#......#....
.....#...#.#...#...#..#........
.#......#......................
...###..#..#....#...##.#.......
.#.#.....##...#...#.....#...##.
.....###..###....##............
.....##....#..#.....#.##.......
#........#.........#...#..#....
...#.#.........#..#.......#.#..
....#.#....##.....#..........#.
.#..#....#..#.#..#..#.........#
#...#....#..............#......
.........#.....#.##...##...###.
.....#....##............#..#...
.....#.#...........#..#....#...
.#..........#...#......#.....#.
.#...........#.....#..#........
..............#......##...#..#.
...#.........#..#....#..##...##
..##...#..................#....
#.....#.................#......
...#......#..#..........#.#....
......#..#.....#.....##...#..#.
......#........#..........#....
...##.##....#..##.#..........#.
..........#..#.#.##............
..##........................#..
.....#.#.#......#....#....##...
#....#.........#........#......
.##.......#...#...#........##..
....##......#....#.#..........#
..#.......#..............#.....
.....#......#.#...#..#.#.#....#
.....#..#........#.##.##.......
##........#..........#.........
.....#..##....#.#......###..##.
#.#...##.........#.#.....#..#..
#....#.#...#........#.....#..#.
........................#......
....###......#............#...#
...#..##......#..##.........#..
.............#...#......#..#..#
....#......#....#...........#..
..#.#.####.#.....##........#..#
#..#...#..#..#.......#.#..#....
..#..#..#....#.#.........##..#.
.......#......#.#............#.
...#.............#.#.....#.....
...#.#.........##...#.#.......#
........#...#...........##...#.
..........#....#......#....##..
..........#...........#........
...#..#...#..........#......#..
......#......#....#.....#..#.#.
........##.................#..#
.#........#.#...........#......
#...#........#.#.#.....#.#.#...
.........#........#..#..#....#.
##........#..........#....#..#.
.#.##...........#..#.#..##....#
.......#.#....#..#......#......
..#.....#........##..#......###
..#...#..................#....#
......#...#..#.##.......#......
........#...#.#................
.........#............#........
..#.....##....#.#..##..........
#.....#..........#....#........
....#.#...#...##....#.....##...
..#.#.......#.............#...#
...##..............#......#....
#......#...#................##.
.#.#...#.#..#..................
...##.......#...........#.#.#..
#......#.#.#........#.##...####
.......#..#.#.........#.#.##..#
..............#....#.........#.
...........#.#..#....##......#.
#.............#...##..#.......#
.........#............#...#.##.
.......#.........#.#.....#..#..
........................#.#.##.
#......#.#......#.........#....
...#.......#.......#.....#.....
#..#....#................#...#.
........#.#..##......#.........
#..#...##....##....##.........#
.......#...#...###.............
#.#..#........#.#.#............
#.....#........##.........#.#..
.#..........#....#.#....###....
.#.....#...#.#........#..#.##..
...#.##......#..#.............#
..##..#.#...................#..
.....#....#...#.#...#...#......
.....#..#.#....#.#.............
#.#....#.#.##..###..........#..
........#.#.............#..#...
.........#.......#.............
.##.#............##...#........
......#................#.......
...............#..#...........#
...#.......#...#.##.....#....#.
##..##..#..........#...........
.##.#.......#...#..#...#...#...
....#..#...........#....#.##...
.#........#........#....#......
.......#...#.##.#..#.#..#......
.#..#......#....#...##....#.#..
......#...##.#.....##.###.....#
.#....#..#......#...#.#.....#..
#............#....##...##.##...
#...#.#....#...#.......##...##.
#...........#.##..#....#.....#.
...#..#...#.........#.......#..
.#....#.....#............#.#..#
.#.....#.#...#.#....##......###
..#..#.#.#...#..#.............#
...#...#..#....#........#...##.
.......#.....#...##...........#
#.##.................#...##...#
..............##........#.....#
............#...#..#.......#.#.
#.#.....#.........#...#......#.
#.###..#......#..#..#...#.....#
.....#.......#.................
........#..#......#.#...#......
#.......#..#........#...#..#...
..#...#.......##.............#.
#.......#.......##...#.........
.........#....#.#..##.....#...#
..#.....#.#.......#....#.......
...#.......#.....#..##.#..#....
....#.......#.#.#..............
.#..#......#........#.#..##..##
....#...#.##.#...#....##...#...
#..##..#.....#.......#.........
....#..#..#.#............#.....
#.......##...##..##............
...............................
....#.......#.##...#.....#.#...
...#........#....#.#..#..#.....
##.......#.....##.#.#....#....#
#.............#...........#.##.
#...........#.#..........#.....
#..#....#....#.#.........#.#...
......#.#.#..#.#.#.............
...#.....#........##....#......
..#...#...#.#.......#......#...
.##........#...#..#..........#.
..#...........#..##.....##.....
............#..#.#...#.....#...
..........#....##.......#......
....#....#.................#..#
....#...............#.........#
..#.#...#......#..........##...
.....#...........#.........#..#
.......#.....##.....#.#........
.#.#..........#....#...........
.#..##....#........#....#......
....#.#..#.......#..#.........#
..#....#.....#......#..#.......
......#........#.......#...#.#.
.......#.......#....#.....##...
....##........#..#...#.#..#...#
.#......#...........##....#....
##....##......#.......#.......#
.##....#.##......#.......##..#.
...#..#.#.#.......#..#.###.....
..........##....#..#.##........
...#........###.#..#........#..
.....#....#..##....#.....#....#
#..........#..........#.#....#.
..#....#.....#..............#..
#..................#......#.##.
.#...#.#.....#.........##......
...#...........#.....#......#..
......#.....#.#..##......##....
...#....###..#.....#..#..##..##
......#.......##..#..#.........
#..#.#....#.#..#..........##.#.
..#..#..##..#.#.#.#.....#......
..#.#...#..#.....###.#.........
##.#.#......#........#.####....
.............#..#..#....#......
...##..........#.......#.#....#
..#.....................#......
..#..#...##...#.##........#....

23
4/1.py Normal file
View file

@ -0,0 +1,23 @@
def validate(entry, required_fields):
for field in required_fields:
if field not in entry:
return False
return True
entries = []
entry = {}
with open("input") as f:
for line in f:
line = line.strip()
if not line:
entries.append(entry)
entry = {}
else:
for field in line.split(" "):
key, value = field.split(":")
entry[key] = value
entries.append(entry)
required = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid']
print(list(map(lambda x: validate(x, required), entries)).count(True))

54
4/2.py Normal file
View file

@ -0,0 +1,54 @@
def validate_int(value, mi, ma):
value = int(value)
return mi <= value <= ma
def validate_height(value):
v = int(value[:-2])
t = value[-2:]
if (t == "cm" and 150<=v<=193) or (t == "in" and 59<=v<=76):
return True
return False
def validate_hex(h):
return h[0] == "#" and len(h[1:]) == 6 and is_int(h[1:], base=16)
def is_int(x, base=10):
try:
int(x, base=base)
except ValueError:
return False
return True
validators = {
'byr': lambda x: validate_int(x, 1920, 2002),
'iyr': lambda x: validate_int(x, 2010, 2020),
'eyr': lambda x: validate_int(x, 2020, 2030),
'hgt': lambda x: validate_height(x),
'hcl': lambda x: validate_hex(x),
'ecl': lambda x: x in ['amb', 'blu', 'brn', 'gry', 'grn', 'hzl', 'oth'],
'pid': lambda x: len(x) == 9 and is_int(x)
}
def validate(entry, required_fields):
for field in required_fields:
if field not in entry or not validators[field](entry[field]):
return False
return True
entries = [{}]
index = 0
with open("input") as f:
for line in f:
line = line.strip()
if not line:
entries.append({})
index = index + 1
else:
for entry in line.split(" "):
key, value = entry.split(":")
entries[index][key] = value
required = ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid']
print(list(map(lambda x: validate(x, required), entries)).count(True))

1023
4/input Normal file

File diff suppressed because it is too large Load diff

33
5/1.py Normal file
View file

@ -0,0 +1,33 @@
def calculate_position(code):
rowt = 128
rowb = 0
colb = 0
colt = 8
for l in code[:7]:
if l == "F":
rowt = (rowt + rowb) / 2
else:
rowb = (rowt + rowb) / 2
for l in code[7:]:
if l == "L":
colt = (colt + colb) / 2
else:
colb = (colt + colb) / 2
return int(rowt-1), int(colt-1)
def calculate_id(row, col):
return (row * 8) + col
with open("input") as f:
max_id = 0
for line in f:
line = line.strip()
new_id = calculate_id(*calculate_position(line))
if new_id > max_id:
max_id = new_id
print(max_id)

33
5/2.py Normal file
View file

@ -0,0 +1,33 @@
def calculate_position(code):
rowt = 128
rowb = 0
colb = 0
colt = 8
for l in code[:7]:
if l == "F":
rowt = (rowt + rowb) / 2
else:
rowb = (rowt + rowb) / 2
for l in code[7:]:
if l == "L":
colt = (colt + colb) / 2
else:
colb = (colt + colb) / 2
return int(rowt-1), int(colt-1)
def calculate_id(row, col):
return (row * 8) + col
with open("input") as f:
ids = []
for line in f:
line = line.strip()
new_id = calculate_id(*calculate_position(line))
ids.append(new_id)
ids.sort()
for i in range(len(ids) - 1):
if ids[i] + 2 == ids[i+1]:
print(ids[i] + 1)

933
5/input Normal file
View file

@ -0,0 +1,933 @@
BBBFBFFRLR
BFFFFFFRLL
BFBBBBFLLL
BBFBFFFRRR
BBBFBFBRLR
FBFFBBBLRL
FBFFBFFRRL
FFBBFFFRRL
BBBFBFBLLL
BBBBFFFLLR
FBBFFBFRRR
BFFFBBBLRR
FFBBFFBRLR
FFBFFBFRRL
BBBBFBFRLL
BBBBBFFLRL
FFBBBFBRRR
FFFBBBFLLR
FFBFFBBLRL
FBBFBBFLRL
FFBBBBFRRR
BFBFBFFRLL
BBFBFFFLLL
FFFBBBFRRL
BBFFBFBRLL
FBFBFBFLLL
BBFFFFBLRR
FFBBBFFRRL
FFFBFBBLRL
FBBFBBBLLL
BBFBFFBRLR
FBFBFBBRLL
FFFBBFBLRL
FFBFFBFLRR
BBFBBBFRRL
BBFBBFBLLR
BBFBBBFRLL
BFFBBBBRLR
FBFBFBBRLR
FBBBFFBRRR
FBBBFBFLLR
FFBFBBFLRL
BFBFBFBRLL
BFFFBFBLRR
FFBBBFBRLR
BBFBFFBLRR
BFFFFBBLLL
BFFFFBFLLR
FBFBBBBRLR
BBFFBBFLRL
BFBFFBBRLR
FFFBFBFRLL
BFFFBBFRRL
BBFBFBFRLL
BFBFFFFRRL
FFBFBBBRLR
FBBFFFFLRR
FBFBBFBRLR
BBFFBFFLRR
BBBFFBFLRR
BFFFFFBRLR
FBBFFFBRRL
BFFFBBFRRR
BBBFBFBRLL
BFBBFBBRLR
BFBFBFBLLL
BBBFFFFRLL
BFFFFBFRLL
FFBBFFBL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FRRL
FBBBBFFLLR
FFFBFFFRRR
BBBFFFBLLR
BBBFBBBLRR
BBFBBFBLLL
FFBBBFBLRR
BFBFFBFLRR
BFFBBFBLRL
BFBBFFBLLR
FBFFBBBRRR
BBBFBBFLRL
BFBFBFFRRL
BBBFBBBLRL
FBFBBBBRLL
BFFFFBFRRL
BFFFFFBRLL
BFFFFBFLRL
FBBFFBFRLL
BBBFBFBLLR
BBBFBBBRLR
BFFBFFFLRR
BFFBFBBLLR
FBFBBFFRRL
BBFBFBBLLR
BFFFFFBLLL
BFFBBFFLLR

13
6/1.py Normal file
View file

@ -0,0 +1,13 @@
entry = set()
total = 0
with open("input") as f:
for line in f:
line = line.strip()
if not line:
total += len(entry)
entry = set()
else:
entry = set(line) | set(entry)
total += len(entry)
print(total)

19
6/2.py Normal file
View file

@ -0,0 +1,19 @@
entry = set()
total = 0
new_group = True
with open("input") as f:
for line in f:
line = line.strip()
if not line:
total += len(entry)
entry = set()
new_group = True
else:
if new_group:
new_group = False
entry = set(line)
else:
entry = set(line) & entry
total += len(entry)
print(total)

15
6/einput Normal file
View file

@ -0,0 +1,15 @@
abc
a
b
c
ab
ac