def AlternatingGroup(n):
 if (n in (1, 2)):
  return PermutationGroup([Permutation([0])])
 a = list(range(n))
 (a[0], a[1], a[2]) = (a[1], a[2], a[0])
 gen1 = a
 if (n % 2):
  a = list(range(1, n))
  a.append(0)
  gen2 = a
 else:
  a = list(range(2, n))
  a.append(1)
  a.insert(0, 0)
  gen2 = a
 gens = [gen1, gen2]
 if (gen1 == gen2):
  gens = gens[:1]
 G = PermutationGroup([_af_new(a) for a in gens], dups=False)
 if (n < 4):
  G._is_abelian = True
  G._is_nilpotent = True
 else:
  G._is_abelian = False
  G._is_nilpotent = False
 if (n < 5):
  G._is_solvable = True
 else:
  G._is_solvable = False
 G._degree = n
 G._is_transitive = True
 G._is_alt = True
 return G

def AlternatingGroup ( n ) : if ( n in ( 1 , 2 ) ) : return PermutationGroup ( [ Permutation ( [ 0 ] ) ] ) a = list ( range ( n ) ) ( a [ 0 ] , a [ 1 ] , a [ 2 ] ) = ( a [ 1 ] , a [ 2 ] , a [ 0 ] ) gen1 = a if ( n % 2 ) : a = list ( range ( 1 , n ) ) a . append ( 0 ) gen2 = a else : a = list ( range ( 2 , n ) ) a . append ( 1 ) a . insert ( 0 , 0 ) gen2 = a gens = [ gen1 , gen2 ] if ( gen1 == gen2 ) : gens = gens [ : 1 ] G = PermutationGroup ( [ _af_new ( a ) for a in gens ] , dups = False ) if ( n < 4 ) : G . _is_abelian = True G . _is_nilpotent = True else : G . _is_abelian = False G . _is_nilpotent = False if ( n < 5 ) : G . _is_solvable = True else : G . _is_solvable = False G . _degree = n G . _is_transitive = True G . _is_alt = True return G
generates the alternating group on n elements as a permutation group .