






from __future__ import annotations

from collections import deque





class 					A__     :

     '''simple docstring'''






     def __init__( self      :    List[Any]   ,						_SCREAMING_SNAKE_CASE      :    list[str] ):






           """simple docstring"""




           UpperCamelCase					       =  []
           self.adlist.append(
               {'value': '', 'next_states': [], 'fail_state': 0, 'output': []} )

           for keyword in keywords:
                 self.add_keyword(_SCREAMING_SNAKE_CASE )
           self.set_fail_transitions()







     def   _SCREAMING_SNAKE_CASE     ( self      :    Any   ,						_SCREAMING_SNAKE_CASE      :    int   ,						_SCREAMING_SNAKE_CASE      :    str ):






           """simple docstring"""




           for state in self.adlist[current_state]["next_states"]:
                 if char == self.adlist[state]["value"]:
                       return state
           return None







     def   _SCREAMING_SNAKE_CASE     ( self      :    Optional[Any]   ,						_SCREAMING_SNAKE_CASE      :    str ):






           """simple docstring"""




           UpperCamelCase					       =  0
           for character in keyword:
                 UpperCamelCase					       =  self.find_next_state(_SCREAMING_SNAKE_CASE   ,						_SCREAMING_SNAKE_CASE )
                 if next_state is None:
                       self.adlist.append(
                           {
                               'value': character,
                               'next_states': [],
                               'fail_state': 0,
                               'output': [],
                           } )
                       self.adlist[current_state]["next_states"].append(len(self.adlist ) - 1 )
                       UpperCamelCase					       =  len(self.adlist ) - 1
                 else:
                       UpperCamelCase					       =  next_state
           self.adlist[current_state]["output"].append(_SCREAMING_SNAKE_CASE )







     def   _SCREAMING_SNAKE_CASE     ( self      :    Any ):






           """simple docstring"""




           UpperCamelCase					       =  deque()
           for node in self.adlist[0]["next_states"]:
                 q.append(_SCREAMING_SNAKE_CASE )
                 UpperCamelCase					       =  0
           while q:
                 UpperCamelCase					       =  q.popleft()
                 for child in self.adlist[r]["next_states"]:
                       q.append(_SCREAMING_SNAKE_CASE )
                       UpperCamelCase					       =  self.adlist[r]['fail_state']
                       while (
                           self.find_next_state(_SCREAMING_SNAKE_CASE   ,						self.adlist[child]['value'] ) is None
                           and state != 0
                       ):
                             UpperCamelCase					       =  self.adlist[state]['fail_state']
                       UpperCamelCase					       =  self.find_next_state(
                           _SCREAMING_SNAKE_CASE   ,						self.adlist[child]['value'] )
                       if self.adlist[child]["fail_state"] is None:
                             UpperCamelCase					       =  0
                       UpperCamelCase					       =  (
                           self.adlist[child]['output']
                           + self.adlist[self.adlist[child]['fail_state']]['output']
                       )







     def   _SCREAMING_SNAKE_CASE     ( self      :    Optional[int]   ,						_SCREAMING_SNAKE_CASE      :    str ):






           """simple docstring"""




           UpperCamelCase					       =  {}  # returns a dict with keywords and list of its occurrences
           UpperCamelCase					       =  0
           for i in range(len(_SCREAMING_SNAKE_CASE ) ):
                 while (
                     self.find_next_state(_SCREAMING_SNAKE_CASE   ,						string[i] ) is None
                     and current_state != 0
                 ):
                       UpperCamelCase					       =  self.adlist[current_state]['fail_state']
                 UpperCamelCase					       =  self.find_next_state(_SCREAMING_SNAKE_CASE   ,						string[i] )
                 if next_state is None:
                       UpperCamelCase					       =  0
                 else:
                       UpperCamelCase					       =  next_state
                       for key in self.adlist[current_state]["output"]:
                             if key not in result:
                                   UpperCamelCase					       =  []
                             result[key].append(i - len(_SCREAMING_SNAKE_CASE ) + 1 )
           return result


if __name__ == "__main__":
       import doctest

       doctest.testmod()











__magic_name__   :  str        =							8.314_4598
def 		lowercase__  (				_UpperCamelCase       ,							_UpperCamelCase) ->			float:
      """simple docstring"""

      if temperature < 0:
            raise Exception('Temperature cannot be less than 0 K')
      if molar_mass <= 0:
            raise Exception('Molar mass cannot be less than or equal to 0 kg/mol')
      else:
            return (3 * UNIVERSAL_GAS_CONSTANT * temperature / molar_mass) ** 0.5


if __name__ == "__main__":
       import doctest

       # run doctest
       doctest.testmod()

       # example
       __magic_name__   :  List[Any]        =							300
       __magic_name__   :  Union[str, Any]        =							28
       __magic_name__   :  str        =							rms_speed_of_molecule(temperature, molar_mass)
       print(F'Vrms of Nitrogen gas at 300 K is {vrms} m/s')



