• + 0 comments

    This question is flawed, for one of the test cases they assert that n = 5 and p = 4 should yield 0 pages flipped. But a book with 5 pages has an unused or blank page as the 6th page. If one were to start from the back of the book, having only flipped the back cover and no pages, they would be looking at the 6th page. To view the 4th page would require 1 flip, exposing pages 4 and 5. Thus n = 5 and p = 4 should yield 1?

    "Each page except the last page will always be printed on both sides. The last page may only be printed on the front, given the length of the book." - This is an example where the last page, page 5 is printed on the front, given the length of the book, n = 5.