Short Problem Definition:
Brie’s Drawing teacher asks her class to open their books to a page number. Brie can either start turning pages from the front of the book or from the back of the book. She always turns pages one at a time. When she opens the book, page 1 is always on the right side.
Link
Complexity:
time complexity is O(1)
space complexity is O(1)
Execution:
Integral division here again. No padding required.
Solution:
1
2
3
4
5
6
7
8
9
10
11
12
13

#!/bin/python import sys def solve(n, p): last_letter = n / / 2 goal_letter = p / / 2 return min (goal_letter, last_letter  goal_letter) n = int ( raw_input ().strip()) p = int ( raw_input ().strip()) result = solve(n, p) print (result) 