{"id":15601571,"url":"https://github.com/iambenkis/drawing-book-mob-programming-","last_synced_at":"2025-03-14T05:11:12.334Z","repository":{"id":138175526,"uuid":"558263911","full_name":"iambenkis/Drawing-Book-Mob-programming-","owner":"iambenkis","description":"Mob programming challenges using  Jest library","archived":false,"fork":false,"pushed_at":"2022-10-27T08:44:12.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T23:49:06.326Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iambenkis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-27T07:50:42.000Z","updated_at":"2023-02-28T16:32:48.000Z","dependencies_parsed_at":"2024-03-26T15:31:52.296Z","dependency_job_id":null,"html_url":"https://github.com/iambenkis/Drawing-Book-Mob-programming-","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambenkis%2FDrawing-Book-Mob-programming-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambenkis%2FDrawing-Book-Mob-programming-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambenkis%2FDrawing-Book-Mob-programming-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambenkis%2FDrawing-Book-Mob-programming-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iambenkis","download_url":"https://codeload.github.com/iambenkis/Drawing-Book-Mob-programming-/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243526953,"owners_count":20305115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T02:22:55.565Z","updated_at":"2025-03-14T05:11:12.314Z","avatar_url":"https://github.com/iambenkis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## How to solve this challenge?\n\n1. Read the \"Challenge description\" below.\n2. Make changes to the [challenge.js](./challenge.js) file.\n3. Commit your changes.\n4. Wait for the result of the \"GitHub Classroom Workflow\" action. If it is green - congratulations, you solved this challenge! If not - try again!\n\n## Challenge description\n\n### Drawing book\n\nA teacher asks the class to open their books to a page number. A student can either start turning pages from the front of the book or from the back of the book. They always turn pages one at a time. When they open the book, page 1 is always on the right side:\n\n![](picture1.png)\n\nWhen they flip page 1, they see pages 2 and 3. 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. If the book is n pages long, and a student wants to turn to page p, what is the minimum number of pages to turn? They can start at the beginning or the end of the book. Given n and p, find and print the minimum number of pages that must be turned in order to arrive at page p.\n\n### Example\n\nn = 5\np = 3\n\n![](picture2.png)\n\nUsing the diagram above, if the student wants to get to page `3`, they open the book to page `1`, flip `1`  page and they are on the correct page. If they open the book to the last page, page `5` , they turn `1`  page and are at the correct page. Return `1`.\n\n###### Function Description\n\nComplete the pageCount function in the editor below.\n\npageCount has the following parameter(s):\n\n- int n: the number of pages in the book\n- int p: the page number to turn to\n\n###### Returns\n\n- int: the minimum number of pages to turn\n\n###### Input Format\n\nThe first line contains an integer `n`, the number of pages in the book.\nThe second line contains an integer,`p`, the page to turn to.\n\n###### Sample Input 0\n```bash\n6\n2\n```\n###### Sample Output 0\n\n```bash\n1\n```\n\n### Explanation 0\n\nIf the student starts turning from page `1`, they only need to turn `1` page:\n\n![](picture3.png)\n\nIf a student starts turning from page `6`, they need to turn `2` pages:\n\n![](picture4.png)\n\nReturn the minimum value, `1`.\n\n###### Sample Input 1\n```bash\n5\n4\n```\n###### Sample Output 1\n\n```bash\n0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiambenkis%2Fdrawing-book-mob-programming-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiambenkis%2Fdrawing-book-mob-programming-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiambenkis%2Fdrawing-book-mob-programming-/lists"}