We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f51ab66 commit 1455dc9Copy full SHA for 1455dc9
2025/src/day1.py
@@ -0,0 +1,36 @@
1
+from math import floor
2
+from common import *
3
+
4
+DAY_NUMBER = 1
5
6
+with get_data(DAY_NUMBER) as f:
7
+ instructions = [int(i) for i in [lines.strip().replace('R', '').replace('L', '-') for lines in f.readlines()]]
8
9
+# Part 1
10
+dial = 50
11
+result = 0
12
13
+for i in instructions:
14
+ dial += i
15
+ dial %= 100
16
17
+ if dial == 0:
18
+ result += 1
19
20
+print_result(DAY_NUMBER, 1, result)
21
22
+# Part 2
23
24
25
26
27
+ was_zero = dial == 0
28
29
30
+ result += floor(abs(dial) / 100)
31
+ result += 1 if ((dial < 0 or dial == 0) and not was_zero) else 0
32
33
34
35
+print_result(DAY_NUMBER, 2, result)
36
0 commit comments