All problems
Min-Max Scaling
Problem
Scale values to the [0, 1] range: (x_i - min) / (max - min).
If all values are equal (max == min), return a list of zeros. Empty input returns [].
Hint
Subtract the minimum, then divide by the range.
Test cases
case 1
in: [[1,2,3,4,5]]
expected: [0,0.25,0.5,0.75,1]
case 2
in: [[5,5,5]]
expected: [0,0,0]
case 3
in: [[-1,0,1]]
expected: [0,0.5,1]
case 4
in: [[10,0,5]]
expected: [1,0,0.5]
Starter codePython
def min_max_scale(values):
# Your code here
pass4 test cases · run your code against them in the editor