
import math




class 						lowercase__  :
	def      A_				(			self							:   Tuple       ,   UpperCAmelCase_							:   list[list[float]]       ,   UpperCAmelCase_							:   list[int]							):
						SCREAMING_SNAKE_CASE__													= 0.0
						SCREAMING_SNAKE_CASE__													= 0.0
						for i in range(len(UpperCAmelCase_							)							):
											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      A_				(			self							:   Any       ,   UpperCAmelCase_							:   list[list[int | float]]       ,   UpperCAmelCase_							:   list[int]       ,   UpperCAmelCase_							:   int       ,   UpperCAmelCase_							:   float							):
						for i in range(len(UpperCAmelCase_							)							):
											weights[j][i] += alpha * (sample[i] - weights[j][i])
						return weights






def 							_lowercase							(     )		->		None:
					'''simple docstring'''


					SCREAMING_SNAKE_CASE__													= [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

															# Compute the winning vector
															SCREAMING_SNAKE_CASE__													= self_organizing_map.get_winner(UpperCamelCase_	,	UpperCamelCase_		)

															# Update the winning vector
															SCREAMING_SNAKE_CASE__													= self_organizing_map.update(UpperCamelCase_	,	UpperCamelCase_	,	UpperCamelCase_	,	UpperCamelCase_		)

    # classify test sample
					SCREAMING_SNAKE_CASE__													= [0, 0, 0, 1]
					SCREAMING_SNAKE_CASE__													= 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()







import os






def 							_lowercase							(     )		->		List[str]:
					'''simple docstring'''


					with open(os.path.dirname(UpperCamelCase_		) + '/p022_names.txt'		) as file:
										SCREAMING_SNAKE_CASE__													= str(file.readlines()[0]		)
										SCREAMING_SNAKE_CASE__													= names.replace('"'	,	''		).split(','		)

					names.sort()

					SCREAMING_SNAKE_CASE__													= 0
					SCREAMING_SNAKE_CASE__													= 0

					for i, name in enumerate(UpperCamelCase_		):
										for letter in name:
															name_score += ord(UpperCamelCase_		) - 64

										total_score += (i + 1) * name_score
										SCREAMING_SNAKE_CASE__													= 0
					return total_score


if __name__ == "__main__":
				print(solution())





