mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-21 12:23:34 +08:00
refactor
This commit is contained in:
20
maths/abs_Min.py
Normal file
20
maths/abs_Min.py
Normal file
@ -0,0 +1,20 @@
|
||||
from Maths.abs import absVal
|
||||
def absMin(x):
|
||||
"""
|
||||
# >>>absMin([0,5,1,11])
|
||||
0
|
||||
# >>absMin([3,-10,-2])
|
||||
-2
|
||||
"""
|
||||
j = x[0]
|
||||
for i in x:
|
||||
if absVal(i) < absVal(j):
|
||||
j = i
|
||||
return j
|
||||
|
||||
def main():
|
||||
a = [-3,-1,2,-11]
|
||||
print(absMin(a)) # = -1
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user