





'''simple docstring'''


import math






class     lowerCAmelCase__ :

       '''simple docstring'''

       def 			__snake_case      ( self					:				List[Any]       ,     a__					:				list[list[float]]       ,     a__					:				list[int]						):
              UpperCAmelCase  =						0.0
              UpperCAmelCase  =						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 			__snake_case      ( self					:				Union[str, Any]       ,     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       __snake_case		( )							->     None:

       """simple docstring"""


       UpperCAmelCase  =						[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

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

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

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






from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt







def 	_snake_case     (							lowercase__						):
				_lowerCamelCase	:     int       =       int(number**0.5						)
				return number == sq * sq







def 	_snake_case     (							lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						):
				_lowerCamelCase	:     int       =       x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
				_lowerCamelCase	:     int       =       x_den * y_den * z_den
				_lowerCamelCase	:     int       =       gcd(lowercase__				,       lowercase__						)
				top //= hcf
				bottom //= hcf
				return top, bottom







def 	_snake_case     (							lowercase__ = 35						):
				_lowerCamelCase	:     set       =       set()
				_lowerCamelCase	:     int
				_lowerCamelCase	:     Fraction       =       Fraction(0						)
				_lowerCamelCase	:     tuple[int, int]

				for x_num in range(1				,       order + 1						):
								for x_den in range(x_num + 1				,       order + 1						):
												for y_num in range(1				,       order + 1						):
																for y_den in range(y_num + 1				,       order + 1						):
																				# n=1
																				_lowerCamelCase	:     int       =       x_num * y_den + x_den * y_num
																				_lowerCamelCase	:     List[Any]       =       x_den * y_den
																				_lowerCamelCase	:     int       =       gcd(lowercase__				,       lowercase__						)
																				z_num //= hcf
																				z_den //= hcf
																				if 0 < z_num < z_den <= order:
																								_lowerCamelCase	:     Optional[Any]       =       add_three(
																								    lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						)
																								unique_s.add(lowercase__						)

																				# n=2
																				_lowerCamelCase	:     Tuple       =       (
																				    x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
																				)
																				_lowerCamelCase	:     Dict       =       x_den * x_den * y_den * y_den
																				if is_sq(lowercase__						) and is_sq(lowercase__						):
																								_lowerCamelCase	:     Dict       =       int(sqrt(lowercase__						)						)
																								_lowerCamelCase	:     Optional[Any]       =       int(sqrt(lowercase__						)						)
																								_lowerCamelCase	:     List[Any]       =       gcd(lowercase__				,       lowercase__						)
																								z_num //= hcf
																								z_den //= hcf
																								if 0 < z_num < z_den <= order:
																												_lowerCamelCase	:     Union[str, Any]       =       add_three(
																												    lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						)
																												unique_s.add(lowercase__						)

                    # n=-1
																				_lowerCamelCase	:     List[str]       =       x_num * y_num
																				_lowerCamelCase	:     int       =       x_den * y_num + x_num * y_den
																				_lowerCamelCase	:     Dict       =       gcd(lowercase__				,       lowercase__						)
																				z_num //= hcf
																				z_den //= hcf
																				if 0 < z_num < z_den <= order:
																								_lowerCamelCase	:     List[str]       =       add_three(
																								    lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						)
																								unique_s.add(lowercase__						)

																				# n=2
																				_lowerCamelCase	:     Tuple       =       x_num * x_num * y_num * y_num
																				_lowerCamelCase	:     List[str]       =       (
																				    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
																				)
																				if is_sq(lowercase__						) and is_sq(lowercase__						):
																								_lowerCamelCase	:     Optional[int]       =       int(sqrt(lowercase__						)						)
																								_lowerCamelCase	:     Optional[int]       =       int(sqrt(lowercase__						)						)
																								_lowerCamelCase	:     Dict       =       gcd(lowercase__				,       lowercase__						)
																								z_num //= hcf
																								z_den //= hcf
																								if 0 < z_num < z_den <= order:
																												_lowerCamelCase	:     int       =       add_three(
																												    lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						)
																												unique_s.add(lowercase__						)

				for num, den in unique_s:
								total += Fraction(lowercase__				,       lowercase__						)

				return total.denominator + total.numerator


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