Skip to content

Instantly share code, notes, and snippets.

@ironbyte
Created March 27, 2018 04:57
Show Gist options
  • Save ironbyte/402f96b4ef24b98116c3f1cf9a710b09 to your computer and use it in GitHub Desktop.
Save ironbyte/402f96b4ef24b98116c3f1cf9a710b09 to your computer and use it in GitHub Desktop.
String incrementer
def increment_string(input)
#your code here
s = input
s_digits = input.slice!(/\d+/)
s_digits_length = s_digits.length
end
@ironbyte
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment