1 | initial version |
Here is an alternative solution that explicitly uses the set $X={1,2,\dots,8}$ where the permutation is acting on, and a dictionary dic
that passes from $X$ to the letters. The dictionary is a replacement for the increment/decrement that converts between pythonic indexing and the natural set permutations act on...
letters = list('abcdefgh')
X = list(range(1, len(letters) + 1))
dic = dict( zip(X, letters) )
test_pi = Permutation((1,5,8,4), (2,6,7,3))
[dic[test_pi(x)] for x in X]
We obtain:
['e', 'b', 'c', 'a', 'h', 'f', 'g', 'd']
sage: ''.join(_)
'ebcahfgd'