Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sumUpNumbers(inputString)
- x = 0
- string_length = inputString.length
- number = ""
- sum = 0
- while (x < string_length)
- if inputString[x].to_s >= '0' and inputString[x].to_s <= '9' then
- while (inputString[x].to_s >= '0' and inputString[x].to_s <= '9')
- number = number + inputString[x]
- x = x + 1
- end
- sum = sum + number.to_i
- end
- x = x + 1
- number = ""
- end
- return sum
- end
Advertisement
Add Comment
Please, Sign In to add comment