Skip to content

Commit

Permalink
Update absMax.py (TheAlgorithms#602)
Browse files Browse the repository at this point in the history
* Update absMax.py

Fixed two bugs

* changed to abs instead of absVal
  • Loading branch information
gpapadok authored and poyea committed Feb 15, 2019
1 parent 3c80364 commit 3014930
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Maths/absMax.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from Maths.abs import absVal

def absMax(x):
"""
#>>>absMax([0,5,1,11])
Expand All @@ -9,15 +7,15 @@ def absMax(x):
"""
j =x[0]
for i in x:
if absVal(i) > absVal(j):
if abs(i) > abs(j):
j = i
return j
#BUG: i is apparently a list, TypeError: '<' not supported between instances of 'list' and 'int' in absVal
#BUG fix


def main():
a = [-13, 2, -11, -12]
print(absMax(a)) # = -13
a = [1,2,-11]
print(absMax(a)) # = -11


if __name__ == '__main__':
main()
Expand Down

0 comments on commit 3014930

Please sign in to comment.