


"""simple docstring"""







from __future__ import annotations
def  a__      (    SCREAMING_SNAKE_CASE   :   str    ,				SCREAMING_SNAKE_CASE   :   str    ):


  '''simple docstring'''







  lowerCAmelCase					:					Union[str, Any]								=							get_failure_array(SCREAMING_SNAKE_CASE    )

  # 2) Step through text searching for pattern
  lowerCAmelCase						,  lowerCAmelCase					:					List[Any]								=							0, 0  # index into text, pattern
  while i < len(SCREAMING_SNAKE_CASE    ):
    if pattern[j] == text[i]:
      if j == (len(SCREAMING_SNAKE_CASE    ) - 1):
        return True
      j += 1

    # if this is a prefix in our pattern
    # just go back far enough to continue
    elif j > 0:
      lowerCAmelCase					:					Optional[int]								=							failure[j - 1]
      continue
    i += 1
  return False
def  a__      (    SCREAMING_SNAKE_CASE   :   str    ):


  '''simple docstring'''







  lowerCAmelCase					:					List[str]								=							[0]
  lowerCAmelCase					:					Optional[Any]								=							0
  lowerCAmelCase					:					str								=							1
  while j < len(SCREAMING_SNAKE_CASE    ):
    if pattern[i] == pattern[j]:
      i += 1
    elif i > 0:
      lowerCAmelCase					:					List[Any]								=							failure[i - 1]
      continue
    j += 1
    failure.append(SCREAMING_SNAKE_CASE    )
  return failure


if __name__ == "__main__":
     # Test 1)
     lowerCAmelCase__				    =       '''abc1abc12'''
     lowerCAmelCase__				    =       '''alskfjaldsabc1abc1abc12k23adsfabcabc'''
     lowerCAmelCase__				    =       '''alskfjaldsk23adsfabcabc'''
     assert kmp(pattern, texta) and not kmp(pattern, texta)

     # Test 2)
     lowerCAmelCase__				    =       '''ABABX'''
     lowerCAmelCase__				    =       '''ABABZABABYABABX'''
     assert kmp(pattern, text)

     # Test 3)
     lowerCAmelCase__				    =       '''AAAB'''
     lowerCAmelCase__				    =       '''ABAAAAAB'''
     assert kmp(pattern, text)

     # Test 4)
     lowerCAmelCase__				    =       '''abcdabcy'''
     lowerCAmelCase__				    =       '''abcxabcdabxabcdabcdabcy'''
     assert kmp(pattern, text)

     # Test 5)
     lowerCAmelCase__				    =       '''aabaabaaa'''
     assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]









"""simple docstring"""







from __future__ import annotations

from math import pi

# Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of
# Pi and the function
lowerCAmelCase__				    =       1.0_5_4_5_7_1_8_1_7e-3_4  # unit of ℏ : J * s

lowerCAmelCase__				    =       3e8  # unit of c : m * s^-1
def  a__      (    SCREAMING_SNAKE_CASE   :   float    ,				SCREAMING_SNAKE_CASE   :   float    ,				SCREAMING_SNAKE_CASE   :   float    ):


  '''simple docstring'''







  if (force, area, distance).count(0    ) != 1:
    raise ValueError("One and only one argument must be 0"    )
  if force < 0:
    raise ValueError("Magnitude of force can not be negative"    )
  if distance < 0:
    raise ValueError("Distance can not be negative"    )
  if area < 0:
    raise ValueError("Area can not be negative"    )
  if force == 0:
    lowerCAmelCase					:					Any								=							(REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / (
        2_4_0 * (distance) ** 4
    )
    return {"force": force}
  elif area == 0:
    lowerCAmelCase					:					Any								=							(2_4_0 * force * (distance) ** 4) / (
        REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2
    )
    return {"area": area}
  elif distance == 0:
    lowerCAmelCase					:					Dict								=							(
        (REDUCED_PLANCK_CONSTANT * SPEED_OF_LIGHT * pi**2 * area) / (2_4_0 * force)
    ) ** (1 / 4)
    return {"distance": distance}
  raise ValueError("One and only one argument must be 0"    )


# Run doctest
if __name__ == "__main__":
     import doctest

     doctest.testmod()





