We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Drawing Book
- Discussions
Drawing Book
Drawing Book
Sort by
recency
|
190 Discussions
|
Please Login in order to post a comment
Hi! It's my solution in Python3 :) :
JS
Made it to pass all the tests like that. Not sure if the logic is optimal though
function pageCount(n, p) {
// Write your code here
let start = Math.ceil((p - 1) / 2);
let end;
n % 2 === 0 ? (end = Math.ceil((n - p) / 2)) : (end = Math.floor((n - p) / 2));
return start <= end ? start : end; }
x=p-1 y=n-p if x