Processing math: 100%
Ask Your Question
0

What is the bug ?

asked 9 years ago

Anupamsage gravatar image

I am writing this code in sage online worksheet given a tuple say a=(a1,a2,...an) \phi be an permutation in S_n then \phi(a)= (a_\phi(1),...,a_\phi(n)) I want to count the number of permutation that fixes a The code is as follows

def Aut(tuple): c=1 for a in SymmetricGroup(len(tuple)): if a.action(tuple)== tuple : c=c+1

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 9 years ago

B r u n o gravatar image

There is no method action for elements of the symmetric group. You should write a(tuple) instead of a.action(tuple). And by the way, your function does not return anything, and I think c should be initialized to 0. Maybe:

def Aut(tuple):
    c = 0
    for a in SymmetricGroup(len(tuple)):
        if a(tuple) == tuple:
            c = c+1
    return c
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 9 years ago

Seen: 805 times

Last updated: May 03 '16