


'''simple docstring'''





from __future__ import annotations

from collections import Counter
from random import random






class   __lowercase				:





      def __init__(		self						:					Dict       )    ->   str:






         """simple docstring"""







         UpperCAmelCase							=     {}





      def        _lowercase				(		self						:					Tuple					,       __lowerCamelCase						:					str       )    ->   None:






         """simple docstring"""







         UpperCAmelCase							=     {}





      def        _lowercase				(		self						:					int					,       __lowerCamelCase						:					str					,       __lowerCamelCase						:					str					,       __lowerCamelCase						:					float       )    ->   None:






         """simple docstring"""







         if nodea not in self.connections:
            self.add_node(__lowerCamelCase       )
         if nodea not in self.connections:
            self.add_node(__lowerCamelCase       )
         UpperCAmelCase							=     probability





      def        _lowercase				(		self						:					str       )    ->   list[str]:






         """simple docstring"""







         return list(self.connections       )





      def        _lowercase				(		self						:					Optional[Any]					,       __lowerCamelCase						:					str       )    ->   str:






         """simple docstring"""







         UpperCAmelCase							=     0
         UpperCAmelCase							=     random()

         for dest in self.connections[node]:
            current_probability += self.connections[node][dest]
            if current_probability > random_value:
               return dest
         return ""

def   _UpperCamelCase				(						lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_   )						->dict[str, int]:
   UpperCAmelCase							=     MarkovChainGraphUndirectedUnweighted()

   for nodea, nodea, probability in transitions:
      graph.add_transition_probability(lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_   )

   UpperCAmelCase							=     Counter(graph.get_nodes()   )
   UpperCAmelCase							=     start

   for _ in range(lowerCAmelCase_   ):
      UpperCAmelCase							=     graph.transition(lowerCAmelCase_   )
      visited[node] += 1

   return visited


if __name__ == "__main__":
 import doctest

 doctest.testmod()







def   _UpperCamelCase				(						lowerCAmelCase_  ,						lowerCAmelCase_   )						->int:
   return int((input_a, input_a).count(0   ) == 0   )
def   _UpperCamelCase				(						)						->None:
   assert and_gate(0  ,						0   ) == 0
   assert and_gate(0  ,						1   ) == 0
   assert and_gate(1  ,						0   ) == 0
   assert and_gate(1  ,						1   ) == 1


if __name__ == "__main__":
 test_and_gate()
 print(and_gate(1, 0))
 print(and_gate(0, 0))
 print(and_gate(0, 1))
 print(and_gate(1, 1))



