Problem 59776. Extract Increasing Integers from Digit String
Given a string containing only digits, the function get_integers should return the list of increasing integers obtained by reading these digits in order.
More precisely: the first number in the final list consists of the first digit of the string. Then, each element is an integer that consists of as many consecutive digits as necessary to make this integer strictly greater than the previous integer in the list. Any remaining digits at the end of the string that do not form a sufficiently large integer are removed.
Examples :
- get_integers("045349") returns [0, 4, 5, 34] Since the first digit is 0, so it forms the first integer in the list [0]; the next digit is 4, which is greater than 0, so it forms the next integer [0, 4]; the next digit is 5, which is greater than 4, so it forms the next integer: [0, 4, 5]; the next digit is 3, which is lower than 5; thenest digit is 4, which together the previous 3 form the next integer: [0, 4, 5, 34].
- get_integers("0098765432") returns [0, 9, 87, 654]
- get_integers("9876543210") returns [9, 87, 654, 3210]
- get_integers("77777777777777777777777") returns [7, 77, 777, 7777, 77777, 777777]
Solution Stats
Problem Comments
-
1 Comment
Dyuman Joshi
on 26 Jun 2024
Similar to #55325 - https://in.mathworks.com/matlabcentral/cody/problems/55325
Solution Comments
Show commentsProblem Recent Solvers10
Suggested Problems
-
Determine whether a vector is monotonically increasing
21156 Solvers
-
07 - Common functions and indexing 2
412 Solvers
-
362 Solvers
-
375 Solvers
-
399 Solvers
More from this Author53
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!