"""simple docstring"""


from string import ascii_uppercase

UpperCAmelCase__     						=  {char: i for i, char in enumerate(ascii_uppercase)}
UpperCAmelCase__     						=  dict(enumerate(ascii_uppercase))






def 			__UpperCAmelCase    (	lowercase      ,lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					len(lowercase						)
  _UpperCAmelCase         =					0
  while True:
    if x == i:
      _UpperCAmelCase         =					0
    if len(lowercase						) == len(lowercase						):
      break
    key += key[i]
    i += 1
  return key






def 			__UpperCAmelCase    (	lowercase      ,lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					""""""
  _UpperCAmelCase         =					0
  for letter in message:
    if letter == " ":
      cipher_text += " "
    else:
      _UpperCAmelCase         =					(dicta[letter] - dicta[key_new[i]]) % 26
      i += 1
      cipher_text += dicta[x]
  return cipher_text






def 			__UpperCAmelCase    (	lowercase      ,lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					""""""
  _UpperCAmelCase         =					0
  for letter in cipher_text:
    if letter == " ":
      or_txt += " "
    else:
      _UpperCAmelCase         =					(dicta[letter] + dicta[key_new[i]] + 26) % 26
      i += 1
      or_txt += dicta[x]
  return or_txt






def 			__UpperCAmelCase    (	):







  """simple docstring"""
  _UpperCAmelCase         =					"""THE GERMAN ATTACK"""
  _UpperCAmelCase         =					"""SECRET"""
  _UpperCAmelCase         =					generate_key(lowercase      ,lowercase						)
  _UpperCAmelCase         =					cipher_text(lowercase      ,lowercase						)
  print(f'''Encrypted Text = {s}'''						)
  print(f'''Original Text = {original_text(lowercase      ,lowercase						)}'''						)


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    main()

"""simple docstring"""


import math


class 				a :


    def    lowerCAmelCase_     (    self		:     Tuple      , __lowerCAmelCase		:     list[list[float]]      , __lowerCAmelCase		:     list[int]    ):
      _UpperCAmelCase         =					0.0
      _UpperCAmelCase         =					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    lowerCAmelCase_     (    self		:     Union[str, Any]      , __lowerCAmelCase		:     list[list[int | float]]      , __lowerCAmelCase		:     list[int]      , __lowerCAmelCase		:     int      , __lowerCAmelCase		:     float    ):
      for i in range(len(__lowerCAmelCase    )    ):
        weights[j][i] += alpha * (sample[i] - weights[j][i])
      return weights






def 			__UpperCAmelCase    (	):







  """simple docstring"""
  # Training Examples ( m, n )
  _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(lowercase						):
    for j in range(len(lowercase						)						):
      # training sample
      _UpperCAmelCase         =					training_samples[j]

      # Compute the winning vector
      _UpperCAmelCase         =					self_organizing_map.get_winner(lowercase      ,lowercase						)

      # Update the winning vector
      _UpperCAmelCase         =					self_organizing_map.update(lowercase      ,lowercase      ,lowercase      ,lowercase						)

    # classify test sample
  _UpperCAmelCase         =					[0, 0, 0, 1]
  _UpperCAmelCase         =					self_organizing_map.get_winner(lowercase      ,lowercase						)

  # 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()
