



'''simple docstring'''



import math





class _UpperCamelCase		:





				'''simple docstring'''





				def 				__lowerCamelCase     (							self  :  str  ,       _lowerCAmelCase  :  list[list[float]]  ,       _lowerCAmelCase  :  list[int]):







											'''simple docstring'''

											__lowercase       	=0.0
											__lowercase       	=0.0
											for i in range(len(_lowerCAmelCase)):
																		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 				__lowerCamelCase     (							self  :  List[Any]  ,       _lowerCAmelCase  :  list[list[int | float]]  ,       _lowerCAmelCase  :  list[int]  ,       _lowerCAmelCase  :  int  ,       _lowerCAmelCase  :  float):







											'''simple docstring'''

											for i in range(len(_lowerCAmelCase)):
																		weights[j][i] += alpha * (sample[i] - weights[j][i])
											return weights



def   _A       (   ):



							"""simple docstring"""



							__lowercase       	=[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

							# training
							__lowercase       	=SelfOrganizingMap()
							__lowercase       	=3
							__lowercase       	=0.5

							for _ in range(_lowerCAmelCase					):
														for j in range(len(_lowerCAmelCase					)					):
																					# training sample
																					__lowercase       	=training_samples[j]

																					# Compute the winning vector
																					__lowercase       	=self_organizing_map.get_winner(_lowerCAmelCase  ,   _lowerCAmelCase					)

																					# Update the winning vector
																					__lowercase       	=self_organizing_map.update(_lowerCAmelCase  ,   _lowerCAmelCase  ,   _lowerCAmelCase  ,   _lowerCAmelCase					)

    # classify test sample
							__lowercase       	=[0, 0, 0, 1]
							__lowercase       	=self_organizing_map.get_winner(_lowerCAmelCase  ,   _lowerCAmelCase					)

							# 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'''



def   _A       (   _lowerCAmelCase					):



							"""simple docstring"""



							if not isinstance(_lowerCAmelCase  ,   _lowerCAmelCase					):
														raise TypeError('only integers accepted as input'					)
							else:
														__lowercase       	=str(abs(_lowerCAmelCase					)					)
														__lowercase       	=[list(_lowerCAmelCase					) for char in range(len(_lowerCAmelCase					)					)]
														for index in range(len(_lowerCAmelCase					)					):
																					num_transpositions[index].pop(_lowerCAmelCase					)
														return max(
														    int(''.join(list(_lowerCAmelCase					)					)					) for transposition in num_transpositions					)


if __name__ == "__main__":
		__import__("""doctest""").testmod()



