Fewest Page Turns

In a book, you can flip pages from the front or from the back, so the shortest direction matters. The function drawing_book receives the total number of pages n and the target page p. Return the minimum number of page turns needed to reach page p.

Примеры

Ввод
6, 2
Вывод
1
Ввод
5, 4
Вывод
0
Ввод
6, 1
Вывод
0

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

def drawing_book(n: int, p: int) -> int:

Теги

math
PostgreSQLv16
Entre para enviar

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

Visible tests
1
Input
6, 2
Expected1
2
Input
5, 4
Expected0
3
Input
6, 1
Expected0
4
Input
6, 6
Expected0
5
Input
7, 4
Expected1
6
Input
6, -6
Expected-3
Focus radio
Paused · SomaFM · Fluid