Idk I wanted to modify it a bit.
This commit is contained in:
parent
34e6bc20d6
commit
e014c806bd
2 changed files with 19 additions and 14 deletions
|
|
@ -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!
|
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?
|
Using password method 0x434C49434B, what is the password to open the door?
|
||||||
|
|
||||||
|
## 1059
|
||||||
|
|
||||||
|
## 6305
|
||||||
|
|
|
||||||
27
01/main.py
27
01/main.py
|
|
@ -24,34 +24,35 @@ def parse_input(input_filepath: str) -> list[int]:
|
||||||
|
|
||||||
|
|
||||||
def simulate_rotations(rotations_list: list[int]) -> list[int]:
|
def simulate_rotations(rotations_list: list[int]) -> list[int]:
|
||||||
|
ending_positions = []
|
||||||
current_position = 50
|
current_position = 50
|
||||||
ending_positions: list[int] = []
|
zero_count = 0
|
||||||
full_rotations = 0
|
full_rotations = 0
|
||||||
|
|
||||||
debug(f"\n\nROTATIONS LIST: {rotations_list}\n\n")
|
debug(f"\n\nROTATIONS LIST: {rotations_list}\n\n")
|
||||||
|
|
||||||
for rotation in rotations_list:
|
for rotation in rotations_list:
|
||||||
previous_position = current_position
|
previous_position = current_position
|
||||||
if rotation < 0:
|
current_position += rotation - (int(rotation / 100) * 100)
|
||||||
temp_rotation = abs(rotation) % 100
|
|
||||||
current_position -= temp_rotation
|
full_rotations += int(abs(rotation) / 100)
|
||||||
else:
|
|
||||||
current_position += 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:
|
if current_position < 0:
|
||||||
current_position += 100
|
current_position += 100
|
||||||
if previous_position != 0:
|
|
||||||
full_rotations += 1
|
|
||||||
elif current_position > 99:
|
elif current_position > 99:
|
||||||
current_position -= 100
|
current_position -= 100
|
||||||
if current_position != 0:
|
if current_position == 0:
|
||||||
full_rotations += 1
|
zero_count += 1
|
||||||
full_rotations += int(abs(rotation) / 100)
|
|
||||||
ending_positions.append(current_position)
|
ending_positions.append(current_position)
|
||||||
|
|
||||||
debug(f"\n\nENDING POSITIONS: {ending_positions}\n\n")
|
debug(f"\n\nENDING POSITIONS: {ending_positions}\n\n")
|
||||||
|
|
||||||
zero_count = ending_positions.count(0)
|
|
||||||
|
|
||||||
print(f"Simulated ending positions at zero: {zero_count}")
|
print(f"Simulated ending positions at zero: {zero_count}")
|
||||||
|
|
||||||
return full_rotations + zero_count
|
return full_rotations + zero_count
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue