Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Follow Ghost Legs by ssk8
def follow_ghost_legs(n: int, legs: list[tuple[int, int]]) -> list[int]:
positions = [0] * n
for start_pos in range(1, n + 1):
cur_pos = start_pos
for leg in legs:
if len(o := tuple({cur_pos,} ^ {*leg})) == 1:
cur_pos = o[0]
positions[cur_pos - 1] = start_pos
return positions
April 5, 2025
Comments: