



'''simple docstring'''




from __future__ import annotations

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

# initial triangle of Koch snowflake
UpperCamelCase__       :	List[Any]    = numpy.array([0, 0])
UpperCamelCase__       :	List[Any]    = numpy.array([0.5, 0.8_6_6_0_2_5_4])
UpperCamelCase__       :	List[Any]    = numpy.array([1, 0])
UpperCamelCase__       :	Tuple    = [VECTOR_1, VECTOR_2, VECTOR_3, VECTOR_1]


def 				lowerCAmelCase_   (	_lowerCamelCase:   list[numpy.ndarray]       ,      _lowerCamelCase:   int					):
		__SCREAMING_SNAKE_CASE       :		Dict           =		initial_vectors
		for _ in range(_lowerCamelCase					):
				__SCREAMING_SNAKE_CASE       :		int           =		iteration_step(_lowerCamelCase					)
		return vectors


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


def 				lowerCAmelCase_   (	_lowerCamelCase:   list[numpy.ndarray]					):
		__SCREAMING_SNAKE_CASE       :		Optional[Any]           =		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()
		__SCREAMING_SNAKE_CASE       ,						__SCREAMING_SNAKE_CASE       :		Tuple           =		zip(*_lowerCamelCase					)
		plt.plot(_lowerCamelCase       ,      _lowerCamelCase					)
		plt.show()


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						UpperCamelCase__       :	Optional[Any]    = iterate(INITIAL_VECTORS, 5)
						plot(processed_vectors)




'''simple docstring'''




def 				lowerCAmelCase_   (	_lowerCamelCase:   float       ,      _lowerCamelCase:   list[float]					):
		if discount_rate < 0:
				raise ValueError("""Discount rate cannot be negative"""					)
		if not cash_flows:
				raise ValueError("""Cash flows list cannot be empty"""					)
		__SCREAMING_SNAKE_CASE       :		List[str]           =		sum(
		    cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(_lowerCamelCase					)					)
		return round(_lowerCamelCase       ,      ndigits=2					)


if __name__ == "__main__":
						import doctest

						doctest.testmod()