Skip to content

Instantly share code, notes, and snippets.

@dasibre
Created March 7, 2014 12:49
Show Gist options
  • Select an option

  • Save dasibre/9410875 to your computer and use it in GitHub Desktop.

Select an option

Save dasibre/9410875 to your computer and use it in GitHub Desktop.
String change
def change(str)
alphabet_count = str.downcase.scan(/[a-z]/).count
if alphabet_count > 0
ones = "1"*alphabet_count
zeroes = 26
ones_zeroes = ones.ljust(zeroes-alphabet_count,'0')
else
"0"*26
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment