-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday1.py
More file actions
38 lines (28 loc) · 715 Bytes
/
day1.py
File metadata and controls
38 lines (28 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import math
file = open("./day1_input", "r")
content = file.read()
strings = content.split("\n")
steps = [(string[:1], string[1:]) for string in strings]
dial = 50
key = 0
for step in steps:
if step[0] == "L":
dial = dial - int(step[1])
elif step[0] == "R":
dial = dial + int(step[1])
dial = dial % 100
if dial == 0:
key += 1
print("easy mode:", key)
dial = 50
key = 0
for step in steps:
if step[0] == "L":
if int(step[1]) >= dial and dial != 0:
key += 1
dial = dial - int(step[1])
elif step[0] == "R":
dial = dial + int(step[1])
key = key + math.floor(abs(dial) / 100)
dial = dial % 100
print("hard mode:", key)