Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## How many pages have I torn out?
- Last month I borrowed a plenty of books from the library. They all were good books, packed with emotions and plot-twists. Unfortunately, at some points I got very angry/sad/disappointed, so I tore some pages out.
- Now the library wants to know how many pages I have torn out for each book.
- Your goal is to write a program, which takes a sorted, comma-delimited list of numbers as input and prints the minimum and maximum possible page count I could have torn out. Each line represents a book, each number represents a missing page from the book.
- Example input:
- ```
- 7,8,100,101,222,223
- 2,3,88,89,90,103,177
- 2,3,6,7,10,11
- 1
- 1,2
- ```
- Example output:
- 4/5
- 5/6
- 3/6
- 1/1
- 1/2
- Your function should accept multiple books
- ```
- yourSolutionFunction([[7,8,100,101,222,223], [1,2]]) // [ [4,5], [1,2] ]
- ```
- `4/5` means, that I may have torn out either 4 or 5 pages, depending on which side the book's page numbering starts. One could have torn out page 6/7, page 8/9, page 100/101, and page 222/223 (4 pages). Alternatively, one could have torn out page 7/8, page 99/100, page 101/102, page 221/222, and page 223/224 (5 pages).
- Remember that a book page always has a front and a back side. Also the page numbering differs from book to book. Some books have even page numbers on the left page; some on the right page. All books are read from left to right.
- Shortest code in bytes win. Strict I/O format is **not** required. Your programs must be able to take one or more books as input. Have fun.
Add Comment
Please, Sign In to add comment