



"""simple docstring"""
import colorsys

from PIL import Image  # type: ignore


def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase ,  __lowerCAmelCase ,  __lowerCAmelCase							) ->						float:







  '''simple docstring'''


  lowercase_								= x
  lowercase_								= y
  for step in range(__lowerCAmelCase							):  # noqa: B007
    lowercase_								= a * a - b * b + x
    lowercase_								= 2 * a * b + y
    lowercase_								= a_new

    # divergence happens for all complex number with an absolute value
    # greater than 4
    if a * a + b * b > 4:
      break
  return step / (max_step - 1)


def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase							) ->						tuple:







  '''simple docstring'''


  if distance == 1:
    return (0, 0, 0)
  else:
    return (2_55, 2_55, 2_55)


def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase							) ->						tuple:







  '''simple docstring'''


  if distance == 1:
    return (0, 0, 0)
  else:
    return tuple(round(i * 2_55							) for i in colorsys.hsv_to_rgb(__lowerCAmelCase ,  1 ,  1							)							)


def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase = 8_00 ,  __lowerCAmelCase = 6_00 ,  __lowerCAmelCase = -0.6 ,  __lowerCAmelCase = 0 ,  __lowerCAmelCase = 3.2 ,  __lowerCAmelCase = 50 ,  __lowerCAmelCase = True ,  ) ->						Image.Image:







  '''simple docstring'''


  lowercase_								= Image.new("""RGB""" ,  (image_width, image_height)							)
  lowercase_								= img.load()

  # loop through the image-coordinates
  for image_x in range(__lowerCAmelCase							):
    for image_y in range(__lowerCAmelCase							):
      # determine the figure-coordinates based on the image-coordinates
      lowercase_								= figure_width / image_width * image_height
      lowercase_								= figure_center_x + (image_x / image_width - 0.5) * figure_width
      lowercase_								= figure_center_y + (image_y / image_height - 0.5) * figure_height

      lowercase_								= get_distance(__lowerCAmelCase ,  __lowerCAmelCase ,  __lowerCAmelCase							)

      # color the corresponding pixel based on the selected coloring-function
      if use_distance_color_coding:
        lowercase_								= get_color_coded_rgb(__lowerCAmelCase							)
      else:
        lowercase_								= get_black_and_white_rgb(__lowerCAmelCase							)

  return img


if __name__ == "__main__":
       import doctest

       doctest.testmod()

       # colored version, full figure
       UpperCAmelCase						:		Any			= get_image()

       # uncomment for colored version, different section, zoomed in
       # img = get_image(figure_center_x = -0.6, figure_center_y = -0.4,
       # figure_width = 0.8)

       # uncomment for black and white version, full figure
       # img = get_image(use_distance_color_coding = False)

       # uncomment to save the image
       # img.save("mandelbrot.png")

       img.show()






"""simple docstring"""
from __future__ import annotations

import math
from collections import Counter
from string import ascii_lowercase


def 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase							) ->						None:







  '''simple docstring'''


  lowercase_					,    lowercase_								= analyze_text(__lowerCAmelCase							)
  lowercase_								= list(""" """ + ascii_lowercase							)
  # what is our total sum of probabilities.
  lowercase_								= sum(single_char_strings.values()							)

  # one length string
  lowercase_								= 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:
      lowercase_								= single_char_strings[ch]
      lowercase_								= 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
  lowercase_								= sum(two_char_strings.values()							)
  lowercase_								= 0
  # for each alpha (two in size) calculate entropy.
  for cha in my_alphas:
    for cha in my_alphas:
      lowercase_								= cha + cha
      if sequence in two_char_strings:
        lowercase_								= two_char_strings[sequence]
        lowercase_								= 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 			_SCREAMING_SNAKE_CASE						(__lowerCAmelCase							) ->						tuple[dict, dict]:







  '''simple docstring'''


  lowercase_								= Counter()  # type: ignore
  lowercase_								= 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 			_SCREAMING_SNAKE_CASE						() ->						str:







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

