Trimmed Average

Sometimes an average is easier to trust after removing one unusually large value and one unusually small value. Write a function centered_average that takes a list nums with at least three numbers. Remove one maximum and one minimum value, calculate the average of the remaining numbers, and return it using integer division.

Примеры

Ввод
[1, 2, 3, 4, 100]
Вывод
3
Ввод
[1, 1, 5, 5, 10, 8, 7]
Вывод
5
Ввод
[-10, -4, -2, -4, -2, 0]
Вывод
-3

Нужно реализовать

def centered_average(nums: list[int]) -> int:

Теги

listsarraymath
PostgreSQLv16
Entre para enviar

O resultado da execução do código aparecerá aqui

Visible tests
1
Input
[1,2,3,4,100]
Expected3
2
Input
[1,1,5,5,10,8,7]
Expected5
3
Input
[-10,-4,-2,-4,-2,0]
Expected-3
4
Input
[5,3,4,6,2]
Expected4
5
Input
[1,2,3]
Expected2
6
Input
[0,0,0,0,0]
Expected0
Focus radio
Paused · SomaFM · Fluid