



"""simple docstring"""

from __future__ import annotations

import random

from matplotlib import animation
from matplotlib import pyplot as plt

# Frame rate of the animation
A_	:						Tuple				=			20

# Time between time steps in seconds
A_	:						int				=			INTERVAL / 1000
class 						lowerCAmelCase__	:


	'''simple docstring'''







	def __init__(			self							:					Optional[Any]    ,					_SCREAMING_SNAKE_CASE							:					float    ,					_SCREAMING_SNAKE_CASE							:					float    ,					_SCREAMING_SNAKE_CASE							:					float    ,					_SCREAMING_SNAKE_CASE							:					float    ,					_SCREAMING_SNAKE_CASE							:					float = 1.0    ,					_SCREAMING_SNAKE_CASE							:					float = 1.0    ,					_SCREAMING_SNAKE_CASE							:					str = "blue"    ,					)	->  None:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE	:       Any 							=    position_x
					SCREAMING_SNAKE_CASE	:       Any 							=    position_y
					SCREAMING_SNAKE_CASE	:       List[str] 							=    velocity_x
					SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    velocity_y
					SCREAMING_SNAKE_CASE	:       List[Any] 							=    mass
					SCREAMING_SNAKE_CASE	:       Dict 							=    size
					SCREAMING_SNAKE_CASE	:       Dict 							=    color





	@property
	def  _lowerCAmelCase    (			self							:					Union[str, Any]						)	->  tuple[float, float]:





					"""simple docstring"""


					return self.position_x, self.position_y





	@property
	def  _lowerCAmelCase    (			self							:					Tuple						)	->  tuple[float, float]:





					"""simple docstring"""


					return self.velocity_x, self.velocity_y





	def  _lowerCAmelCase    (			self							:					Dict    ,					_SCREAMING_SNAKE_CASE							:					float    ,					_SCREAMING_SNAKE_CASE							:					float    ,					_SCREAMING_SNAKE_CASE							:					float						)	->  None:





					"""simple docstring"""


					self.velocity_x += force_x * delta_time
					self.velocity_y += force_y * delta_time







	def  _lowerCAmelCase    (			self							:					Dict    ,					_SCREAMING_SNAKE_CASE							:					float						)	->  None:





					"""simple docstring"""


					self.position_x += self.velocity_x * delta_time
					self.position_y += self.velocity_y * delta_time




class 						lowerCAmelCase__	:


	'''simple docstring'''







	def __init__(			self							:					Dict    ,					_SCREAMING_SNAKE_CASE							:					list[Body]    ,					_SCREAMING_SNAKE_CASE							:					float = 1.0    ,					_SCREAMING_SNAKE_CASE							:					float = 1.0    ,					_SCREAMING_SNAKE_CASE							:					float = 0.0    ,					)	->  None:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE	:       Tuple 							=    bodies
					SCREAMING_SNAKE_CASE	:       str 							=    gravitation_constant
					SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    time_factor
					SCREAMING_SNAKE_CASE	:       str 							=    softening_factor





	def __len__(			self							:					Union[str, Any]						)	->  int:





					"""simple docstring"""


					return len(self.bodies						)







	def  _lowerCAmelCase    (			self							:					int    ,					_SCREAMING_SNAKE_CASE							:					float						)	->  None:





					"""simple docstring"""


					for bodya in self.bodies:
									SCREAMING_SNAKE_CASE	:       List[str] 							=    0.0
									SCREAMING_SNAKE_CASE	:       int 							=    0.0
									for bodya in self.bodies:
													if bodya != bodya:
																	SCREAMING_SNAKE_CASE	:       Dict 							=    bodya.position_x - bodya.position_x
																	SCREAMING_SNAKE_CASE	:       Any 							=    bodya.position_y - bodya.position_y

																	# Calculation of the distance using Pythagoras's theorem
																	# Extra factor due to the softening technique
																	SCREAMING_SNAKE_CASE	:       Tuple 							=    (dif_x**2 + dif_y**2 + self.softening_factor) ** (
																	    1 / 2
																	)

																	# Newton's law of universal gravitation.
																	force_x += (
																	    self.gravitation_constant * bodya.mass * dif_x / distance**3
																	)
																	force_y += (
																	    self.gravitation_constant * bodya.mass * dif_y / distance**3
																	)

            # Update the body's velocity once all the force components have been added
									bodya.update_velocity(_SCREAMING_SNAKE_CASE    ,					_SCREAMING_SNAKE_CASE    ,					delta_time * self.time_factor						)

					# Update the positions only after all the velocities have been updated
					for body in self.bodies:
									body.update_position(delta_time * self.time_factor						)




def    __snake_case       (  __A			:	BodySystem       ,		__A			:	float       ,		__A			:	list[plt.Circle]    )    ->					None:






				'''simple docstring'''
				body_system.update_system(__A    )

				# Update the positions of the patches
				for patch, body in zip(__A       ,		body_system.bodies    ):
								SCREAMING_SNAKE_CASE	:       int 							=    (body.position_x, body.position_y)
def    __snake_case       (  __A			:	str       ,		__A			:	BodySystem       ,		__A			:	float = -1       ,		__A			:	float = 1       ,		__A			:	float = -1       ,		__A			:	float = 1       ,		)    ->					None:






				'''simple docstring'''
				SCREAMING_SNAKE_CASE	:       str 							=    plt.figure()
				fig.canvas.set_window_title(__A    )
				SCREAMING_SNAKE_CASE	:       List[str] 							=    plt.axes(
				    xlim=(x_start, x_end)       ,		ylim=(y_start, y_end)    )  # Set section to be plotted
				plt.gca().set_aspect('equal'    )  # Fix aspect ratio

				# Each body is drawn as a patch by the plt-function
				SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    [
				    plt.Circle((body.position_x, body.position_y)       ,		body.size       ,		fc=body.color    )
				    for body in body_system.bodies
				]

				for patch in patches:
								ax.add_patch(__A    )

				# Function called at each step of the animation
				def update(__A			:	int    ) -> list[plt.Circle]:
								update_step(__A       ,		__A       ,		__A    )
								return patches

				SCREAMING_SNAKE_CASE	:       str 							=    animation.FuncAnimation(  # noqa: F841
				    __A       ,		__A       ,		interval=__A       ,		blit=__A    )

				plt.show()
def    __snake_case       (  )    ->					BodySystem:






				'''simple docstring'''
				SCREAMING_SNAKE_CASE	:       Optional[int] 							=    0.9_7_0_0_4_3_6
				SCREAMING_SNAKE_CASE	:       List[str] 							=    -0.2_4_3_0_8_7_5_3
				SCREAMING_SNAKE_CASE	:       Tuple 							=    0.4_6_6_2_0_3_6_8_5
				SCREAMING_SNAKE_CASE	:       Tuple 							=    0.4_3_2_3_6_5_7_3

				SCREAMING_SNAKE_CASE	:       Optional[Any] 							=    [
				    Body(__A       ,		__A       ,		__A       ,		__A       ,		size=0.2       ,		color='red'    ),
				    Body(-position_x       ,		-position_y       ,		__A       ,		__A       ,		size=0.2       ,		color='green'    ),
				    Body(0       ,		0       ,		-2 * velocity_x       ,		-2 * velocity_y       ,		size=0.2       ,		color='blue'    ),
				]
				return BodySystem(__A       ,		time_factor=3    )
def    __snake_case       (  )    ->					BodySystem:






				'''simple docstring'''
				SCREAMING_SNAKE_CASE	:       str 							=    7.3476E22
				SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    5.972E24
				SCREAMING_SNAKE_CASE	:       Optional[int] 							=    1022
				SCREAMING_SNAKE_CASE	:       Any 							=    384399000
				SCREAMING_SNAKE_CASE	:       Dict 							=    6.674E-11

				# Calculation of the respective velocities so that total impulse is zero,
				# i.e. the two bodies together don't move
				SCREAMING_SNAKE_CASE	:       Optional[Any] 							=    earth_mass * velocity_dif / (earth_mass + moon_mass)
				SCREAMING_SNAKE_CASE	:       Dict 							=    moon_velocity - velocity_dif

				SCREAMING_SNAKE_CASE	:       Optional[Any] 							=    Body(-earth_moon_distance       ,		0       ,		0       ,		__A       ,		__A       ,		10000000       ,		'grey'    )
				SCREAMING_SNAKE_CASE	:       Optional[Any] 							=    Body(0       ,		0       ,		0       ,		__A       ,		__A       ,		50000000       ,		'blue'    )
				return BodySystem([earth, moon]       ,		__A       ,		time_factor=1000000    )
def    __snake_case       (  )    ->					BodySystem:






				'''simple docstring'''
				SCREAMING_SNAKE_CASE	:       int 							=    []
				for _ in range(10    ):
								SCREAMING_SNAKE_CASE	:       Optional[Any] 							=    random.uniform(-0.5       ,		0.5    )
								SCREAMING_SNAKE_CASE	:       int 							=    random.uniform(-0.5       ,		0.5    )

								# Bodies are created pairwise with opposite velocities so that the
								# total impulse remains zero
								bodies.append(
								    Body(
								        random.uniform(-0.5       ,		0.5    )       ,		random.uniform(-0.5       ,		0.5    )       ,		__A       ,		__A       ,		size=0.0_5       ,		)    )
								bodies.append(
								    Body(
								        random.uniform(-0.5       ,		0.5    )       ,		random.uniform(-0.5       ,		0.5    )       ,		-velocity_x       ,		-velocity_y       ,		size=0.0_5       ,		)    )
				return BodySystem(__A       ,		0.0_1       ,		10       ,		0.1    )


if __name__ == "__main__":
							plot('Figure-8 solution to the 3-body-problem', example_a(), -2, 2, -2, 2)
							plot(
							    'Moon\'s orbit around the earth',
							    example_a(),
							    -4_3000_0000,
							    4_3000_0000,
							    -4_3000_0000,
							    4_3000_0000,
							)
							plot('Random system with many bodies', example_a(), -1.5, 1.5, -1.5, 1.5)










"""simple docstring"""

def    __snake_case       (  __A			:	str       ,		__A			:	str    )    ->					int:






				'''simple docstring'''
				# The longer word should come first
				if len(__A    ) < len(__A    ):
								return levenshtein_distance(__A       ,		__A    )

				if len(__A    ) == 0:
								return len(__A    )

				SCREAMING_SNAKE_CASE	:       List[Any] 							=    list(range(len(__A    ) + 1    )    )

				for i, ca in enumerate(__A    ):
								SCREAMING_SNAKE_CASE	:       Union[str, Any] 							=    [i + 1]

								for j, ca in enumerate(__A    ):
												# Calculate insertions, deletions and substitutions
												SCREAMING_SNAKE_CASE	:       str 							=    previous_row[j + 1] + 1
												SCREAMING_SNAKE_CASE	:       List[str] 							=    current_row[j] + 1
												SCREAMING_SNAKE_CASE	:       Any 							=    previous_row[j] + (ca != ca)

												# Get the minimum to append to the current row
												current_row.append(min(__A       ,		__A       ,		__A    )    )

								# Store the previous row
								SCREAMING_SNAKE_CASE	:       Tuple 							=    current_row

				# Returns the last element (distance)
				return previous_row[-1]


if __name__ == "__main__":
							A_	:						Optional[int]				=			input('Enter the first word:\n').strip()
							A_	:						Optional[Any]				=			input('Enter the second word:\n').strip()

							A_	:						str				=			levenshtein_distance(first_word, second_word)
							print(f'''Levenshtein distance between {first_word} and {second_word} is {result}''')





