Today’s exercise is a tricky little homework problem:
Given a string consisting only of digits, find the missing number. For instance, given the string 596597598600601602 the missing number is 599. You may assume all the numbers are positive integers and the sequence increases by one at each number except the missing number. The numbers will have no more than five digits and the string will have no more than two hundred characters.
Your task is to write a program to find the missing number. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
This is harder than it looks. One problem is that the length of the numbers may increase in the middle of the string; for instance, the string 99989999… begins with four-digit numbers but the next number has five…
View original post 278 more words