Created
March 27, 2018 04:57
-
-
Save ironbyte/402f96b4ef24b98116c3f1cf9a710b09 to your computer and use it in GitHub Desktop.
String incrementer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def increment_string(input) | |
#your code here | |
s = input | |
s_digits = input.slice!(/\d+/) | |
s_digits_length = s_digits.length | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your job is to write a function which increments a string, to create a new string. If the string already ends with a number, the number should be incremented by 1. If the string does not end with a number the number 1 should be appended to the new string.