4 kyu

Block sequence

174 of 426KenKamau

Description:

Consider the following array:

[1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 12345678910, 1234567891011...]

If we join these blocks of numbers, we come up with an infinite sequence which starts with 112123123412345123456.... The list is infinite.

You will be given an number (n) and your task will be to return the element at that index in the sequence, where 1 ≤ n ≤ 10^18. Assume the indexes start with 1, not 0. For example:

solve(1) = 1, because the first character in the sequence is 1. There is no index 0. 
solve(2) = 1, because the second character is also 1.
solve(3) = 2, because the third character is 2.

More examples in the test cases. Good luck!

Mathematics
Fundamentals

Stats:

CreatedJan 12, 2020
PublishedJan 12, 2020
Warriors Trained6680
Total Skips952
Total Code Submissions5669
Total Times Completed426
Python Completions174
Ruby Completions23
C++ Completions117
C# Completions37
Java Completions65
Kotlin Completions23
JavaScript Completions21
Total Stars358
% of votes with a positive feedback rating89% of 96
Total "Very Satisfied" Votes80
Total "Somewhat Satisfied" Votes10
Total "Not Satisfied" Votes6
Total Rank Assessments4
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • KenKamau Avatar
  • docgunthrop Avatar
  • hobovsky Avatar
  • G_kuldeep Avatar
  • dfhwze Avatar
Ad