'''simple docstring'''
from __future__ import annotations

import math
from collections import Counter
from string import ascii_lowercase







def  _UpperCamelCase (     _a	:	str			):




    """simple docstring"""



    __UpperCamelCase    ,					__UpperCamelCase	:	Dict		    =  analyze_text(UpperCamelCase__			)
    __UpperCamelCase	:	Dict		    =  list(' ' + ascii_lowercase			)
    # what is our total sum of probabilities.
    __UpperCamelCase	:	Dict		    =  sum(single_char_strings.values()			)

    # one length string
    __UpperCamelCase	:	Any		    =  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:
            __UpperCamelCase	:	Any		    =  single_char_strings[ch]
            __UpperCamelCase	:	int		    =  my_str / all_sum
            my_fir_sum += prob * math.loga(UpperCamelCase__			)  # entropy formula.

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

    # two len string
    __UpperCamelCase	:	List[str]		    =  sum(two_char_strings.values()			)
    __UpperCamelCase	:	Tuple		    =  0
    # for each alpha (two in size) calculate entropy.
    for cha in my_alphas:
        for cha in my_alphas:
            __UpperCamelCase	:	str		    =  cha + cha
            if sequence in two_char_strings:
                __UpperCamelCase	:	List[Any]		    =  two_char_strings[sequence]
                __UpperCamelCase	:	Optional[int]		    =  int(UpperCamelCase__			) / all_sum
                my_sec_sum += prob * math.loga(UpperCamelCase__			)

    # 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  _UpperCamelCase (     _a	:	str			):




    """simple docstring"""



    __UpperCamelCase	:	Union[str, Any]		    =  Counter()  # type: ignore
    __UpperCamelCase	:	Any		    =  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(UpperCamelCase__			) - 1			):
        single_char_strings[text[i]] += 1
        two_char_strings[text[i : i + 2]] += 1
    return single_char_strings, two_char_strings







def  _UpperCamelCase (     ):




    """simple docstring"""



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




'''simple docstring'''
from __future__ import annotations

import numpy as np
from numpy import floataa
from numpy.typing import NDArray







def  _UpperCamelCase (     _a	:	NDArray[floataa]				,     _a	:	NDArray[floataa]				,     _a	:	list[int]				,     _a	:	int				,     ):




    """simple docstring"""



    __UpperCamelCase    ,					__UpperCamelCase	:	Union[str, Any]		    =  coefficient_matrix.shape
    __UpperCamelCase    ,					__UpperCamelCase	:	Union[str, Any]		    =  constant_matrix.shape

    if rowsa != colsa:
        __UpperCamelCase	:	Tuple		    =  f"""Coefficient matrix dimensions must be nxn but received {rowsa}x{colsa}"""
        raise ValueError(_a			)

    if colsa != 1:
        __UpperCamelCase	:	List[Any]		    =  f"""Constant matrix must be nx1 but received {rowsa}x{colsa}"""
        raise ValueError(_a			)

    if rowsa != rowsa:
        __UpperCamelCase	:	Optional[int]		    =  (
            'Coefficient and constant matrices dimensions must be nxn and nx1 but '
            f"""received {rowsa}x{colsa} and {rowsa}x{colsa}"""
        )
        raise ValueError(_a			)

    if len(_a			) != rowsa:
        __UpperCamelCase	:	Union[str, Any]		    =  (
            'Number of initial values must be equal to number of rows in coefficient '
            f"""matrix but received {len(_a			)} and {rowsa}"""
        )
        raise ValueError(_a			)

    if iterations <= 0:
        raise ValueError('Iterations must be at least 1'			)

    __UpperCamelCase	:	NDArray[floataa]		    =  np.concatenate(
        (coefficient_matrix, constant_matrix)				,     axis=1			)

    __UpperCamelCase    ,					__UpperCamelCase	:	Union[str, Any]		    =  table.shape

    strictly_diagonally_dominant(_a			)

    # Iterates the whole matrix for given number of times
    for _ in range(_a			):
        __UpperCamelCase	:	List[Any]		    =  []
        for row in range(_a			):
            __UpperCamelCase	:	List[Any]		    =  0
            for col in range(_a			):
                if col == row:
                    __UpperCamelCase	:	Optional[int]		    =  table[row][col]
                elif col == cols - 1:
                    __UpperCamelCase	:	str		    =  table[row][col]
                else:
                    temp += (-1) * table[row][col] * init_val[col]
            __UpperCamelCase	:	Any		    =  (temp + val) / denom
            new_val.append(_a			)
        __UpperCamelCase	:	List[Any]		    =  new_val

    return [float(_a			) for i in new_val]







def  _UpperCamelCase (     _a	:	NDArray[floataa]			):




    """simple docstring"""



    __UpperCamelCase    ,					__UpperCamelCase	:	str		    =  table.shape

    __UpperCamelCase	:	str		    =  True

    for i in range(0				,     _a			):
        __UpperCamelCase	:	Optional[Any]		    =  0
        for j in range(0				,     cols - 1			):
            if i == j:
                continue
            else:
                total += table[i][j]

        if table[i][i] <= total:
            raise ValueError('Coefficient matrix is not strictly diagonally dominant'			)

    return is_diagonally_dominant


# Test Cases
if __name__ == "__main__":
  import doctest

  doctest.testmod()



