Question: Please follow the steps to write this program. Use python only. Thank you. Problem 3. (Inverse Permutation) Write a program inverse-permutation.py that accepts a permutation
Please follow the steps to write this program. Use python only. Thank you.


Problem 3. (Inverse Permutation) Write a program inverse-permutation.py that accepts a permutation of the integers 0 through n-1 as n command-line arguments and writes its inverse. If the permutation is a list a, its inverse is the list b such that alb[i bla[i] - i. Be sure to check that the input is a valid permutation. If not, the program must exit with the message "Not a permutation" _you can do this by calling the function sys.exit (msg), where nsg is the message you want to write s python3 inverse_permutation.py 1 2 3 4 5 Not a permutation $ python3 i 3 4 5 1 2 0 $ python3 inverse-permutation.py 0 12 34 5 0 1 2 3 4 5 $ python3 inverse permutation.py 5 4 3 2 1 0 543210 nverse.perautation.py 5 3 4012 Problem 3. (Inverse Permutation) Write a program inverse-permutation.py that accepts a permutation of the integers 0 through n-1 as n command-line arguments and writes its inverse. If the permutation is a list a, its inverse is the list b such that alb[i bla[i] - i. Be sure to check that the input is a valid permutation. If not, the program must exit with the message "Not a permutation" _you can do this by calling the function sys.exit (msg), where nsg is the message you want to write s python3 inverse_permutation.py 1 2 3 4 5 Not a permutation $ python3 i 3 4 5 1 2 0 $ python3 inverse-permutation.py 0 12 34 5 0 1 2 3 4 5 $ python3 inverse permutation.py 5 4 3 2 1 0 543210 nverse.perautation.py 5 3 4012
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
