




from __future__ import annotations

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

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



def      __lowerCAmelCase			(					UpperCamelCase	,      UpperCamelCase      )     ->	list[numpy.ndarray]:
  lowerCAmelCase__				:  List[Any]		       =     initial_vectors
  for _ in range(UpperCamelCase      ):
    lowerCAmelCase__				:  Optional[Any]		       =     iteration_step(UpperCamelCase      )
  return vectors



def      __lowerCAmelCase			(					UpperCamelCase      )     ->	list[numpy.ndarray]:
  lowerCAmelCase__				:  Tuple		       =     []
  for i, start_vector in enumerate(vectors[:-1]      ):
    lowerCAmelCase__				:  Optional[Any]		       =     vectors[i + 1]
    new_vectors.append(UpperCamelCase      )
    lowerCAmelCase__				:  int		       =     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      __lowerCAmelCase			(					UpperCamelCase	,      UpperCamelCase      )     ->	numpy.ndarray:
  lowerCAmelCase__				:  Optional[int]		       =     numpy.radians(UpperCamelCase      )
  lowerCAmelCase__       ,			lowerCAmelCase__				:  List[str]		       =     numpy.cos(UpperCamelCase      ), numpy.sin(UpperCamelCase      )
  lowerCAmelCase__				:  int		       =     numpy.array(((c, -s), (s, c))      )
  return numpy.dot(UpperCamelCase	,      UpperCamelCase      )



def      __lowerCAmelCase			(					UpperCamelCase      )     ->	None:
  lowerCAmelCase__				:  Optional[int]		       =     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()
  lowerCAmelCase__       ,			lowerCAmelCase__				:  Optional[int]		       =     zip(*UpperCamelCase      )
  plt.plot(UpperCamelCase	,      UpperCamelCase      )
  plt.show()


if __name__ == "__main__":
     import doctest

     doctest.testmod()

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







def      __lowerCAmelCase			(					UpperCamelCase      )     ->	bool:
  if not isinstance(UpperCamelCase	,      UpperCamelCase      ):
    raise ValueError('''Input series is not valid, valid series - [2, 4, 6]'''      )
  if len(UpperCamelCase      ) == 0:
    raise ValueError('''Input list must be a non empty list'''      )
  if len(UpperCamelCase      ) == 1:
    return True
  lowerCAmelCase__				:  Tuple		       =     series[1] - series[0]
  for index in range(len(UpperCamelCase      ) - 1      ):
    if series[index + 1] - series[index] != common_diff:
      return False
  return True



def      __lowerCAmelCase			(					UpperCamelCase      )     ->	float:
  if not isinstance(UpperCamelCase	,      UpperCamelCase      ):
    raise ValueError('''Input series is not valid, valid series - [2, 4, 6]'''      )
  if len(UpperCamelCase      ) == 0:
    raise ValueError('''Input list must be a non empty list'''      )
  lowerCAmelCase__				:  int		       =     0
  for val in series:
    answer += val
  return answer / len(UpperCamelCase      )


if __name__ == "__main__":
     import doctest

     doctest.testmod()

