Sympy:排列作用于列表?

问题描述 投票:1回答:1

Sympy noob想知道如何使Sympy Permutation应用于列表。例如,

from sympy.combinatorics import Permutation

lst = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
perm = Permutation([[0, 2, 8, 6], [1, 5, 7, 3]])
# Then something like...
perm * lst   # This doesn't work. Throws AttributeError because of list

我想要这样的东西返回(在此示例中:)]

['g', 'd', 'a', 'h', 'e', 'b', 'i', 'f', 'c']

我已经读过https://docs.sympy.org/latest/modules/combinatorics/permutations.html,但不知道如何。

关于任何可能的解决方法的任何建议?

Sympy noob想知道如何使Sympy Permutation应用于列表。例如,从sympy.combinatorics导入置换lst = ['a','b','c','d','e','f','g','h','i'] perm =置换([[[0,...

python-3.x permutation sympy combinatorics
1个回答
0
投票

您可以只执行perm(lst)

© www.soinside.com 2019 - 2024. All rights reserved.