First time here? Check out the FAQ!
answered 2022-01-23 22:33:06 +0100
Solution via indirect sorting:
L1=[1,2,5,6,3,4,4,8,2,1,9,3,2] L2=[1,2,2,5,6,4,3,4,8,9,1,2,3] perm = Word(L2).standard_permutation() / Word(L1).standard_permutation() assert [L1[i-1] for i in perm] == L2 print(perm)