Extract increasing integers from digit string def extract_increasing(digits): Given a string of digits guaranteed to only contain ordinary integer digit characters 0 to 9, create and return the list of increasing integers acquired from reading these digits in order from left to right. The first integer in the result list is made up from the first digit of the string. After that, each element is an integer that consists of as many following consecutive digits as are needed to make that integer strictly larger than the previous integer. The leftover digits at the end of the digit string that do not form a sufficiently large integer are ignored. This problem can be solved with one for-loop through the digits that looks at each digit exactly once regardless of the position of that digit in the beginning, end or middle of the string. Keep track of the current number (initially zero) and the previous number to beat (initially minus one). Each digit d then updates current = 10*current+d to tack that digit to the end of current. digits Expected result '045349' [0, 4, 5, 34] '77777777777777777777777' [7, 77, 777, 7777, 77777, 777777] '122333444455555666666' [1, 2, 23, 33, 44, 445, 555, 566, 666] '1234567890987654321' [1, 2, 3, 4, 5, 6, 7, 8, 9, 98, 765, 4321]

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Extract increasing integers from digit string

def extract_increasing(digits):

Given a string of digits guaranteed to only contain ordinary integer digit characters 0 to 9, create and return the list of increasing integers acquired from reading these digits in order from left to right. The first integer in the result list is made up from the first digit of the string. After that, each element is an integer that consists of as many following consecutive digits as are needed to make that integer strictly larger than the previous integer. The leftover digits at the end of the digit string that do not form a sufficiently large integer are ignored.
This problem can be solved with one for-loop through the digits that looks at each digit exactly once regardless of the position of that digit in the beginning, end or middle of the string. Keep track of the current number (initially zero) and the previous number to beat (initially minus one). Each digit d then updates current = 10*current+d to tack that digit to the end of current.

digits Expected result
'045349' [0, 4, 5, 34]
'77777777777777777777777' [7, 77, 777, 7777, 77777, 777777]
'122333444455555666666' [1, 2, 23, 33, 44, 445, 555, 566,
666]
'1234567890987654321' [1, 2, 3, 4, 5, 6, 7, 8, 9, 98,
765, 4321]
'3141592653589793238462643
383279502884'
[3, 14, 15, 92, 653, 5897, 9323,
84626, 433832, 795028]
'2718281828459045235360287
47135266249775724709369995
95749669676277240766303535
47594571382178525166427427
46639193200305992181741359
6629043572900334295260'
[2, 7, 18, 28, 182, 845, 904,
5235, 36028, 74713, 526624,
977572, 4709369, 9959574,
96696762, 772407663, 3535475945,
7138217852, 51664274274,
66391932003, 599218174135,
966290435729]
'123456789' * 100 A list with 75 elements, the last one equal to
34567891234567891234567891
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY