commit ebf224386f9c7b7ee6a7773dc9ecc6d3d8cd67ef
parent 231c53e94f70be860ec574029d6b2b8c60230477
Author: Andrew Laack <andrew@laack.co>
Date: Mon, 17 Aug 2026 14:43:17 -0500
AoC 2025 problem 1
Diffstat:
1 file changed, 50 insertions(+), 0 deletions(-)
diff --git a/aoc_2025_1/aoc_2025_1.py b/aoc_2025_1/aoc_2025_1.py
@@ -0,0 +1,50 @@
+# 0 - 99
+
+class Dial:
+
+ position = 0
+
+ def __init__(self, starting_position):
+ self.position = starting_position
+ def rotate_right(self, num):
+ self.position = (self.position + num) % 100
+ def rotate_left(self, num):
+ self.position = (self.position - num)
+ while self.position < 0:
+ self.position += 100
+
+ # returns number of times the dial was at 0
+ # not including starting state
+
+ def follow_instructions(self, instructions):
+ count = 0
+ for instruction in instructions:
+ if len(instruction) < 2:
+ raise ValueError()
+
+ if instruction[0] == 'L':
+ self.rotate_left(int(instruction[1:]))
+ elif instruction[0] == 'R':
+ self.rotate_right(int(instruction[1:]))
+ else:
+ raise ValueError()
+ if self.position == 0:
+ count += 1
+ return count
+
+dial = Dial(50)
+
+instructions = [
+"L68",
+"L30",
+"R48",
+"L5",
+"R60",
+"L55",
+"L1",
+"L99",
+"R14",
+"L82"
+]
+
+print(dial.follow_instructions(instructions))