
import math





class 							UpperCAmelCase      :




	'''simple docstring'''





	def 				UpperCamelCase_  (       self					: Optional[Any]							,A					: list[list[float]]							,A					: list[int] ):
					__A   			= 0.0
					__A   			= 0.0
					for i in range(len(_A ) ):
									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 				UpperCamelCase_  (       self					: Dict							,A					: list[list[int | float]]							,A					: list[int]							,A					: int							,A					: float ):


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





def 						UpperCAmelCase			(	)		->	None:







				"""simple docstring"""



				__A   			= [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

												# Compute the winning vector
												__A   			= self_organizing_map.get_winner(lowerCAmelCase__		,   lowerCAmelCase__						)

												# Update the winning vector
												__A   			= self_organizing_map.update(lowerCAmelCase__		,   lowerCAmelCase__		,   lowerCAmelCase__		,   lowerCAmelCase__						)

    # classify test sample
				__A   			= [0, 0, 0, 1]
				__A   			= 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__						)    ->	int:
    UpperCAmelCase__			:		Tuple													=				0
    while num > 0:
        digit_sum += num % 10
        num //= 10
    return digit_sum





def 					a__       (					lowerCAmelCase__ = 1_00						)    ->	int:
    UpperCAmelCase__			:		Dict													=				1
    UpperCAmelCase__			:		str													=				2

    for i in range(2  ,					max_n + 1						):
        UpperCAmelCase__			:		Tuple													=				pre_numerator
        UpperCAmelCase__			:		Tuple													=				2 * i // 3 if i % 3 == 0 else 1
        UpperCAmelCase__			:		str													=				cur_numerator
        UpperCAmelCase__			:		List[str]													=				e_cont * pre_numerator + temp

    return sum_digits(lowerCAmelCase__						)


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