



"""simple docstring"""






from __future__ import annotations

import math
import random
from collections.abc import Collection
from typing import overload






class 			__snake_case			:




  def __init__(					self	:		str		,   __lowerCAmelCase	:		Collection[float] | None = None						):






         """simple docstring"""






         if components is None:
                _lowerCamelCase		:							Tuple            =					[]
         _lowerCamelCase		:							int            =					list(__lowerCAmelCase						)




  def __len__(					self	:		Tuple						):






         """simple docstring"""






         return len(self.__components						)




  def __str__(					self	:		str						):






         """simple docstring"""






         return "(" + ",".join(map(__lowerCAmelCase		,   self.__components						)						) + ")"




  def __add__(					self	:		Dict		,   __lowerCAmelCase	:		Vector						):






         """simple docstring"""






         _lowerCamelCase		:							List[str]            =					len(self						)
         if size == len(__lowerCAmelCase						):
                _lowerCamelCase		:							Union[str, Any]            =					[self.__components[i] + other.component(__lowerCAmelCase						) for i in range(__lowerCAmelCase						)]
                return Vector(__lowerCAmelCase						)
         else:
                raise Exception('''must have the same size'''						)




  def __sub__(					self	:		List[Any]		,   __lowerCAmelCase	:		Vector						):






         """simple docstring"""






         _lowerCamelCase		:							str            =					len(self						)
         if size == len(__lowerCAmelCase						):
                _lowerCamelCase		:							Tuple            =					[self.__components[i] - other.component(__lowerCAmelCase						) for i in range(__lowerCAmelCase						)]
                return Vector(__lowerCAmelCase						)
         else:  # error case
                raise Exception('''must have the same size'''						)




  @overload
  def __mul__(					self	:		Optional[Any]		,   __lowerCAmelCase	:		float						):






         """simple docstring"""






         ...




  @overload
  def __mul__(					self	:		Union[str, Any]		,   __lowerCAmelCase	:		Vector						):






         """simple docstring"""






         ...




  def __mul__(					self	:		Optional[int]		,   __lowerCAmelCase	:		float | Vector						):






         """simple docstring"""






         if isinstance(__lowerCAmelCase		,   (float, int)						):
                _lowerCamelCase		:							Any            =					[c * other for c in self.__components]
                return Vector(__lowerCAmelCase						)
         elif isinstance(__lowerCAmelCase		,   __lowerCAmelCase						) and len(self						) == len(__lowerCAmelCase						):
                _lowerCamelCase		:							int            =					len(self						)
                _lowerCamelCase		:							int            =					[self.__components[i] * other.component(__lowerCAmelCase						) for i in range(__lowerCAmelCase						)]
                return sum(__lowerCAmelCase						)
         else:  # error case
                raise Exception('''invalid operand!'''						)




  def 		SCREAMING_SNAKE_CASE							(					self	:		Optional[Any]						):






         """simple docstring"""






         return Vector(self.__components						)




  def 		SCREAMING_SNAKE_CASE							(					self	:		List[Any]		,   __lowerCAmelCase	:		int						):






         """simple docstring"""






         if isinstance(__lowerCAmelCase		,   __lowerCAmelCase						) and -len(self.__components						) <= i < len(self.__components						):
                return self.__components[i]
         else:
                raise Exception('''index out of range'''						)




  def 		SCREAMING_SNAKE_CASE							(					self	:		str		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		float						):






         """simple docstring"""






         assert -len(self.__components						) <= pos < len(self.__components						)
         _lowerCamelCase		:							List[Any]            =					value




  def 		SCREAMING_SNAKE_CASE							(					self	:		Tuple						):






         """simple docstring"""






         if len(self.__components						) == 0:
                raise Exception('''Vector is empty'''						)
         _lowerCamelCase		:							Any            =					[c**2 for c in self.__components]
         return math.sqrt(sum(__lowerCAmelCase						)						)




  def 		SCREAMING_SNAKE_CASE							(					self	:		int		,   __lowerCAmelCase	:		Vector		,   __lowerCAmelCase	:		bool = False						):






         """simple docstring"""






         _lowerCamelCase		:							Optional[int]            =					self * other
         _lowerCamelCase		:							Tuple            =					self.euclidean_length() * other.euclidean_length()
         if deg:
                return math.degrees(math.acos(num / den						)						)
         else:
                return math.acos(num / den						)






def 			snake_case_    ( A_   :						int		):


       '''simple docstring'''





       assert isinstance(A_,							A_		)
       return Vector([0] * dimension		)






def 			snake_case_    ( A_   :						int,							A_   :						int		):


       '''simple docstring'''





       assert isinstance(A_,							A_		) and (isinstance(A_,							A_		))
       _lowerCamelCase		:							Any            =					[0] * dimension
       _lowerCamelCase		:							str            =					1
       return Vector(A_		)






def 			snake_case_    ( A_   :						float,							A_   :						Vector,							A_   :						Vector		):


       '''simple docstring'''





       assert (
           isinstance(A_,							A_		)
           and isinstance(A_,							A_		)
           and (isinstance(A_,							(int, float)		))
       )
       return x * scalar + y






def 			snake_case_    ( A_   :						int,							A_   :						int,							A_   :						int		):


       '''simple docstring'''





       random.seed(A_		)
       _lowerCamelCase		:							Tuple            =					[random.randint(A_,							A_		) for _ in range(A_		)]
       return Vector(A_		)






class 			__snake_case			:




  def __init__(					self	:		Optional[Any]		,   __lowerCAmelCase	:		list[list[float]]		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		int						):






         """simple docstring"""






         _lowerCamelCase		:							str            =					matrix
         _lowerCamelCase		:							str            =					w
         _lowerCamelCase		:							Union[str, Any]            =					h




  def __str__(					self	:		int						):






         """simple docstring"""






         _lowerCamelCase		:							Optional[Any]            =					''''''
         for i in range(self.__height						):
                ans += "|"
                for j in range(self.__width						):
                       if j < self.__width - 1:
                              ans += str(self.__matrix[i][j]						) + ","
                       else:
                              ans += str(self.__matrix[i][j]						) + "|\n"
         return ans




  def __add__(					self	:		Optional[Any]		,   __lowerCAmelCase	:		Matrix						):






         """simple docstring"""






         if self.__width == other.width() and self.__height == other.height():
                _lowerCamelCase		:							Optional[int]            =					[]
                for i in range(self.__height						):
                       _lowerCamelCase		:							Dict            =					[
                           self.__matrix[i][j] + other.component(__lowerCAmelCase		,   __lowerCAmelCase						)
                           for j in range(self.__width						)
                       ]
                       matrix.append(__lowerCAmelCase						)
                return Matrix(__lowerCAmelCase		,   self.__width		,   self.__height						)
         else:
                raise Exception('''matrix must have the same dimension!'''						)




  def __sub__(					self	:		List[Any]		,   __lowerCAmelCase	:		Matrix						):






         """simple docstring"""






         if self.__width == other.width() and self.__height == other.height():
                _lowerCamelCase		:							List[Any]            =					[]
                for i in range(self.__height						):
                       _lowerCamelCase		:							List[str]            =					[
                           self.__matrix[i][j] - other.component(__lowerCAmelCase		,   __lowerCAmelCase						)
                           for j in range(self.__width						)
                       ]
                       matrix.append(__lowerCAmelCase						)
                return Matrix(__lowerCAmelCase		,   self.__width		,   self.__height						)
         else:
                raise Exception('''matrices must have the same dimension!'''						)




  @overload
  def __mul__(					self	:		Any		,   __lowerCAmelCase	:		float						):






         """simple docstring"""






         ...




  @overload
  def __mul__(					self	:		Tuple		,   __lowerCAmelCase	:		Vector						):






         """simple docstring"""






         ...




  def __mul__(					self	:		Optional[int]		,   __lowerCAmelCase	:		float | Vector						):






         """simple docstring"""






         if isinstance(__lowerCAmelCase		,   __lowerCAmelCase						):  # matrix-vector
                if len(__lowerCAmelCase						) == self.__width:
                       _lowerCamelCase		:							Optional[Any]            =					zero_vector(self.__height						)
                       for i in range(self.__height						):
                              _lowerCamelCase		:							str            =					[
                                  self.__matrix[i][j] * other.component(__lowerCAmelCase						)
                                  for j in range(self.__width						)
                              ]
                              ans.change_component(__lowerCAmelCase		,   sum(__lowerCAmelCase						)						)
                       return ans
                else:
                       raise Exception(
                           '''vector must have the same size as the '''
                           '''number of columns of the matrix!'''						)
         elif isinstance(__lowerCAmelCase		,   (int, float)						):  # matrix-scalar
                _lowerCamelCase		:							Optional[Any]            =					[
                    [self.__matrix[i][j] * other for j in range(self.__width						)]
                    for i in range(self.__height						)
                ]
                return Matrix(__lowerCAmelCase		,   self.__width		,   self.__height						)
         return None




  def 		SCREAMING_SNAKE_CASE							(					self	:		Dict						):






         """simple docstring"""






         return self.__height




  def 		SCREAMING_SNAKE_CASE							(					self	:		List[Any]						):






         """simple docstring"""






         return self.__width




  def 		SCREAMING_SNAKE_CASE							(					self	:		Optional[Any]		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		int						):






         """simple docstring"""






         if 0 <= x < self.__height and 0 <= y < self.__width:
                return self.__matrix[x][y]
         else:
                raise Exception('''change_component: indices out of bounds'''						)




  def 		SCREAMING_SNAKE_CASE							(					self	:		List[Any]		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		float						):






         """simple docstring"""






         if 0 <= x < self.__height and 0 <= y < self.__width:
                _lowerCamelCase		:							Tuple            =					value
         else:
                raise Exception('''change_component: indices out of bounds'''						)




  def 		SCREAMING_SNAKE_CASE							(					self	:		Optional[int]		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		int						):






         """simple docstring"""






         if self.__height != self.__width:
                raise Exception('''Matrix is not square'''						)
         _lowerCamelCase		:							List[Any]            =					self.__matrix[:x] + self.__matrix[x + 1 :]
         for i in range(len(__lowerCAmelCase						)						):
                _lowerCamelCase		:							int            =					minor[i][:y] + minor[i][y + 1 :]
         return Matrix(__lowerCAmelCase		,   self.__width - 1		,   self.__height - 1						).determinant()




  def 		SCREAMING_SNAKE_CASE							(					self	:		Dict		,   __lowerCAmelCase	:		int		,   __lowerCAmelCase	:		int						):






         """simple docstring"""






         if self.__height != self.__width:
                raise Exception('''Matrix is not square'''						)
         if 0 <= x < self.__height and 0 <= y < self.__width:
                return (-1) ** (x + y) * self.minor(__lowerCAmelCase		,   __lowerCAmelCase						)
         else:
                raise Exception('''Indices out of bounds'''						)




  def 		SCREAMING_SNAKE_CASE							(					self	:		Dict						):






         """simple docstring"""






         if self.__height != self.__width:
                raise Exception('''Matrix is not square'''						)
         if self.__height < 1:
                raise Exception('''Matrix has no element'''						)
         elif self.__height == 1:
                return self.__matrix[0][0]
         elif self.__height == 2:
                return (
                    self.__matrix[0][0] * self.__matrix[1][1]
                    - self.__matrix[0][1] * self.__matrix[1][0]
                )
         else:
                _lowerCamelCase		:							Optional[Any]            =					[
                    self.__matrix[0][y] * self.cofactor(0		,   __lowerCAmelCase						) for y in range(self.__width						)
                ]
                return sum(__lowerCAmelCase						)






def 			snake_case_    ( A_   :						int		):


       '''simple docstring'''





       _lowerCamelCase		:							list[list[float]]            =					[[0] * n for _ in range(A_		)]
       return Matrix(A_,							A_,							A_		)







def 			snake_case_    ( A_   :						int,							A_   :						int,							A_   :						int,							A_   :						int		):


       '''simple docstring'''





       random.seed(A_		)
       _lowerCamelCase		:							list[list[float]]            =					[
           [random.randint(A_,							A_		) for _ in range(A_		)] for _ in range(A_		)
       ]
       return Matrix(A_,							A_,							A_		)







from __future__ import annotations

import math
from collections import Counter
from string import ascii_lowercase






def        __lowerCAmelCase		(	__lowerCamelCase						:     str						)	->    None:
					__lowerCAmelCase ,						__lowerCAmelCase						 =analyze_text(__lowerCamelCase						)
					__lowerCAmelCase						 =list(""" """ + ascii_lowercase						)
					# what is our total sum of probabilities.
					__lowerCAmelCase						 =sum(single_char_strings.values()						)

					# one length string
					__lowerCAmelCase						 =0
					# for each alpha we go in our dict and if it is in it we calculate entropy
					for ch in my_alphas:
										if ch in single_char_strings:
															__lowerCAmelCase						 =single_char_strings[ch]
															__lowerCAmelCase						 =my_str / all_sum
															my_fir_sum += prob * math.loga(__lowerCamelCase						)  # entropy formula.

    # print entropy
					print(f"""{round(-1 * my_fir_sum						):.1f}"""						)

					# two len string
					__lowerCAmelCase						 =sum(two_char_strings.values()						)
					__lowerCAmelCase						 =0
					# for each alpha (two in size) calculate entropy.
					for cha in my_alphas:
										for cha in my_alphas:
															__lowerCAmelCase						 =cha + cha
															if sequence in two_char_strings:
																				__lowerCAmelCase						 =two_char_strings[sequence]
																				__lowerCAmelCase						 =int(__lowerCamelCase						) / all_sum
																				my_sec_sum += prob * math.loga(__lowerCamelCase						)

    # print second entropy
					print(f"""{round(-1 * my_sec_sum						):.1f}"""						)

					# print the difference between them
					print(f"""{round((-1 * my_sec_sum) - (-1 * my_fir_sum)						):.1f}"""						)






def        __lowerCAmelCase		(	__lowerCamelCase						:     str						)	->    tuple[dict, dict]:
					__lowerCAmelCase						 =Counter()  # type: ignore
					__lowerCAmelCase						 =Counter()  # type: ignore
					single_char_strings[text[-1]] += 1

					# first case when we have space at start.
					two_char_strings[" " + text[0]] += 1
					for i in range(0					, len(__lowerCamelCase						) - 1						):
										single_char_strings[text[i]] += 1
										two_char_strings[text[i : i + 2]] += 1
					return single_char_strings, two_char_strings






def        __lowerCAmelCase		(	)	->    str:
					import doctest

					doctest.testmod()
					# text = (
					#     "Had repulsive dashwoods suspicion sincerity but advantage now him. Remark "
					#     "easily garret nor nay. Civil those mrs enjoy shy fat merry. You greatest "
					#     "jointure saw horrible. He private he on be imagine suppose. Fertile "
					#     "beloved evident through no service elderly is. Blind there if every no so "
					#     "at. Own neglected you preferred way sincerity delivered his attempted. To "
					#     "of message cottage windows do besides against uncivil.  Delightful "
					#     "unreserved impossible few estimating men favourable see entreaties. She "
					#     "propriety immediate was improving. He or entrance humoured likewise "
					#     "moderate. Much nor game son say feel. Fat make met can must form into "
					#     "gate. Me we offending prevailed discovery. "
					# )

					# calculate_prob(text)


if __name__ == "__main__":
				main()




