grokking-algorithms/chapter4/ex4.3.py

17 lines
349 B
Python
Raw Normal View History

2024-01-07 21:19:47 +00:00
import logging
import random
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
def maximum(nums, size):
if size == 1:
return nums[0]
return max(nums[size - 1], maximum(nums, size - 1))
randomlist = random.sample(range(10, 300), 5)
logger.debug(randomlist)
print(maximum(randomlist, len(randomlist)))