Quote Originally Posted by Scatman
i am not trying to make sense of anything, it was just for the sake of exercise (how would i solve if i had to )
That is what you're trying to do though: make sense of the input according to certain rules. When you're just allowing for one number per line, it is easy to be lax, but if you're trying to interpret a number on a line that may contain other things rather than just considering that to be invalid input, you should be more careful. The thing then is to be absolutely clear as to what are those rules. For example, what about:
Code:
three300
or
Code:
three300zero
or
Code:
three 300 five 500
Do you allow negative numbers?

So, depending on what rules you want to use, the exact approach you take to parsing for the number might differ.