


'''simple docstring'''







def       lowerCAmelCase__       (				lowerCamelCase     :			int  ,lowerCamelCase     :			int  ,lowerCamelCase     :			int  ,lowerCamelCase     :			int   ):
       return len_board * len_board_column * row + column






def       lowerCAmelCase__       (				lowerCamelCase     :			list[list[str]]  ,lowerCamelCase     :			str  ,lowerCamelCase     :			int  ,lowerCamelCase     :			int  ,lowerCamelCase     :			int  ,lowerCamelCase     :			set[int]  ,):

       if board[row][column] != word[word_index]:
              return False

       if word_index == len(lowerCamelCase   ) - 1:
              return True

       _A     :	Optional[int]      =					[(0, 1), (0, -1), (-1, 0), (1, 0)]
       _A     :	Dict      =					len(lowerCamelCase   )
       _A     :	int      =					len(board[0]   )
       for direction in traverts_directions:
              _A     :	Optional[int]      =					row + direction[0]
              _A     :	str      =					column + direction[1]
              if not (0 <= next_i < len_board and 0 <= next_j < len_board_column):
                     continue

              _A     :	Optional[Any]      =					get_point_key(lowerCamelCase  ,lowerCamelCase  ,lowerCamelCase  ,lowerCamelCase   )
              if key in visited_points_set:
                     continue

              visited_points_set.add(lowerCamelCase   )
              if exits_word(lowerCamelCase  ,lowerCamelCase  ,lowerCamelCase  ,lowerCamelCase  ,word_index + 1  ,lowerCamelCase   ):
                     return True

              visited_points_set.remove(lowerCamelCase   )

       return False






def       lowerCAmelCase__       (				lowerCamelCase     :			list[list[str]]  ,lowerCamelCase     :			str   ):
       _A     :	Tuple      =					(
           'The board should be a non empty matrix of single chars strings.'
       )

       _A     :	Dict      =					len(lowerCamelCase   )
       if not isinstance(lowerCamelCase  ,lowerCamelCase   ) or len(lowerCamelCase   ) == 0:
              raise ValueError(lowerCamelCase   )

       for row in board:
              if not isinstance(lowerCamelCase  ,lowerCamelCase   ) or len(lowerCamelCase   ) == 0:
                     raise ValueError(lowerCamelCase   )

              for item in row:
                     if not isinstance(lowerCamelCase  ,lowerCamelCase   ) or len(lowerCamelCase   ) != 1:
                            raise ValueError(lowerCamelCase   )

    # Validate word
       if not isinstance(lowerCamelCase  ,lowerCamelCase   ) or len(lowerCamelCase   ) == 0:
              raise ValueError(
                  'The word parameter should be a string of length greater than 0.'   )

       _A     :	Union[str, Any]      =					len(board[0]   )
       for i in range(lowerCamelCase   ):
              for j in range(lowerCamelCase   ):
                     if exits_word(
                         lowerCamelCase  ,lowerCamelCase  ,lowerCamelCase  ,lowerCamelCase  ,0  ,{get_point_key(lowerCamelCase  ,lowerCamelCase  ,lowerCamelCase  ,lowerCamelCase   )}   ):
                            return True

       return False


if __name__ == "__main__":
   import doctest

   doctest.testmod()










'''simple docstring'''







from __future__ import annotations






def       lowerCAmelCase__       (				lowerCamelCase     :			list   ):
       _A     :	Union[str, Any]      =					sorted(lowerCamelCase   )
       _A     :	Tuple      =					len(lowerCamelCase   )
       _A     :	int      =					length >> 1
       return (
           (sorted_list[mid_index] + sorted_list[mid_index - 1]) / 2
           if length % 2 == 0
           else sorted_list[mid_index]
       )






def       lowerCAmelCase__       (				):
       import doctest

       doctest.testmod()


if __name__ == "__main__":
   main()






