On Wed, 5 Dec 2012 23:14:56 -0500 Rich Felker wrote: > All that means is that you missed testing any case where it differs. > > ./a.out s10212 s102102 > 2 > -1 I realized what you meant just after sending the last email... Anyhow, after working out how the state should change and a little bit of testing, I arrived at the attached version. Logic for the upper part: Start, assuming a non-numeric char (1) --if initialized to 0, it will break the case where the first 2 characters are differing digits! while walking down to the difference, -record 0 if char was last -record 2 for any other digit if char was last -Reset to 1 if a non-digit is found. This records the leading digit of a sequence. When the difference is reached, record 0 if one branch contains a leading zero. -- Isaac Dunham