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.
Getting the pages to count and turn correctly was my problem.
Renaming the n,k,arr to better names really helped me work this one out.
defworkbook(chapter_count,problems_per_page,chapters):ifchapter_count==0:return0ifproblems_per_page==0:return0iflen(chapters)==0:return0special_count=0current_page=0forchapterinchapters:#Each chapter starts on a new pagecurrent_page+=1forprobleminrange(1,chapter+1):ifproblem==current_page:special_count+=1# don't turn page if this is the last problemifproblem!=chapterandproblem%problems_per_page==0:current_page+=1returnspecial_count
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lisa's Workbook
You are viewing a single comment's thread. Return to all comments →
Getting the pages to count and turn correctly was my problem.
Renaming the n,k,arr to better names really helped me work this one out.