'''simple docstring'''




import math




class    a__				:






     def        SCREAMING_SNAKE_CASE__       (			self		:		List[str]  ,    a		:		list[list[float]]  ,    a		:		list[int]   ):





         """simple docstring"""



         __lowerCamelCase          =  0.0
         __lowerCamelCase          =  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        SCREAMING_SNAKE_CASE__       (			self		:		Union[str, Any]  ,    a		:		list[list[int | float]]  ,    a		:		list[int]  ,    a		:		int  ,    a		:		float   ):





         """simple docstring"""



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






def __lowerCAmelCase			(							)     ->   None:
    # Training Examples ( m, n )
    __lowerCamelCase          =  [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

            # Compute the winning vector
            __lowerCamelCase          =  self_organizing_map.get_winner(UpperCamelCase__    ,  UpperCamelCase__    )

            # Update the winning vector
            __lowerCamelCase          =  self_organizing_map.update(UpperCamelCase__    ,  UpperCamelCase__    ,  UpperCamelCase__    ,  UpperCamelCase__    )

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

'''simple docstring'''




__UpperCAmelCase												="ABCDEFGHIJKLMNOPQRSTUVWXYZ"






def __lowerCAmelCase			(							)     ->   None:
    __lowerCamelCase          =  input('''Enter message: '''    )
    __lowerCamelCase          =  input('''Enter key [alphanumeric]: '''    )
    __lowerCamelCase          =  input('''Encrypt/Decrypt [e/d]: '''    )

    if mode.lower().startswith('''e'''    ):
        __lowerCamelCase          =  '''encrypt'''
        __lowerCamelCase          =  encrypt_message(UpperCamelCase__    ,  UpperCamelCase__    )
    elif mode.lower().startswith('''d'''    ):
        __lowerCamelCase          =  '''decrypt'''
        __lowerCamelCase          =  decrypt_message(UpperCamelCase__    ,  UpperCamelCase__    )

    print(f"""\n{mode.title()}ed message:"""    )
    print(UpperCamelCase__    )






def __lowerCAmelCase			(							UpperCamelCase__    ,  UpperCamelCase__    )     ->   str:
    return translate_message(UpperCamelCase__    ,  UpperCamelCase__    ,  '''encrypt'''    )






def __lowerCAmelCase			(							UpperCamelCase__    ,  UpperCamelCase__    )     ->   str:
    return translate_message(UpperCamelCase__    ,  UpperCamelCase__    ,  '''decrypt'''    )






def __lowerCAmelCase			(							UpperCamelCase__    ,  UpperCamelCase__    ,  UpperCamelCase__    )     ->   str:
    __lowerCamelCase          =  []
    __lowerCamelCase          =  0
    __lowerCamelCase          =  key.upper()

    for symbol in message:
        __lowerCamelCase          =  LETTERS.find(symbol.upper()    )
        if num != -1:
            if mode == "encrypt":
                num += LETTERS.find(key[key_index]    )
            elif mode == "decrypt":
                num -= LETTERS.find(key[key_index]    )

            num %= len(UpperCamelCase__    )

            if symbol.isupper():
                translated.append(LETTERS[num]    )
            elif symbol.islower():
                translated.append(LETTERS[num].lower()    )

            key_index += 1
            if key_index == len(UpperCamelCase__    ):
                __lowerCamelCase          =  0
        else:
            translated.append(UpperCamelCase__    )
    return "".join(UpperCamelCase__    )


if __name__ == "__main__":
  main()
