-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodewars6.py
45 lines (30 loc) · 876 Bytes
/
codewars6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#Question
#Your task is to make two functions, max and min (maximum and minimum in PHP and Python) that take a(n)
# array/vector of integers list as input and outputs, respectively, the largest and lowest number in that array/vector.
#Examples
#maximun([4,6,2,1,9,63,-134,566]) returns 566
#minimun([-52, 56, 30, 29, -54, 0, -110]) returns -110
#maximun([5]) returns 5
#minimun([42, 54, 65, 87, 0]) returns 0
def minimum(arr):
return min(arr)
def minimal(arr):
number = arr[0]
for n in arr:
if n < number:
number = n
return number
print(minimal([-1, -2, -3, -4, -5, -10])
def maximum(arr):
return max(arr)
def max(arr):
digit = arr[0]
for n in arr:
if n > digit:
digit = n
return digit
#intriguing examples
def min(arr):
return sorted(arr)[0]
def max(arr):
return sorted(arr)[-1]