'''simple docstring'''


import math





class       _a    :


  """simple docstring"""

  def 		lowerCamelCase__  (		self      :       Optional[int]   ,				lowercase_      :       list[list[float]]   ,				lowercase_      :       list[int]      ):







    '''simple docstring'''


    lowercase_     =       0.0
    lowercase_     =       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 		lowerCamelCase__  (		self      :       Tuple   ,				lowercase_      :       list[list[int | float]]   ,				lowercase_      :       list[int]   ,				lowercase_      :       int   ,				lowercase_      :       float      ):







    '''simple docstring'''


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






def   A_      (       )			->None:
  # Training Examples ( m, n )
  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(SCREAMING_SNAKE_CASE_						):
    for j in range(len(SCREAMING_SNAKE_CASE_						)						):
      # training sample
      lowercase_     =       training_samples[j]

      # Compute the winning vector
      lowercase_     =       self_organizing_map.get_winner(SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)

      # Update the winning vector
      lowercase_     =       self_organizing_map.update(SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_ ,	SCREAMING_SNAKE_CASE_						)

    # classify test sample
  lowercase_     =       [0, 0, 0, 1]
  lowercase_     =       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'''


def   A_      (       SCREAMING_SNAKE_CASE_						)			->bool:
  if num < 0:
    return False

  lowercase_     =       num
  lowercase_     =       0
  while num > 0:
    lowercase_     =       rev_num * 10 + (num % 10)
    num //= 10

  return num_copy == rev_num


if __name__ == "__main__":
       import doctest

       doctest.testmod()

