


import sys
import turtle


def 		lowercase_	(  _UpperCamelCase							,      _UpperCamelCase	):


			'''simple docstring'''







			return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2


def 		lowercase_	(  _UpperCamelCase							,      _UpperCamelCase							,      _UpperCamelCase							,      _UpperCamelCase							,      ):


			'''simple docstring'''







			my_pen.up()
			my_pen.goto(vertexa[0]							,      vertexa[1]	)
			my_pen.down()
			my_pen.goto(vertexa[0]							,      vertexa[1]	)
			my_pen.goto(vertexa[0]							,      vertexa[1]	)
			my_pen.goto(vertexa[0]							,      vertexa[1]	)

			if depth == 0:
						return

			triangle(_UpperCamelCase							,      get_mid(_UpperCamelCase							,      _UpperCamelCase	)							,      get_mid(_UpperCamelCase							,      _UpperCamelCase	)							,      depth - 1	)
			triangle(_UpperCamelCase							,      get_mid(_UpperCamelCase							,      _UpperCamelCase	)							,      get_mid(_UpperCamelCase							,      _UpperCamelCase	)							,      depth - 1	)
			triangle(_UpperCamelCase							,      get_mid(_UpperCamelCase							,      _UpperCamelCase	)							,      get_mid(_UpperCamelCase							,      _UpperCamelCase	)							,      depth - 1	)


if __name__ == "__main__":
	if len(sys.argv) != 2:
		raise ValueError(
		    '''Correct format for using this script: '''
		    '''python fractals.py <int:depth_for_fractal>'''
		)
	a			:			Any												=					turtle.Turtle()
	my_pen.ht()
	my_pen.speed(5)
	my_pen.pencolor('''red''')

	a			:			List[str]												=					[(-175, -125), (0, 175), (175, -125)]  # vertices of triangle
	triangle(vertices[0], vertices[1], vertices[2], int(sys.argv[1]))






from __future__ import annotations
class 						lowerCamelCase_							:



					'''simple docstring'''







					def __init__(					self			,							snake_case_    ) ->      None:







								'''simple docstring'''

								__lowercase			       = order

								# a_{0} ... a_{k}
								__lowercase			       = [1.0] + [0.0] * order
								# b_{0} ... b_{k}
								__lowercase			       = [1.0] + [0.0] * order

								# x[n-1] ... x[n-k]
								__lowercase			       = [0.0] * self.order
								# y[n-1] ... y[n-k]
								__lowercase			       = [0.0] * self.order






					def A   (					self			,							snake_case_			,							snake_case_    ) ->      None:







								'''simple docstring'''

								if len(snake_case_    ) < self.order:
											__lowercase			       = [1.0, *a_coeffs]

								if len(snake_case_    ) != self.order + 1:
											__lowercase			       = (
											    F'Expected a_coeffs to have {self.order + 1} elements '
											    F'for {self.order}-order filter, got {len(snake_case_    )}'
											)
											raise ValueError(snake_case_    )

								if len(snake_case_    ) != self.order + 1:
											__lowercase			       = (
											    F'Expected b_coeffs to have {self.order + 1} elements '
											    F'for {self.order}-order filter, got {len(snake_case_    )}'
											)
											raise ValueError(snake_case_    )

								__lowercase			       = a_coeffs
								__lowercase			       = b_coeffs






					def A   (					self			,							snake_case_    ) ->      float:







								'''simple docstring'''

								__lowercase			       = 0.0

								# Start at index 1 and do index 0 at the end.
								for i in range(1			,							self.order + 1    ):
											result += (
											    self.b_coeffs[i] * self.input_history[i - 1]
											    - self.a_coeffs[i] * self.output_history[i - 1]
											)

								__lowercase			       = (result + self.b_coeffs[0] * sample) / self.a_coeffs[0]

								__lowercase			       = self.input_history[:-1]
								__lowercase			       = self.output_history[:-1]

								__lowercase			       = sample
								__lowercase			       = result

								return result


