
'''simple docstring'''


import unittest

from knapsack import knapsack as k


class 						lowercase__	(  unittest.TestCase   ):






   '''simple docstring'''







   def       UpperCAmelCase				(			self   ):

      '''simple docstring'''







      UpperCamelCase       =  0
      UpperCamelCase       =  [0]
      UpperCamelCase       =  [0]
      UpperCamelCase       =  len(lowerCamelCase__   )
      self.assertEqual(k.knapsack(lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__   ) ,   0   )

      UpperCamelCase       =  [6_0]
      UpperCamelCase       =  [1_0]
      UpperCamelCase       =  len(lowerCamelCase__   )
      self.assertEqual(k.knapsack(lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__   ) ,   0   )







   def       UpperCAmelCase				(			self   ):

      '''simple docstring'''







      UpperCamelCase       =  3
      UpperCamelCase       =  [1, 2, 3]
      UpperCamelCase       =  [3, 2, 1]
      UpperCamelCase       =  len(lowerCamelCase__   )
      self.assertEqual(k.knapsack(lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__   ) ,   5   )







   def       UpperCAmelCase				(			self   ):

      '''simple docstring'''







      UpperCamelCase       =  5_0
      UpperCamelCase       =  [6_0, 1_0_0, 1_2_0]
      UpperCamelCase       =  [1_0, 2_0, 3_0]
      UpperCamelCase       =  len(lowerCamelCase__   )
      self.assertEqual(k.knapsack(lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__ ,   lowerCamelCase__   ) ,   2_2_0   )


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







'''simple docstring'''


from __future__ import annotations



def  __snake_case     (    _UpperCAmelCase					:       list[int]):
   UpperCamelCase       =  len(_UpperCAmelCase) // 2

   # choose the middle 3 elements
   UpperCamelCase       =  lst[m - 1 : m + 2]

   # if middle element is peak
   if three[1] > three[0] and three[1] > three[2]:
      return three[1]

   # if increasing, recurse on right
   elif three[0] < three[2]:
      if len(lst[:m]) == 2:
         m -= 1
      return peak(lst[m:])

   # decreasing
   else:
      if len(lst[:m]) == 2:
         m += 1
      return peak(lst[:m])


if __name__ == "__main__":
   import doctest

   doctest.testmod()





