

import math

class    _lowercase				:

   def     UpperCamelCase					(				self	:    List[Any]			,						lowerCamelCase__	:    list[list[float]]			,						lowerCamelCase__	:    list[int]       ) ->			int:
         """simple docstring"""





         A_							       =		0.0
         A_							       =		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     UpperCamelCase					(				self	:    str			,						lowerCamelCase__	:    list[list[int | float]]			,						lowerCamelCase__	:    list[int]			,						lowerCamelCase__	:    int			,						lowerCamelCase__	:    float       ) ->			list[list[int | float]]:
         """simple docstring"""





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







def 							_lowerCamelCase   (			):
      '''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(SCREAMING_SNAKE_CASE   ):
            for j in range(len(SCREAMING_SNAKE_CASE   )   ):
                  # training sample
                  A_							       =		training_samples[j]

                  # Compute the winning vector
                  A_							       =		self_organizing_map.get_winner(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE   )

                  # Update the winning vector
                  A_							       =		self_organizing_map.update(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE   )

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








def 							_lowerCamelCase   (			SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE   ):
      '''simple docstring'''







      return int((input_a, input_a).count(0   ) != 0   )







def 							_lowerCamelCase   (			):
      '''simple docstring'''







      assert nand_gate(0		,				0   ) == 1
      assert nand_gate(0		,				1   ) == 1
      assert nand_gate(1		,				0   ) == 1
      assert nand_gate(1		,				1   ) == 0


if __name__ == "__main__":
      print(nand_gate(0, 0))
      print(nand_gate(0, 1))
      print(nand_gate(1, 0))
      print(nand_gate(1, 1))





