code: def AlternatingGroup(n):
      """
      Generates the alternating group on ``n`` elements as a permutation group.
  
      Explanation
      ===========
  
      For ``n > 2``, the generators taken are ``(0 1 2), (0 1 2 ... n-1)`` for
      ``n`` odd
      and ``(0 1 2), (1 2 ... n-1)`` for ``n`` even (See [1], p.31, ex.6.9.).
      After the group is generated, some of its basic properties are set.
      The cases ``n = 1, 2`` are handled separately.
  
      Examples
      ========
  
      >>> from sympy.combinatorics.named_groups import AlternatingGroup
      >>> G = AlternatingGroup(4)
      >>> G.is_group
      True
      >>> a = list(G.generate_dimino())
      >>> len(a)
      12
      >>> all(perm.is_even for perm in a)
      True
  
      See Also
      ========
  
      SymmetricGroup, CyclicGroup, DihedralGroup
  
      References
      ==========
  
      .. [1] Armstrong, M. "Groups and Symmetry"
  
      """
      # small cases are special
      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)
  
      set_alternating_group_properties(G, n, n)
      G._is_alt = True
      return G
  
file_path: sympy/sympy/combinatorics/named_groups.py
imports: from sympy.combinatorics.group_constructs import DirectProduct
  from sympy.combinatorics.perm_groups import PermutationGroup
  from sympy.combinatorics.permutations import Permutation
label_desc: Use image node_id 2 for calling a global function with example usage: AlternatingGroup(n) and returns: G, PermutationGroup