6 kyu

How many pages in a book?

1,632 of 4,690alexbur

Description:

Every book has n pages with page numbers 1 to n. The summary is made by adding up the number of digits of all page numbers.

Task: Given the summary, find the number of pages n the book has.

Example

If the input is summary=25, then the output must be n=17: The numbers 1 to 17 have 25 digits in total: 1234567891011121314151617.

Be aware that you'll get enormous books having up to 100.000 pages.

All inputs will be valid.

Here's the opposite kata, which is more complex (Paginating a huge book)

Puzzles
Algorithms

Stats:

CreatedMar 13, 2022
PublishedMar 13, 2022
Warriors Trained9106
Total Skips219
Total Code Submissions15749
Total Times Completed4690
Python Completions1632
JavaScript Completions1937
Rust Completions88
Java Completions658
C++ Completions295
COBOL Completions4
C Completions171
D Completions4
Go Completions43
Total Stars151
% of votes with a positive feedback rating92% of 582
Total "Very Satisfied" Votes499
Total "Somewhat Satisfied" Votes72
Total "Not Satisfied" Votes11
Total Rank Assessments15
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • alexbur Avatar
  • falsetru Avatar
  • Rascal_Two Avatar
  • Madjosz Avatar
  • rowcased Avatar
  • barnasm Avatar
  • WestwardLand968 Avatar
  • akar-0 Avatar
  • lazyvinh Avatar
  • saudiGuy Avatar
Ad