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

28.26% Correct | 71.74% Incorrect
Last Solution submitted on Oct 26, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers10

Suggested Problems

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!