Idk I wanted to modify it a bit.

This commit is contained in:
Ada Werefox 2025-12-01 20:37:10 -08:00
parent 34e6bc20d6
commit e014c806bd
2 changed files with 19 additions and 14 deletions

View file

@ -90,3 +90,7 @@ In this example, the dial points at 0 three times at the end of a rotation, plus
Be careful: if the dial were pointing at 50, a single rotation like R1000 would cause the dial to point at 0 ten times before returning back to 50!
Using password method 0x434C49434B, what is the password to open the door?
## 1059
## 6305

View file

@ -24,34 +24,35 @@ def parse_input(input_filepath: str) -> list[int]:
def simulate_rotations(rotations_list: list[int]) -> list[int]:
ending_positions = []
current_position = 50
ending_positions: list[int] = []
zero_count = 0
full_rotations = 0
debug(f"\n\nROTATIONS LIST: {rotations_list}\n\n")
for rotation in rotations_list:
previous_position = current_position
if rotation < 0:
temp_rotation = abs(rotation) % 100
current_position -= temp_rotation
else:
current_position += rotation % 100
current_position += rotation - (int(rotation / 100) * 100)
full_rotations += int(abs(rotation) / 100)
if (current_position < 0 and previous_position != 0) or (
current_position > 99 and current_position != 100
):
full_rotations += 1
if current_position < 0:
current_position += 100
if previous_position != 0:
full_rotations += 1
elif current_position > 99:
current_position -= 100
if current_position != 0:
full_rotations += 1
full_rotations += int(abs(rotation) / 100)
if current_position == 0:
zero_count += 1
ending_positions.append(current_position)
debug(f"\n\nENDING POSITIONS: {ending_positions}\n\n")
zero_count = ending_positions.count(0)
print(f"Simulated ending positions at zero: {zero_count}")
return full_rotations + zero_count