• + 0 comments

    Here's the solution in python:

    def pageCount(n, p):
    # Calculate turns from front and back
    front_turns = p // 2
    back_turns = (n // 2) - (p // 2)
    
    # Return the minimum of the two
    return min(front_turns, back_turns)