All problems

Min-Max Normalization

easyPythonFeature Engineering

Quillon Energy is preparing smart-meter data for a model, and the columns are hopelessly mismatched: household size runs from 1 to 6, annual consumption runs into the tens of thousands. Any method that judges columns by how far apart their numbers are will hear only the loud one. So each column is rescaled onto a common footing before the model sees it: the smallest reading in the column becomes 0, the largest becomes 1, and everything between lands in proportion to where it sat.

Task: Print each reading on the rescaled footing.

Input

The first line holds one integer n, the number of readings in the column. The second line holds the n readings separated by single spaces. Not every reading is the same, so the column always has some spread.

Output

n lines, one per reading, in the order the readings arrived. Each holds the rescaled reading rounded to 4 decimal places.

Example:

Input:
3
10 20 30

Output:
0.0000
0.5000
1.0000

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…