
from __future__ import annotations

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

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






def        a_		(       __lowercase   :	list[numpy.ndarray]       ,					__lowercase   :	int ) ->  list[numpy.ndarray]:
			_snake_case		=			initial_vectors
			for _ in range(__lowercase ):
						_snake_case		=			iteration_step(__lowercase )
			return vectors






def        a_		(       __lowercase   :	list[numpy.ndarray] ) ->  list[numpy.ndarray]:
			_snake_case		=			[]
			for i, start_vector in enumerate(vectors[:-1] ):
						_snake_case		=			vectors[i + 1]
						new_vectors.append(__lowercase )
						_snake_case		=			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        a_		(       __lowercase   :	numpy.ndarray       ,					__lowercase   :	float ) ->  numpy.ndarray:
			_snake_case		=			numpy.radians(__lowercase )
			_snake_case	,					_snake_case		=			numpy.cos(__lowercase ), numpy.sin(__lowercase )
			_snake_case		=			numpy.array(((c, -s), (s, c)) )
			return numpy.dot(__lowercase       ,					__lowercase )






def        a_		(       __lowercase   :	list[numpy.ndarray] ) ->  None:
			_snake_case		=			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()
			_snake_case	,					_snake_case		=			zip(*__lowercase )
			plt.plot(__lowercase       ,					__lowercase )
			plt.show()


if __name__ == "__main__":
			import doctest

			doctest.testmod()

			_lowerCamelCase       :				str       =			iterate(INITIAL_VECTORS, 5)
			plot(processed_vectors)

from __future__ import annotations

import time
from collections.abc import Sequence
from random import randint

from matplotlib import pyplot as plt






def        a_		(       __lowercase   :	Sequence[float]       ,					__lowercase   :	int       ,					__lowercase   :	int ) ->  tuple[int | None, int | None, float]:
			if not arr:
						return None, None, 0
			if low == high:
						return low, high, arr[low]

			_snake_case		=			(low + high) // 2
			_snake_case	,					_snake_case	,					_snake_case		=			max_subarray(__lowercase       ,					__lowercase       ,					__lowercase )
			_snake_case	,					_snake_case	,					_snake_case		=			max_subarray(__lowercase       ,					mid + 1       ,					__lowercase )
			_snake_case	,					_snake_case	,					_snake_case		=			max_cross_sum(__lowercase       ,					__lowercase       ,					__lowercase       ,					__lowercase )
			if left_sum >= right_sum and left_sum >= cross_sum:
						return left_low, left_high, left_sum
			elif right_sum >= left_sum and right_sum >= cross_sum:
						return right_low, right_high, right_sum
			return cross_left, cross_right, cross_sum






def        a_		(       __lowercase   :	Sequence[float]       ,					__lowercase   :	int       ,					__lowercase   :	int       ,					__lowercase   :	int ) ->  tuple[int, int, float]:
			_snake_case	,					_snake_case		=			float('-inf' ), -1
			_snake_case	,					_snake_case		=			float('-inf' ), -1

			_snake_case		=			0
			for i in range(__lowercase       ,					low - 1       ,					-1 ):
						summ += arr[i]
						if summ > left_sum:
									_snake_case		=			summ
									_snake_case		=			i

			_snake_case		=			0
			for i in range(mid + 1       ,					high + 1 ):
						summ += arr[i]
						if summ > right_sum:
									_snake_case		=			summ
									_snake_case		=			i

			return max_left, max_right, (left_sum + right_sum)






def        a_		(       __lowercase   :	int ) ->  float:
			_snake_case		=			[randint(1       ,					__lowercase ) for _ in range(__lowercase )]
			_snake_case		=			time.time()
			max_subarray(__lowercase       ,					0       ,					input_size - 1 )
			_snake_case		=			time.time()
			return end - start






def        a_		(       ) ->  None:
			_snake_case		=			[10, 100, 1_000, 10_000, 50_000, 100_000, 200_000, 300_000, 400_000, 500_000]
			_snake_case		=			[time_max_subarray(__lowercase ) for input_size in input_sizes]
			print('No of Inputs\t\tTime Taken' )
			for input_size, runtime in zip(__lowercase       ,					__lowercase ):
						print(__lowercase       ,					'\t\t'       ,					__lowercase )
			plt.plot(__lowercase       ,					__lowercase )
			plt.xlabel('Number of Inputs' )
			plt.ylabel('Time taken in seconds' )
			plt.show()


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

			testmod()