From b478cd3f282b640891bd5136ee53c5fb794096c7 Mon Sep 17 00:00:00 2001 From: gpapadok <38889721+gpapadok@users.noreply.github.com> Date: Fri, 9 Nov 2018 10:13:43 +0200 Subject: [PATCH 1/2] Update absMax.py Fixed two bugs --- Maths/absMax.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Maths/absMax.py b/Maths/absMax.py index 432734ec02c0..28ed307b6e77 100644 --- a/Maths/absMax.py +++ b/Maths/absMax.py @@ -8,7 +8,7 @@ def absMax(x): """ j = x[0] for i in x: - if absVal(i) < j: + if absVal(i) > absVal(j): j = i return j #BUG: i is apparently a list, TypeError: '<' not supported between instances of 'list' and 'int' in absVal @@ -16,7 +16,7 @@ def absMax(x): def main(): a = [1,2,-11] - print(absVal(a)) # = -11 + print(absMax(a)) # = -11 if __name__ == '__main__': main() From 55fef324fed4f17148439120732a915f7bc0b4a5 Mon Sep 17 00:00:00 2001 From: gpapadok <38889721+gpapadok@users.noreply.github.com> Date: Fri, 15 Feb 2019 13:47:11 +0200 Subject: [PATCH 2/2] changed to abs instead of absVal --- Maths/absMax.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Maths/absMax.py b/Maths/absMax.py index 28ed307b6e77..8640f843815b 100644 --- a/Maths/absMax.py +++ b/Maths/absMax.py @@ -1,4 +1,3 @@ -from abs import absVal def absMax(x): """ >>>absMax([0,5,1,11]) @@ -8,10 +7,9 @@ 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 def main():