Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Gator And Ducks by freeman_lex
def gator(ducks: int, step: int) -> list[int]:
res = [0] * ducks
circle = list(range(ducks))
for i in range(1, ducks + 1):
for _ in range(step-1):
circle.append(circle.pop(0))
res[circle.pop(0)] = i
return res
print("Example:")
print(gator(3, 2))
# These "asserts" are used for self-checking
assert gator(8, 4) == [5, 4, 6, 1, 3, 8, 7, 2]
assert gator(7, 11) == [7, 2, 3, 1, 5, 6, 4]
assert gator(3, 1) == [1, 2, 3]
print("The mission is done! Click 'Check Solution' to earn rewards!")
March 17, 2024
Comments: