Initial setup

This commit is contained in:
2020-12-06 23:33:55 +01:00
parent 719c643b03
commit e011ff8444
13 changed files with 2817 additions and 0 deletions

1000
Ressources/InputDay2.txt Normal file

File diff suppressed because it is too large Load Diff

323
Ressources/InputDay3.txt Normal file
View File

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

1102
Ressources/InputDay4.txt Normal file

File diff suppressed because it is too large Load Diff

200
Ressources/NumsDay1.txt Normal file
View File

@@ -0,0 +1,200 @@
1046
1565
1179
1889
1683
1837
1973
1584
1581
192
1857
1373
1715
1473
1770
1907
1918
1909
1880
1903
1835
1887
1511
1844
1628
1688
1545
1469
1620
1751
1893
1861
511
1201
1641
1874
1946
1701
1777
1829
1609
1805
1678
1928
1398
1555
1675
1798
1485
1911
1974
1663
1919
1635
195
1441
1525
1490
1151
1406
1408
1095
1085
1097
1976
1987
1498
1753
1603
1933
1729
1106
1929
1832
1744
1914
1643
1571
1391
1953
1790
1797
1938
258
1957
1858
1506
628
1109
1113
1768
1649
1669
694
1803
1849
1395
1754
1421
1575
1632
1998
1693
1499
1550
1771
1902
1801
1549
1459
1826
1927
1507
1718
647
1922
1432
1625
1904
1691
1427
1519
1949
1514
1749
1616
1898
1696
1917
1661
1787
1440
1796
1560
1956
1823
1815
1557
1730
1951
1548
1527
1881
1727
1530
1460
1360
1583
1662
1954
1890
1855
1752
1935
1601
1767
1812
1990
1445
1908
2001
1544
1814
1634
1532
1788
1521
1638
1470
1524
1394
1674
1314
1588
1429
1745
1416
1637
1942
484
1467
1764
1743
1401
1471
1458
1335
1866
1399
1393
1708
1694
1447
1972
1478
1182
1672
1813
1546
1535

13
Ressources/Test.txt Normal file
View File

@@ -0,0 +1,13 @@
ecl:gry pid:860033327 eyr:2020 hcl:#fffffd
byr:1937 iyr:2017 cid:147 hgt:183cm
iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884
hcl:#cfa07d byr:1929
hcl:#ae17e1 iyr:2013
eyr:2024
ecl:brn pid:760753108 byr:1931
hgt:179cm
hcl:#cfa07d eyr:2025 pid:166559648
iyr:2011 ecl:brn hgt:59in

10
Scripts/Day1_1.py Normal file
View File

@@ -0,0 +1,10 @@
f = open("Ressources/NumsDay1.txt", 'r')
nums = f.readlines()
nums = [int(i) for i in nums]
for i in nums:
for j in nums:
if i + j == 2020:
print(i*j)
break

11
Scripts/Day1_2.py Normal file
View File

@@ -0,0 +1,11 @@
f = open("Ressources/NumsDay1.txt", 'r')
nums = f.readlines()
nums = [int(i) for i in nums]
for i in nums:
for j in nums:
for k in nums:
if i + j + k == 2020:
print(i*j*k)
break

21
Scripts/Day2_1.py Normal file
View File

@@ -0,0 +1,21 @@
f = open("Ressources/InputDay2.txt", 'r')
input = f.readlines()
limiters = []
chars = []
passwords = []
for i in input:
limiter, char, password = i.split(" ")
limiters.append(limiter)
chars.append(char[0])
passwords.append(password.strip())
validPasswords = 0
for (password, char, limiter) in zip(passwords, chars, limiters):
if int(limiter.split('-')[0]) <= password.count(char) <= int(limiter.split('-')[1]):
validPasswords += 1
print(validPasswords)

21
Scripts/Day2_2 copy.py Normal file
View File

@@ -0,0 +1,21 @@
f = open("Ressources/InputDay2.txt", 'r')
input = f.readlines()
indexes = []
chars = []
passwords = []
for i in input:
index, char, password = i.split(" ")
indexes.append(index)
chars.append(char[0])
passwords.append(password.strip())
validPasswords = 0
for (password, char, index) in zip(passwords, chars, indexes):
if (password[int(index.split('-')[0])-1] == char) ^ (password[int(index.split('-')[1])-1] == char):
validPasswords += 1
print(validPasswords)

23
Scripts/Day3_1.py Normal file
View File

@@ -0,0 +1,23 @@
xPosition = 0
treesEncounterd = 0
def makeStep():
global xPosition
if xPosition+3 >= map[0].__len__():
xPosition = (xPosition+3) - map[0].__len__()
else :
xPosition += 3
f = open("Ressources/InputDay3.txt", 'r')
map = [f.strip() for f in f.readlines()]
deepestLevel = map.__len__()
for i in range(1,deepestLevel):
makeStep()
if map[i][xPosition] == '#':
treesEncounterd += 1
print(treesEncounterd)

25
Scripts/Day3_2.py Normal file
View File

@@ -0,0 +1,25 @@
import numpy
f = open("Ressources/InputDay3.txt", 'r')
map = [f.replace('\n', '') for f in f.readlines()]
rightSteps = [1,3,5,7,1]
downSteps = [1,1,1,1,2]
treesEncounterd = []
x_pos = 0
counter = 0
for right, down in zip(rightSteps, downSteps):
trees = 0
x_pos = 0
for y_pos in range (0, len(map), down):
if map[y_pos][x_pos] == '#':
trees += 1
x_pos = (x_pos + right) % len(map[0])
treesEncounterd.append(trees)
print (numpy.prod(treesEncounterd))

27
Scripts/Day4_1.py Normal file
View File

@@ -0,0 +1,27 @@
f = open("Ressources/InputDay4.txt", 'r')
input = ""
for line in f:
if not line.isspace():
input += line
else:
input += 'ü'
input = input.replace("\n", "")
passports = input.split('ü')
requiered = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]
valid = 0
for passport in passports:
matches = 0
for requierdInfo in requiered:
if requierdInfo in passport:
matches += 1
if matches == len(requiered):
valid += 1
print(valid)

41
Scripts/Day4_2.py Normal file
View File

@@ -0,0 +1,41 @@
f = open("Ressources/Test.txt", 'r')
input = ""
for line in f:
if not line.isspace():
input += line
else:
input += 'ü'
input = input.replace("\n", "")
passports = input.split('ü')
requiered = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]
minValueCm = ["1920", "2010", "2020", "150", "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$", "amb blu brn gry grn hzl oth", "^0\d{8}$"]
maxValueIn = ["2002", "2020", "2030", "193", "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$", "amb blu brn gry grn hzl oth", "^0\d{8}$"]
minValueIn = ["1920", "2010", "2020", "59", "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$", "amb blu brn gry grn hzl oth", "^0\d{8}$"]
maxValueIn = ["2002", "2020", "2030", "76", "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$", "amb blu brn gry grn hzl oth", "^0\d{8}$"]
minValueCmDict = dict(zip(requiered, minValueCm))
maxValueInDict = dict(zip(requiered, maxValueIn))
minValueInDict = dict(zip(requiered, minValueIn))
maxValueInDict = dict(zip(requiered, maxValueIn))
valid = 0
for passport in passports:
matches = 0
keys = passport.split
# for requierdInfo in requiered:
# if requierdInfo in passport:
# matches += 1
# if matches == len(requiered):
# valid += 1
print(valid)