All problems
Inverse Permutation for Cipher Decoding
Problem
Return the inverse of a permutation given as a 0-indexed list: inv[perm[i]] = i. The inverse undoes a transposition cipher's column shuffling.
Hint
Applying a permutation and then its inverse returns the identity.
Test cases
case 1
in: [[2,0,1]]
expected: [1,2,0]
case 2
in: [[0,1,2]]
expected: [0,1,2]
case 3
in: [[1,0,3,2]]
expected: [1,0,3,2]
case 4
in: [[3,2,1,0]]
expected: [3,2,1,0]
Starter codePython
def inverse_permutation(perm):
# Your code here
pass4 test cases · run your code against them in the editor