def bifid_square(key):
 A = ''.join(uniq(''.join(key)))
 n = (len(A) ** 0.5)
 if (n != int(n)):
  raise ValueError(('Length of alphabet (%s) is not a square number.' % len(A)))
 n = int(n)
 f = (lambda i, j: Symbol(A[((n * i) + j)]))
 rv = Matrix(n, n, f)
 return rv

def bifid_square ( key ) : A = '' . join ( uniq ( '' . join ( key ) ) ) n = ( len ( A ) ** 0.5 ) if ( n != int ( n ) ) : raise ValueError ( ( 'Length of alphabet (%s) is not a square number.' % len ( A ) ) ) n = int ( n ) f = ( lambda i , j : Symbol ( A [ ( ( n * i ) + j ) ] ) ) rv = Matrix ( n , n , f ) return rv
return characters of key arranged in a square .