I have a list of positive integers and I want to repeatedly subtract the smallest element from all elements, but only if the element isn't an instance of the minimum. For example, in one iteration
a = np.array([3, 5, 9, 3, 3]) becomes [3, 2, 6, 3, 3] and ultimately [1,1,1,1,1].
That is, no entry is ever reduced to 0. I'm suspicious there may exist an easy way to modify a - min(a) such that a[0], a[3], and a[4] don't become 0, but I don't know.
I know this can be accomplished with a list comprehension:
while len(set(arr)) > 1:
arr = [a - min(arr) if a > min(arr) else a for a in arr]
The arrays may be very large though, so with time efficiency in mind I'm hoping NumPy has a convenient way of doing this. I'm quite new to Python, so correction/information in all capacities is appreciated.