absMax.py and absMin.py bugs fixed. (#624) · SandersLin/Python@d75bec8 · GitHub
Skip to content

Commit d75bec8

Browse files
ahviplcharshildarji
authored andcommitted
absMax.py and absMin.py bugs fixed. (TheAlgorithms#624)
1 parent 6a95bf9 commit d75bec8

3 files changed

Lines changed: 21 additions & 16 deletions

File tree

Maths/abs.py

Lines changed: 2 additions & 2 deletions

Maths/absMax.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
from abs import absVal
1+
from Maths.abs import absVal
2+
23
def absMax(x):
34
"""
4-
>>>absMax([0,5,1,11])
5+
#>>>absMax([0,5,1,11])
56
11
67
>>absMax([3,-10,-2])
78
-10
89
"""
9-
j = x[0]
10+
j =x[0]
1011
for i in x:
11-
if absVal(i) < j:
12+
if absVal(i) > absVal(j):
1213
j = i
1314
return j
1415
#BUG: i is apparently a list, TypeError: '<' not supported between instances of 'list' and 'int' in absVal
15-
16+
#BUG fix
1617

1718
def main():
18-
a = [1,2,-11]
19-
print(absVal(a)) # = -11
19+
a = [-13, 2, -11, -12]
20+
print(absMax(a)) # = -13
2021

2122
if __name__ == '__main__':
2223
main()
24+
25+
"""
26+
print abs Max
27+
"""

Maths/absMin.py

Lines changed: 7 additions & 7 deletions

0 commit comments

Comments
 (0)