solved day 1
This commit is contained in:
4036
1/input.txt
Normal file
4036
1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
30
1/main.py
Normal file
30
1/main.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
START_POS = 50
|
||||||
|
MODULO = 100
|
||||||
|
|
||||||
|
position = START_POS
|
||||||
|
anzahl_null = 0
|
||||||
|
|
||||||
|
with open("input.txt", encoding="utf-8") as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
|
||||||
|
richtung = line[0].upper()
|
||||||
|
schritte = int(line[1:])
|
||||||
|
|
||||||
|
if richtung == "L":
|
||||||
|
position = (position - schritte) % MODULO
|
||||||
|
elif richtung == "R":
|
||||||
|
position = (position + schritte) % MODULO
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Unbekannte Richtung in Zeile: {line}")
|
||||||
|
|
||||||
|
if position == 0:
|
||||||
|
anzahl_null += 1
|
||||||
|
|
||||||
|
print("Anzahl, wie oft 0 erreicht wird:", anzahl_null)
|
||||||
|
print("Endposition:", position)
|
||||||
|
|
||||||
|
# times 0 is reached: 984
|
||||||
|
# end position: 90
|
||||||
Reference in New Issue
Block a user