• + 0 comments

    My solution

    def permutationEquation(p): return [p.index(p.index(x) + 1) + 1 for x in sorted(p)]

    I am just learning Python, so the syntax where I use one line with the for cycle at the end is new to me. Originally I wrote:

    def permutationEquation(p): answer = []

    for x in sorted(p):
        answer.append(p.index(p.index(x) + 1) + 1)    
    
    print(answer)