6 kyu
The lost beginning
342 of 769CatPlusPlus
Description:
Problem Statement
You're given a string of digits representing a sequence of consecutive natural numbers concatenated together. Your task is to find the smallest possible first number in the sequence. The sequence starts with a single or multi-digit number and continues with numbers each incremented by 1. If multiple sequences can be formed, choose the one that starts with the smallest number.
Examples
- "123" -> [1, 2, 3] -> 1
- "91011" -> [9, 10, 11] -> 9
- "17181920" -> [17, 18, 19, 20] -> 17
- "9899100" -> [98, 99, 100] -> 98
- "91" -> [91] -> 91
- "121122123" -> [121, 122, 123] -> 121
- "1235" -> [1235] -> 1235
- "101" -> [101] -> 101
Constraints
- Input string length: 1 - 200 characters.
- Smallest possible first number: 1 - 1,000,000,000.
Remember, the key is to form a sequence of consecutive natural numbers. If the sequence matches the input string, you've found the smallest possible first number. Experiment with different lengths for the first number until you find a match or exhaust all possibilities.
Fundamentals
Algorithms
Strings
Mathematics
Similar Kata:
Stats:
Created | Jan 7, 2024 |
Published | Jan 8, 2024 |
Warriors Trained | 3761 |
Total Skips | 114 |
Total Code Submissions | 4985 |
Total Times Completed | 769 |
Python Completions | 342 |
Haskell Completions | 17 |
JavaScript Completions | 252 |
Java Completions | 100 |
CoffeeScript Completions | 7 |
Scala Completions | 12 |
λ Calculus Completions | 3 |
Rust Completions | 23 |
C++ Completions | 60 |
C Completions | 19 |
Total Stars | 122 |
% of votes with a positive feedback rating | 94% of 124 |
Total "Very Satisfied" Votes | 112 |
Total "Somewhat Satisfied" Votes | 9 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 19 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |