


'''simple docstring'''





from __future__ import annotations

import math
def   _UpperCamelCase				(						lowerCAmelCase_   )						->Optional[Any]:

   if 1 < number < 4:
      # 2 and 3 are primes
      return True
   elif number < 2 or number % 2 == 0 or number % 3 == 0:
      # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
      return False

   # All primes number are in format of 6k +/- 1
   for i in range(5  ,						int(math.sqrt(__snake_case   ) + 1   )  ,						6   ):
      if number % i == 0 or number % (i + 2) == 0:
         return False
   return True
def   _UpperCamelCase				(						lowerCAmelCase_   )						->Dict:
   UpperCAmelCase							=     str(__snake_case   )
   UpperCAmelCase							=     [n]
   for i in range(1  ,						len(__snake_case   )   ):
      list_nums.append(int(str_num[i:]   )   )
      list_nums.append(int(str_num[:-i]   )   )
   return list_nums
def   _UpperCamelCase				(						lowerCAmelCase_   )						->int:
   if len(str(__snake_case   )   ) > 3:
      if not is_prime(int(str(__snake_case   )[-3:]   )   ) or not is_prime(int(str(__snake_case   )[:3]   )   ):
         return False
   return True
def   _UpperCamelCase				(						lowerCAmelCase_ = 1_1   )						->Optional[int]:
   UpperCAmelCase							=     []
   UpperCAmelCase							=     1_3
   while len(__snake_case   ) != count:
      if validate(__snake_case   ):
         UpperCAmelCase							=     list_truncated_nums(__snake_case   )
         if all(is_prime(__snake_case   ) for i in list_nums   ):
            list_truncated_primes.append(__snake_case   )
      num += 2
   return list_truncated_primes
def   _UpperCamelCase				(						)						->List[Any]:
   return sum(compute_truncated_primes(1_1   )   )


if __name__ == "__main__":
 print(F"""{sum(compute_truncated_primes(11)) = }""")







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



