import math
import unittest






def 					snake_case    (			snake_case__     :Optional[int])		->  bool:
       assert isinstance(a__  ,      a__) and (
           number >= 0
       ), "'number' must been an int and positive"

       if 1 < number < 4:
              # 2 and 3 are primes
              return True
       elif number < 2 or number % 2 == 0 or number % 3 == 0:
              # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
              return False

       # All primes number are in format of 6k +/- 1
       for i in range(5  ,      int(math.sqrt(a__) + 1)  ,      6):
              if number % i == 0 or number % (i + 2) == 0:
                     return False
       return True



class 							a				(     unittest.TestCase			):







 """simple docstring"""






 def 	UpperCAmelCase				(   self				)    ->   Tuple:
        self.assertTrue(is_prime(2				)				)
        self.assertTrue(is_prime(3				)				)
        self.assertTrue(is_prime(5				)				)
        self.assertTrue(is_prime(7				)				)
        self.assertTrue(is_prime(11				)				)
        self.assertTrue(is_prime(13				)				)
        self.assertTrue(is_prime(17				)				)
        self.assertTrue(is_prime(19				)				)
        self.assertTrue(is_prime(23				)				)
        self.assertTrue(is_prime(29				)				)



 def 	UpperCAmelCase				(   self				)    ->   Optional[int]:







        with self.assertRaises(lowercase_				):
               is_prime(-19				)
        self.assertFalse(
            is_prime(0				)						,							"""Zero doesn't have any positive factors, primes must have exactly two."""						,							)
        self.assertFalse(
            is_prime(1				)						,							"""One only has 1 positive factor, primes must have exactly two."""						,							)
        self.assertFalse(is_prime(2 * 2				)				)
        self.assertFalse(is_prime(2 * 3				)				)
        self.assertFalse(is_prime(3 * 3				)				)
        self.assertFalse(is_prime(3 * 5				)				)
        self.assertFalse(is_prime(3 * 5 * 7				)				)


if __name__ == "__main__":
    unittest.main()





from __future__ import annotations


def 				lowerCAmelCase__       (			a__    ,     a__ )      ->bool:




  '''simple docstring'''

  _UpperCamelCase           =    get_failure_array(a__ )

  # 2) Step through text searching for pattern
  _UpperCamelCase      ,						_UpperCamelCase           =    0, 0  # index into text, pattern
  while i < len(a__ ):
    if pattern[j] == text[i]:
      if j == (len(a__ ) - 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 				lowerCAmelCase__       (			a__ )      ->list[int]:




  '''simple docstring'''

  _UpperCamelCase           =    [0]
  _UpperCamelCase           =    0
  _UpperCamelCase           =    1
  while j < len(a__ ):
    if pattern[i] == pattern[j]:
      i += 1
    elif i > 0:
      _UpperCamelCase           =    failure[i - 1]
      continue
    j += 1
    failure.append(a__ )
  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]




