15-1 fertig
This commit is contained in:
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,8 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.11 (AdventOfCode2023)" />
|
<option name="sdkName" value="Python 3.11 (AdventOfCode2023)" />
|
||||||
</component>
|
</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" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
22
15/15-1.py
Normal file
22
15/15-1.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
data = []
|
||||||
|
|
||||||
|
# parse input
|
||||||
|
input_file = open("input-ex1", "r")
|
||||||
|
pattern = []
|
||||||
|
for line in input_file:
|
||||||
|
for value in line.rstrip().split(","):
|
||||||
|
data.append(value)
|
||||||
|
input_file.close()
|
||||||
|
|
||||||
|
hashsum = 0
|
||||||
|
for value in data:
|
||||||
|
hash = 0
|
||||||
|
for b in value:
|
||||||
|
hash += ord(b)
|
||||||
|
hash *= 17
|
||||||
|
hash %= 256
|
||||||
|
print(value, hash)
|
||||||
|
hashsum += hash
|
||||||
|
print("Hashsumme:", hashsum)
|
||||||
27
15/15-2.py
Normal file
27
15/15-2.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
data = []
|
||||||
|
|
||||||
|
# parse input
|
||||||
|
input_file = open("input-ex1", "r")
|
||||||
|
pattern = []
|
||||||
|
for line in input_file:
|
||||||
|
for value in line.rstrip().split(","):
|
||||||
|
data.append(value)
|
||||||
|
input_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
def get_hash(val):
|
||||||
|
h = 0
|
||||||
|
for b in value:
|
||||||
|
h += ord(b)
|
||||||
|
h *= 17
|
||||||
|
h %= 256
|
||||||
|
return h
|
||||||
|
|
||||||
|
|
||||||
|
hashsum = 0
|
||||||
|
for value in data:
|
||||||
|
print(value, get_hash(value))
|
||||||
|
hashsum += get_hash(value)
|
||||||
|
print("Hashsumme:", hashsum)
|
||||||
1
15/input-ex
Normal file
1
15/input-ex
Normal file
@@ -0,0 +1 @@
|
|||||||
|
HASH
|
||||||
1
15/input-ex1
Normal file
1
15/input-ex1
Normal file
@@ -0,0 +1 @@
|
|||||||
|
rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7
|
||||||
Reference in New Issue
Block a user