Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3014930

Browse files
gpapadokpoyea
authored andcommitted
Update absMax.py (TheAlgorithms#602)
* Update absMax.py Fixed two bugs * changed to abs instead of absVal
1 parent 3c80364 commit 3014930

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

‎Maths/absMax.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from Maths.abs import absVal
2-
31
def absMax(x):
42
"""
53
#>>>absMax([0,5,1,11])
@@ -9,15 +7,15 @@ def absMax(x):
97
"""
108
j =x[0]
119
for i in x:
12-
if absVal(i) > absVal(j):
10+
if abs(i) > abs(j):
1311
j = i
1412
return j
15-
#BUG: i is apparently a list, TypeError: '<' not supported between instances of 'list' and 'int' in absVal
16-
#BUG fix
13+
1714

1815
def main():
19-
a = [-13, 2, -11, -12]
20-
print(absMax(a)) # = -13
16+
a = [1,2,-11]
17+
print(absMax(a)) # = -11
18+
2119

2220
if __name__ == '__main__':
2321
main()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /