def _check_cycles_alt_sym(perm):
 n = perm.size
 af = perm.array_form
 current_len = 0
 total_len = 0
 used = set()
 for i in range((n // 2)):
  if ((not (i in used)) and (i < ((n // 2) - total_len))):
   current_len = 1
   used.add(i)
   j = i
   while (af[j] != i):
    current_len += 1
    j = af[j]
    used.add(j)
   total_len += current_len
   if ((current_len > (n // 2)) and (current_len < (n - 2)) and isprime(current_len)):
    return True
 return False

def _check_cycles_alt_sym ( perm ) : n = perm . size af = perm . array_form current_len = 0 total_len = 0 used = set ( ) for i in range ( ( n // 2 ) ) : if ( ( not ( i in used ) ) and ( i < ( ( n // 2 ) - total_len ) ) ) : current_len = 1 used . add ( i ) j = i while ( af [ j ] != i ) : current_len += 1 j = af [ j ] used . add ( j ) total_len += current_len if ( ( current_len > ( n // 2 ) ) and ( current_len < ( n - 2 ) ) and isprime ( current_len ) ) : return True return False
checks for cycles of prime length p with n/2 < p < n-2 .