Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Arithmetic formulation solution in Clear category for Permutation Index by tokyoamado
from functools import reduce
from typing import Tuple
def permutation_index(numbers: Tuple[int])->int:
idx = [sorted(numbers[i:]).index(n) for i, n in enumerate(numbers)]
weighted = list(reversed(list(enumerate(reversed(idx)))))[:-1]
return reduce(lambda s, x: (s + x[1]) * x[0], weighted, 0) + 1
Oct. 28, 2019