We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 582441a commit fa5f11dCopy full SHA for fa5f11d
maths/abs_Max.py
@@ -1,8 +1,10 @@
1
-def absMax(x):
+from typing import List
2
+
3
+def abs_max(x: List[int]) -> int:
4
"""
- #>>>absMax([0,5,1,11])
5
+ >>> abs_max([0,5,1,11])
6
11
- >>absMax([3,-10,-2])
7
+ >>> abs_max([3,-10,-2])
8
-10
9
10
j =x[0]
@@ -11,15 +13,20 @@ def absMax(x):
13
j = i
12
14
return j
15
16
+def abs_max_sort(x):
17
+ """
18
+ >>> abs_max_sort([0,5,1,11])
19
+ 11
20
+ >>> abs_max_sort([3,-10,-2])
21
+ -10
22
23
+ return sorted(x,key=abs)[-1]
24
25
def main():
26
a = [1,2,-11]
- print(absMax(a)) # = -11
-
27
+ assert abs_max(a) == -11
28
+ assert abs_max_sort(a) == -11
29
30
if __name__ == '__main__':
31
main()
32
-"""
-print abs Max
0 commit comments