This commit is contained in:
marcus@weifer.de 2022-12-14 13:31:08 +01:00
commit a820af0b60
36 changed files with 1406 additions and 0 deletions

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,23 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="NonAsciiCharacters" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="mysql_connector_repackaged" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="PyPep8Inspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (AdventOfCode2020)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/AdventOfCode2020.iml" filepath="$PROJECT_DIR$/.idea/AdventOfCode2020.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

27
base.py Normal file
View File

@ -0,0 +1,27 @@
day = ""
file = f"inputs/{day}.txt"
def part_one(file):
result = 0
input = open(file, "r")
input = input.readlines()
print(f"Part 1: {result}")
part_one(file)
def part_two(file):
result = 0
input = open(file, "r")
input = input.readlines()
print(f"Part 2: {result}")
part_two(file)

39
day1.py Normal file
View File

@ -0,0 +1,39 @@
day = "day1"
file = f"inputs/{day}.txt"
def part_one(file):
result = 0
input = open(file, "r")
input = input.readlines()
check_number = 0
current_number = 0
for i in input:
for j in input:
if(int(i) + int(j) == 2020):
result = int(i) * int(j)
break
print(f"Part 1: {result}")
part_one(file)
def part_two(file):
result = 0
input = open(file, "r")
input = input.readlines()
for i in input:
for j in input:
for k in input:
if((int(i) + int(j) + int(k)) == 2020):
result = int(i) * int(j) * int(k)
break
print(f"Part 2: {result}")
part_two(file)

59
day2.py Normal file
View File

@ -0,0 +1,59 @@
day = "day2"
file = f"inputs/{day}.txt"
def part_one(file):
result = 0
input = open(file, "r")
input = input.readlines()
for line in input:
if(line_check(line)):
result += 1
print(f"Part 1: {result}")
def line_check(line):
string = line.split(' ')[2]
letter = line.split(" ")[1][0]
start = int(line.split(" ")[0].split("-")[0])
end = int(line.split(" ")[0].split("-")[1])
if(string.count(letter) >= start and string.count(letter) <= end):
return True
part_one(file)
def part_two(file):
result = 0
input = open(file, "r")
input = input.readlines()
for line in input:
if(line_check_part2(line)):
result += 1
print(f"Part 2: {result}")
def line_check_part2(line):
string = line.split(' ')[2]
letter = line.split(" ")[1][0]
start = int(line.split(" ")[0].split("-")[0])
end = int(line.split(" ")[0].split("-")[1])
if(string[start-1] == letter and string[end-1] == letter):
return False
elif(string[start-1] == letter or string[end-1] == letter):
return True
part_two(file)

5
inputs.py Normal file
View File

@ -0,0 +1,5 @@
def create_day_files():
for i in range(1,25):
f = open(f"inputs/day{i}.txt", "a")
create_day_files()

200
inputs/day1.txt Normal file
View File

@ -0,0 +1,200 @@
1150
1579
1361
1319
1201
1253
1806
1783
1164
1772
1920
1428
1918
245
1504
1952
1057
1977
704
1119
1971
1200
1650
1795
1877
1932
1811
1981
1803
1366
1580
1986
1976
1063
1895
1143
1991
1061
1855
1947
1134
1800
1898
1778
1964
1949
1103
1770
1321
2005
1758
1181
1140
1873
1946
1540
1909
1710
1705
1313
1196
1084
1870
1610
1708
1810
1133
1375
1264
1921
1624
41
1899
1226
1757
1978
1485
1385
1526
1653
1130
1223
1577
1912
1894
276
954
1269
1769
1924
93
1165
1812
1092
1402
1284
1903
1884
1581
1887
1963
1983
1233
1445
1974
1956
1691
1954
2000
1469
1875
955
1334
1116
1700
1818
1790
1704
1901
1072
1848
1990
1724
1719
1638
1311
1474
1837
1801
1929
1791
1317
1643
1632
1813
1488
1129
1998
1771
1793
1074
1826
1935
1462
1230
1797
1878
1751
1993
1437
1967
1844
1438
1969
1175
1823
1124
1922
154
936
1117
1145
1308
1320
1767
1850
1809
1350
1820
1082
1597
1913
1766
1701
1294
1556
2006
1480
1953
1104
1861
1966
1248
1671
1955
1863
1202
1356
1842
2010
1288
1067
1576
1295
1760
1888
1639
1282
1633
1619

0
inputs/day10.txt Normal file
View File

0
inputs/day11.txt Normal file
View File

0
inputs/day12.txt Normal file
View File

0
inputs/day13.txt Normal file
View File

0
inputs/day14.txt Normal file
View File

0
inputs/day15.txt Normal file
View File

0
inputs/day16.txt Normal file
View File

0
inputs/day17.txt Normal file
View File

0
inputs/day18.txt Normal file
View File

0
inputs/day19.txt Normal file
View File

1000
inputs/day2.txt Normal file

File diff suppressed because it is too large Load Diff

0
inputs/day20.txt Normal file
View File

0
inputs/day21.txt Normal file
View File

0
inputs/day22.txt Normal file
View File

0
inputs/day23.txt Normal file
View File

0
inputs/day24.txt Normal file
View File

0
inputs/day3.txt Normal file
View File

0
inputs/day4.txt Normal file
View File

0
inputs/day5.txt Normal file
View File

0
inputs/day6.txt Normal file
View File

0
inputs/day7.txt Normal file
View File

0
inputs/day8.txt Normal file
View File

0
inputs/day9.txt Normal file
View File

16
main.py Normal file
View File

@ -0,0 +1,16 @@
# This is a sample Python script.
# Press Umschalt+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Strg+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
# See PyCharm help at https://www.jetbrains.com/help/pycharm/