18 lines
571 B
Python
18 lines
571 B
Python
# HumanEval/21
|
|
# Loki Mode Multi-Agent Solution
|
|
# Attempts: 1
|
|
# Passed: True
|
|
|
|
from typing import List
|
|
|
|
|
|
def rescale_to_unit(numbers: List[float]) -> List[float]:
|
|
""" Given list of numbers (of at least two elements), apply a linear transform to that list,
|
|
such that the smallest number will become 0 and the largest will become 1
|
|
>>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
|
|
[0.0, 0.25, 0.5, 0.75, 1.0]
|
|
"""
|
|
min_val = min(numbers)
|
|
max_val = max(numbers)
|
|
range_val = max_val - min_val
|
|
return [(x - min_val) / range_val for x in numbers] |