Distance From Limit

This function helps you practice finding the distance between numbers and applying a special rule above a boundary. Write a function diff21 that takes an integer n and returns the absolute difference between n and 21. If n is greater than 21, return double that difference.

Примеры

Ввод
19
Вывод
2
Ввод
10
Вывод
11
Ввод
21
Вывод
0

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

def diff21(n: int) -> int:

Теги

math
PostgreSQLv16

Hier verschijnt het resultaat van je code

Visible tests
1
Input
19
Expected2
2
Input
10
Expected11
3
Input
21
Expected0
4
Input
22
Expected2
5
Input
25
Expected8
6
Input
2
Expected19
Focus radio
Paused · SomaFM · Fluid