'''simple docstring'''




import math





class     __magic_name__						:







			def 	SCREAMING_SNAKE_CASE_     (	self				:  int				,			lowercase_				:  list[list[float]]				,			lowercase_				:  list[int]    ):
										lowercase_					:			List[Any]										=       0.0
										lowercase_					:			Tuple										=       0.0
										for i in range(len(lowercase_    )    ):
																	da += math.pow((sample[i] - weights[0][i])				,			2    )
																	da += math.pow((sample[i] - weights[1][i])				,			2    )
																	return 0 if da > da else 1
										return 0







			def 	SCREAMING_SNAKE_CASE_     (	self				:  List[str]				,			lowercase_				:  list[list[int | float]]				,			lowercase_				:  list[int]				,			lowercase_				:  int				,			lowercase_				:  float    ):
										for i in range(len(lowercase_    )    ):
																	weights[j][i] += alpha * (sample[i] - weights[j][i])
										return weights




def 							lowerCamelCase	(      )			->      None:
							# Training Examples ( m, n )
							lowercase_					:			Optional[int]										=       [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

							# weight initialization ( n, C )
							lowercase_					:			str										=       [[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

							# training
							lowercase_					:			Tuple										=       SelfOrganizingMap()
							lowercase_					:			Dict										=       3
							lowercase_					:			Tuple										=       0.5

							for _ in range(UpperCAmelCase__ ):
														for j in range(len(UpperCAmelCase__ ) ):
																					# training sample
																					lowercase_					:			Tuple										=       training_samples[j]

																					# Compute the winning vector
																					lowercase_					:			List[Any]										=       self_organizing_map.get_winner(UpperCAmelCase__      ,      UpperCAmelCase__ )

																					# Update the winning vector
																					lowercase_					:			str										=       self_organizing_map.update(UpperCAmelCase__      ,      UpperCAmelCase__      ,      UpperCAmelCase__      ,      UpperCAmelCase__ )

    # classify test sample
							lowercase_					:			Optional[Any]										=       [0, 0, 0, 1]
							lowercase_					:			Union[str, Any]										=       self_organizing_map.get_winner(UpperCAmelCase__      ,      UpperCAmelCase__ )

							# results
							print(F'''Clusters that the test sample belongs to : {winner}''' )
							print(F'''Weights that have been trained : {weights}''' )


# running the main() function
if __name__ == "__main__":
						main()






'''simple docstring'''




import os




def 							lowerCamelCase	(      UpperCAmelCase__       :					str = "input.txt" )			->      int:

							with open(os.path.join(os.path.dirname(UpperCAmelCase__ )      ,      UpperCAmelCase__ ) ) as input_file:
														lowercase_					:			str										=       [
														    [int(UpperCAmelCase__ ) for element in line.split(""",""" )]
														    for line in input_file.readlines()
														]

							lowercase_					:			Optional[Any]										=       len(UpperCAmelCase__ )
							lowercase_					:			Any										=       len(matrix[0] )

							lowercase_					:			Union[str, Any]										=       [[-1 for _ in range(UpperCAmelCase__ )] for _ in range(UpperCAmelCase__ )]
							for i in range(UpperCAmelCase__ ):
														lowercase_					:			int										=       matrix[i][0]

							for j in range(1      ,      UpperCAmelCase__ ):
														for i in range(UpperCAmelCase__ ):
																					lowercase_					:			Union[str, Any]										=       minimal_path_sums[i][j - 1] + matrix[i][j]

														for i in range(1      ,      UpperCAmelCase__ ):
																					lowercase_					:			Tuple										=       min(
																					    minimal_path_sums[i][j]      ,      minimal_path_sums[i - 1][j] + matrix[i][j] )

														for i in range(rows - 2      ,      -1      ,      -1 ):
																					lowercase_					:			Dict										=       min(
																					    minimal_path_sums[i][j]      ,      minimal_path_sums[i + 1][j] + matrix[i][j] )

							return min(minimal_path_sums_row[-1] for minimal_path_sums_row in minimal_path_sums )


if __name__ == "__main__":
						print(f"""{solution() = }""")





