Nov-17-2019, 09:31 PM
Title is quite confusing let me explain:
If I have an 2D array of values 'y':
and a singular array 'x':
I want to be able to run function
If I ran
but instead with arrays.
How can I do this?
If I have an 2D array of values 'y':
[[10,20,10],[30,20,10],[10,10,10],[45,37,34]]
and a singular array 'x':
[25,18,9]
I want to be able to run function
findClosestArray(x, y)
which will return Output:[30,20,10]
because that is the closest array to the one I provided.If I ran
findClosestArray(x, y)
with 'x' NOW being [43,37,30]
it would return Output:[45,37,34]
It's very similar to this:myList = [6,6,10,50,24,457,24] myNumber= 9 a = min(myList, key=lambda x:abs(x-myNumber)) print(a)(which would return 10)
but instead with arrays.
How can I do this?