


from __future__ import annotations

import matplotlib.pyplot as plt  # type: ignore
import numpy

# initial triangle of Koch snowflake
_A			=						numpy.array([0, 0])
_A			=						numpy.array([0.5, 0.8_660_254])
_A			=						numpy.array([1, 0])
_A			=						[VECTOR_1, VECTOR_2, VECTOR_3, VECTOR_1]

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : list[numpy.ndarray]      ,					SCREAMING_SNAKE_CASE__      : int    ):
     __UpperCamelCase   							=initial_vectors
     for _ in range(SCREAMING_SNAKE_CASE__    ):
          __UpperCamelCase   							=iteration_step(SCREAMING_SNAKE_CASE__    )
     return vectors

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : list[numpy.ndarray]    ):
     __UpperCamelCase   							=[]
     for i, start_vector in enumerate(vectors[:-1]    ):
          __UpperCamelCase   							=vectors[i + 1]
          new_vectors.append(SCREAMING_SNAKE_CASE__    )
          __UpperCamelCase   							=end_vector - start_vector
          new_vectors.append(start_vector + difference_vector / 3    )
          new_vectors.append(
              start_vector + difference_vector / 3 + rotate(difference_vector / 3      ,					60    )    )
          new_vectors.append(start_vector + difference_vector * 2 / 3    )
     new_vectors.append(vectors[-1]    )
     return new_vectors

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : numpy.ndarray      ,					SCREAMING_SNAKE_CASE__      : float    ):
     __UpperCamelCase   							=numpy.radians(SCREAMING_SNAKE_CASE__    )
     __UpperCamelCase							,				__UpperCamelCase   							=numpy.cos(SCREAMING_SNAKE_CASE__    ), numpy.sin(SCREAMING_SNAKE_CASE__    )
     __UpperCamelCase   							=numpy.array(((c, -s), (s, c))    )
     return numpy.dot(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    )

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : list[numpy.ndarray]    ):
     __UpperCamelCase   							=plt.gca()
     axes.set_aspect('equal'    )

     # matplotlib.pyplot.plot takes a list of all x-coordinates and a list of all
     # y-coordinates as inputs, which are constructed from the vector-list using
     # zip()
     __UpperCamelCase							,				__UpperCamelCase   							=zip(*SCREAMING_SNAKE_CASE__    )
     plt.plot(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    )
     plt.show()


if __name__ == "__main__":
   import doctest

   doctest.testmod()

   _A			=						iterate(INITIAL_VECTORS, 5)
   plot(processed_vectors)









from __future__ import annotations

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int    ):
     if b == 0:
          return (1, 0)
     ((__UpperCamelCase)							,				(__UpperCamelCase))   							=extended_euclid(SCREAMING_SNAKE_CASE__      ,					a % b    )
     __UpperCamelCase   							=a // b
     return (y, x - k * y)

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int    ):
     ((__UpperCamelCase)							,				(__UpperCamelCase))   							=extended_euclid(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    )
     __UpperCamelCase   							=na * na
     __UpperCamelCase   							=ra * x * na + ra * y * na
     return (n % m + m) % m

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int    ):
     ((__UpperCamelCase)							,				(__UpperCamelCase))   							=extended_euclid(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    )
     if b < 0:
          __UpperCamelCase   							=(b % n + n) % n
     return b

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int    ):
     __UpperCamelCase							,				__UpperCamelCase   							=invert_modulo(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    ), invert_modulo(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    )
     __UpperCamelCase   							=na * na
     __UpperCamelCase   							=ra * x * na + ra * y * na
     return (n % m + m) % m


if __name__ == "__main__":
   from doctest import testmod

   testmod(name='chinese_remainder_theorem', verbose=True)
   testmod(name='chinese_remainder_theorem2', verbose=True)
   testmod(name='invert_modulo', verbose=True)
   testmod(name='extended_euclid', verbose=True)





