This commit is contained in:
Gareth
2025-12-01 18:11:11 +00:00
parent 358249e78a
commit 015607cde3
8 changed files with 4247 additions and 0 deletions

49
2025/gareth/day01/poc.py Normal file
View File

@@ -0,0 +1,49 @@
def part1(input_file):
file = open(input_file, "r")
line = file.readline()
position = 50
output = 0
while line:
direction = line[0]
amount = int(line[1:])
if direction == "R":
position += amount
while position > 99:
position -= 100
elif direction == "L":
position -= amount
while position < 0:
position += 100
if position == 0:
output += 1
line = file.readline()
file.close()
print("Part 1:", output)
def part2(input_file):
position = 50
output = 0
with open(input_file) as file:
for line in file:
line = line.strip()
direction = line[0]
amount = int(line[1:])
step = 1 if direction == "R" else -1
for _ in range(amount):
position = (position + step) % 100
if position == 0:
output += 1
print("Part 2:", output)
part1("input.txt")
part2("input.txt")