Mockbit/#65
ML CodingeasyNumpy~10m

The Normalizer

Problem

You are preprocessing training data for a machine learning model. Raw feature values come in wildly different ranges — some in the thousands, some negative. Before feeding data to the model, you must normalize each feature to the range [0, 1] using min-max scaling.

Given a 1D array of integers, return a new array where each value is normalized using:

normalized[i] = (x[i] - min(x)) / (max(x) - min(x))

Round each output value to 6 decimal places. Return the result as a Python list.

Examples

Example 1

Input: [-10, 0, 10, 20, 30]
Output: [0.0, 0.25, 0.5, 0.75, 1.0]

Range is 40. Each value normalized: (-10-(-10))/40=0.0, (0-(-10))/40=0.25, etc.

Example 2

Input: [-500, -250, -100]
Output: [0.0, 0.625, 1.0]

Range is 400. (-250-(-500))/400 = 250/400 = 0.625.

Example 3

Input: [1000, 500, 0, -500]
Output: [1.0, 0.666667, 0.333333, 0.0]

Reverse sorted — largest value maps to 1.0, smallest to 0.0.

Constraints
  • 2 <= len(arr) <= 1000
  • All values are integers in range [-1000, 1000]
  • max(arr) != min(arr) — not all values are equal
Reference solution

Reference solution available after you attempt the question.

Ready to solve it?

Start a session on Mockbit #65. Write your code, run it against hidden tests, and get graded with specific critique on each axis.

Related ML Coding questions
← Back homemockbit.io/q/65
PrivacyTerms© 2026 Mockbit