Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
no factorial solution in Clear category for Permutation Index by karlian
from typing import Tuple
def permutation_index(numbers: Tuple[int]) -> int:
idx, n = 0, len(numbers)
pool = list(range(n))
for i, x in zip(range(n, -1, -1), numbers):
r = pool.index(x)
idx = idx * i + r
del pool[r]
return idx + 1
July 14, 2022
Comments: