





import math


class       __lowerCAmelCase					:


	'''simple docstring'''





	def    snake_case__(						self:						Optional[int],					lowerCamelCase_:						list[list[float]],					lowerCamelCase_:						list[int]			):
			lowercase__					:      Optional[Any]      =		0.0
			lowercase__					:      Any      =		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    snake_case__(						self:						Tuple,					lowerCamelCase_:						list[list[int | float]],					lowerCamelCase_:						list[int],					lowerCamelCase_:						int,					lowerCamelCase_:						float			):


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


def       SCREAMING_SNAKE_CASE__  (       )   ->							None:




		'''simple docstring'''
		# Training Examples ( m, n )
		lowercase__					:      Union[str, Any]      =		[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

		# training
		lowercase__					:      Optional[Any]      =		SelfOrganizingMap()
		lowercase__					:      Any      =		3
		lowercase__					:      Optional[Any]      =		0.5

		for _ in range(SCREAMING_SNAKE_CASE_			):
				for j in range(len(SCREAMING_SNAKE_CASE_			)			):
						# training sample
						lowercase__					:      Optional[int]      =		training_samples[j]

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

						# Update the winning vector
						lowercase__					:      Optional[int]      =		self_organizing_map.update(SCREAMING_SNAKE_CASE_   ,    SCREAMING_SNAKE_CASE_   ,    SCREAMING_SNAKE_CASE_   ,    SCREAMING_SNAKE_CASE_			)

				# classify test sample
		lowercase__					:      Tuple      =		[0, 0, 0, 1]
		lowercase__					:      Optional[Any]      =		self_organizing_map.get_winner(SCREAMING_SNAKE_CASE_   ,    SCREAMING_SNAKE_CASE_			)

		# 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 math
import sys

def   A_      (       SCREAMING_SNAKE_CASE_						)			->int:
  if number != int(SCREAMING_SNAKE_CASE_						):
    raise ValueError("""the value of input must be a natural number"""						)
  if number < 0:
    raise ValueError("""the value of input must not be a negative number"""						)
  if number == 0:
    return 1
  lowercase_     =       [-1] * (number + 1)
  lowercase_     =       0
  for i in range(1 ,	number + 1						):
    lowercase_     =       sys.maxsize
    lowercase_     =       int(math.sqrt(SCREAMING_SNAKE_CASE_						)						)
    for j in range(1 ,	root + 1						):
      lowercase_     =       1 + answers[i - (j**2)]
      lowercase_     =       min(SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)
    lowercase_     =       answer
  return answers[number]


if __name__ == "__main__":
       import doctest

       doctest.testmod()

