15-2 fertig

This commit is contained in:
2023-12-15 16:45:15 +01:00
parent c3a07f43df
commit 240685a703
2 changed files with 11 additions and 9 deletions

2
.idea/misc.xml generated
View File

@@ -3,7 +3,7 @@
<component name="Black">
<option name="sdkName" value="Python 3.11 (AdventOfCode2023)" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="Python 3.10 (AdventOfCode2023)" project-jdk-type="Python SDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="Python 3.11 (AdventOfCode2023)" project-jdk-type="Python SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -3,7 +3,7 @@
data = []
# parse input
input_file = open("input-ex1", "r")
input_file = open("input", "r")
pattern = []
for line in input_file:
for value in line.rstrip().split(","):
@@ -12,12 +12,12 @@ input_file.close()
def get_hash(val):
h = 0
hav = 0
for b in val:
h += ord(b)
h *= 17
h %= 256
return h
hav += ord(b)
hav *= 17
hav %= 256
return hav
hashsum = 0
@@ -59,5 +59,7 @@ print(boxes)
solution = 0
for key in boxes.keys():
for k in range(len(boxes[key])):
pass
print(key+1, k+1, int(boxes[key][k].split("=")[1]))
solution += ((key+1) * (k+1) * int(boxes[key][k].split("=")[1]))
print("Solution", solution)