

from __future__ import annotations

from collections.abc import Iterable, Iterator
from dataclasses import dataclass

_SCREAMING_SNAKE_CASE  :						Optional[int]         =    (3, 9, -11, 0, 7, 5, 1, -1)
_SCREAMING_SNAKE_CASE  :						Tuple         =    (4, 6, 2, 0, 8, 10, 3, -2)






@dataclass
class  UpperCAmelCase__	:






  """simple docstring"""


  a     =      42
  a     =      42






class  UpperCAmelCase__	:






  """simple docstring"""


  def __init__(							self		:	List[Any]			,     __lowerCamelCase		:	Iterable[int]      )	->							None:
       SCREAMING_SNAKE_CASE__					=					None
       for i in sorted(__lowerCamelCase			,     reverse=__lowerCamelCase      ):
            SCREAMING_SNAKE_CASE__					=					Node(__lowerCamelCase			,     self.head      )






  def __iter__(							self		:	List[Any]      )	->							Iterator[int]:
       SCREAMING_SNAKE_CASE__					=					self.head
       while node:
            yield node.data
            SCREAMING_SNAKE_CASE__					=					node.next_node






  def __len__(							self		:	int      )	->							int:
       return sum(1 for _ in self      )







  def __str__(							self		:	Any      )	->							str:
       return " -> ".join([str(__lowerCamelCase      ) for node in self]      )



def        UpperCAmelCase_     (		_A   ,	_A       ):





     '''simple docstring'''




     return SortedLinkedList(list(_A       ) + list(_A       )       )


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       _SCREAMING_SNAKE_CASE  :						str         =    SortedLinkedList
       print(merge_lists(SSL(test_data_odd), SSL(test_data_even)))





import math






class  UpperCAmelCase__	:






  """simple docstring"""


  def    lowercase_	(							self		:	int			,     __lowerCamelCase		:	list[list[float]]			,     __lowerCamelCase		:	list[int]      )	->							int:
       SCREAMING_SNAKE_CASE__					=					0.0
       SCREAMING_SNAKE_CASE__					=					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		:	Optional[int]			,     __lowerCamelCase		:	list[list[int | float]]			,     __lowerCamelCase		:	list[int]			,     __lowerCamelCase		:	int			,     __lowerCamelCase		:	float      )	->							list[list[int | float]]:
       for i in range(len(__lowerCamelCase      )      ):
            weights[j][i] += alpha * (sample[i] - weights[j][i])
       return weights



def        UpperCAmelCase_     (		):





     '''simple docstring'''




     SCREAMING_SNAKE_CASE__					=					[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

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

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

               # Compute the winning vector
               SCREAMING_SNAKE_CASE__					=					self_organizing_map.get_winner(_A   ,	_A       )

               # Update the winning vector
               SCREAMING_SNAKE_CASE__					=					self_organizing_map.update(_A   ,	_A   ,	_A   ,	_A       )

    # classify test sample
     SCREAMING_SNAKE_CASE__					=					[0, 0, 0, 1]
     SCREAMING_SNAKE_CASE__					=					self_organizing_map.get_winner(_A   ,	_A       )

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


