"""simple docstring"""


import math






def 			__UpperCAmelCase    (	lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					0
  _UpperCAmelCase         =					0
  while num > 0:
    _UpperCAmelCase         =					num % 8
    _UpperCAmelCase         =					octal + (remainder * math.floor(math.pow(10      ,lowercase						)						))
    counter += 1
    _UpperCAmelCase         =					math.floor(num / 8						)  # basically /= 8 without remainder if any
    # This formatting removes trailing '.0' from `octal`.
  return f'''0o{int(lowercase						)}'''






def 			__UpperCAmelCase    (	):







  """simple docstring"""
  print("""\n2 in octal is:"""						)
  print(decimal_to_octal(2						)						)  # = 2
  print("""\n8 in octal is:"""						)
  print(decimal_to_octal(8						)						)  # = 10
  print("""\n65 in octal is:"""						)
  print(decimal_to_octal(65						)						)  # = 101
  print("""\n216 in octal is:"""						)
  print(decimal_to_octal(2_16						)						)  # = 330
  print("""\n512 in octal is:"""						)
  print(decimal_to_octal(5_12						)						)  # = 1000
  print("""\n"""						)


if __name__ == "__main__":
    main()

"""simple docstring"""


from __future__ import annotations






def 			__UpperCAmelCase    (	lowercase      ,lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					get_failure_array(lowercase						)

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

    # if this is a prefix in our pattern
    # just go back far enough to continue
    elif j > 0:
      _UpperCAmelCase         =					failure[j - 1]
      continue
    i += 1
  return False






def 			__UpperCAmelCase    (	lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					[0]
  _UpperCAmelCase         =					0
  _UpperCAmelCase         =					1
  while j < len(lowercase						):
    if pattern[i] == pattern[j]:
      i += 1
    elif i > 0:
      _UpperCAmelCase         =					failure[i - 1]
      continue
    j += 1
    failure.append(lowercase						)
  return failure


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

    # Test 2)
    UpperCAmelCase__     						=  """ABABX"""
    UpperCAmelCase__     						=  """ABABZABABYABABX"""
    assert kmp(pattern, text)

    # Test 3)
    UpperCAmelCase__     						=  """AAAB"""
    UpperCAmelCase__     						=  """ABAAAAAB"""
    assert kmp(pattern, text)

    # Test 4)
    UpperCAmelCase__     						=  """abcdabcy"""
    UpperCAmelCase__     						=  """abcxabcdabxabcdabcdabcy"""
    assert kmp(pattern, text)

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