adnanaziz/EPIJudge

Problem No. 5.10, Apply Permutations Python

Closed this issue · 3 comments

Correct me if I am wrong. I am unable to understand the how the test case works on the solution provided.

A = [0,1, 2, 3, 4, 5]
P = [3, 5, 0, 4, 1, 2]

Expected A after permutation = [3, 5, 0, 4, 1, 2]
Actual A after permutation = [2, 4, 5, 0, 3, 1]

Please help correct my understanding if wrong. Posting it here, as I didn't find any good place to post it.

You misinterpret the parameter orderings. The first line of test data (https://github.com/adnanaziz/EPIJudge/blob/master/test_data/apply_permutation.tsv) shows it is permutation then A. It is also listed in https://github.com/adnanaziz/EPIJudge/blob/master/epi_judge_python_solutions/apply_permutation.py in the function signature.

Thanks for the reply. But I have trouble understanding this

For example, the permutation (2,0,1,3) applied to A = (a,b,c,d) yields
the array (b,c,a,d).
@tsunghsienlee could you please help clarify this. according to me, it should be (c,a,b,d). Thanks a ton!

Nevermind, I got it. Thanks to The indices in the permutation actually represent where the element would move to after getting permuted.