

from __future__ import annotations

from collections.abc import MutableSequence





class       snake_case_  :







			'''simple docstring'''

			def __init__(	self					:							Union[str, Any]				,  _UpperCamelCase					:							int				,  _UpperCamelCase					:							MutableSequence[float]				) ->None:
									if len(_UpperCamelCase				) != degree + 1:
															raise ValueError(
															    '''The number of coefficients should be equal to the degree + 1.'''				)

									snake_case_  =      list(_UpperCamelCase				)
									snake_case_  =      degree







			def __add__(	self					:							Any				,  _UpperCamelCase					:							Polynomial				) ->Polynomial:

									if self.degree > polynomial_a.degree:
															snake_case_  =      self.coefficients[:]
															for i in range(polynomial_a.degree + 1				):
																					coefficients[i] += polynomial_a.coefficients[i]
															return Polynomial(self.degree				,  _UpperCamelCase				)
									else:
															snake_case_  =      polynomial_a.coefficients[:]
															for i in range(self.degree + 1				):
																					coefficients[i] += self.coefficients[i]
															return Polynomial(polynomial_a.degree				,  _UpperCamelCase				)







			def __sub__(	self					:							Any				,  _UpperCamelCase					:							Polynomial				) ->Polynomial:
									return self + polynomial_a * Polynomial(0				,  [-1]				)







			def __neg__(	self					:							List[Any]				) ->Polynomial:
									return Polynomial(self.degree				,  [-c for c in self.coefficients]				)







			def __mul__(	self					:							List[Any]				,  _UpperCamelCase					:							Polynomial				) ->Polynomial:
									snake_case_  =      [0] * (self.degree + polynomial_a.degree + 1)
									for i in range(self.degree + 1				):
															for j in range(polynomial_a.degree + 1				):
																					coefficients[i + j] += (
																					    self.coefficients[i] * polynomial_a.coefficients[j]
																					)

									return Polynomial(self.degree + polynomial_a.degree				,  _UpperCamelCase				)







			def 							snake_case__(	self					:							Dict				,  _UpperCamelCase					:							int | float				) ->int | float:
									snake_case_  =      0
									for i in range(self.degree + 1				):
															result += self.coefficients[i] * (substitution**i)
									return result







			def __str__(	self					:							Tuple				) ->str:
									snake_case_  =      ''''''
									for i in range(self.degree				,  -1				,  -1				):
															if self.coefficients[i] == 0:
																					continue
															elif self.coefficients[i] > 0:
																					if polynomial:
																											polynomial += " + "
															else:
																					polynomial += " - "

															if i == 0:
																					polynomial += str(abs(self.coefficients[i]				)				)
															elif i == 1:
																					polynomial += str(abs(self.coefficients[i]				)				) + "x"
															else:
																					polynomial += str(abs(self.coefficients[i]				)				) + "x^" + str(_UpperCamelCase				)

									return polynomial







			def __repr__(	self					:							Union[str, Any]				) ->str:
									return self.__str__()







			def 							snake_case__(	self					:							Any				) ->Polynomial:
									snake_case_  =      [0] * self.degree
									for i in range(self.degree				):
															snake_case_  =      self.coefficients[i + 1] * (i + 1)
									return Polynomial(self.degree - 1				,  _UpperCamelCase				)







			def 							snake_case__(	self					:							List[Any]				,  _UpperCamelCase					:							int | float = 0				) ->Polynomial:
									snake_case_  =      [0] * (self.degree + 2)
									snake_case_  =      constant
									for i in range(self.degree + 1				):
															snake_case_  =      self.coefficients[i] / (i + 1)
									return Polynomial(self.degree + 1				,  _UpperCamelCase				)







			def __eq__(	self					:							str				,  _UpperCamelCase					:							object				) ->bool:
									if not isinstance(_UpperCamelCase				,  _UpperCamelCase				):
															return False

									if self.degree != polynomial_a.degree:
															return False

									for i in range(self.degree + 1				):
															if self.coefficients[i] != polynomial_a.coefficients[i]:
																					return False

									return True







			def __ne__(	self					:							str				,  _UpperCamelCase					:							object				) ->bool:
									return not self.__eq__(_UpperCamelCase				)




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()




