


'''simple docstring'''





def   _UpperCamelCase				(						lowerCAmelCase_  ,						lowerCAmelCase_   )						->bool:
   UpperCAmelCase							=     len(lowerCAmelCase_   ) + 1
   UpperCAmelCase							=     len(lowerCAmelCase_   ) + 1

   # dp is a 2d matrix where dp[i][j] denotes whether prefix string of
   # length i of input_string matches with prefix string of length j of
   # given pattern.
   # "dp" stands for dynamic programming.
   UpperCAmelCase							=     [[0 for i in range(lowerCAmelCase_   )] for j in range(lowerCAmelCase_   )]

   # since string of zero length match pattern of zero length
   UpperCAmelCase							=     1

   # since pattern of zero length will never match with string of non-zero length
   for i in range(1  ,						lowerCAmelCase_   ):
      UpperCAmelCase							=     0

   # since string of zero length will match with pattern where there
   # is at least one * alternatively
   for j in range(1  ,						lowerCAmelCase_   ):
      UpperCAmelCase							=     dp[0][j - 2] if pattern[j - 1] == """*""" else 0

   # now using bottom-up approach to find for all remaining lengths
   for i in range(1  ,						lowerCAmelCase_   ):
      for j in range(1  ,						lowerCAmelCase_   ):
         if input_string[i - 1] == pattern[j - 1] or pattern[j - 1] == ".":
            UpperCAmelCase							=     dp[i - 1][j - 1]

         elif pattern[j - 1] == "*":
            if dp[i][j - 2] == 1:
               UpperCAmelCase							=     1
            elif pattern[j - 2] in (input_string[i - 1], "."):
               UpperCAmelCase							=     dp[i - 1][j]
            else:
               UpperCAmelCase							=     0
         else:
            UpperCAmelCase							=     0

   return bool(dp[-1][-1]   )


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 # inputing the strings
 # input_string = input("input a string :")
 # pattern = input("input a pattern :")

 __a     =			"""aab"""
 __a     =			"""c*a*b"""

 # using function to check whether given string matches the given pattern
 if match_pattern(input_string, pattern):
  print(F"""{input_string} matches the given pattern {pattern}""")
 else:
  print(F"""{input_string} does not match with the given pattern {pattern}""")







import math






class   __lowercase				:





      def        _lowercase				(		self						:					Union[str, Any]					,       __lowerCamelCase						:					list[list[float]]					,       __lowerCamelCase						:					list[int]       )    ->   int:






         """simple docstring"""







         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        _lowercase				(		self						:					List[Any]					,       __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   _UpperCamelCase				(						)						->None:
   # 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(lowerCAmelCase_   ):
      for j in range(len(lowerCAmelCase_   )   ):
         # training sample
         UpperCAmelCase							=     training_samples[j]

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

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

    # classify test sample
   UpperCAmelCase							=     [0, 0, 0, 1]
   UpperCAmelCase							=     self_organizing_map.get_winner(lowerCAmelCase_  ,						lowerCAmelCase_   )

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



