Skip to content

Instantly share code, notes, and snippets.

@lolptdr
Created May 21, 2014 16:01
Show Gist options
  • Save lolptdr/12fadbe4ece0c40bd83d to your computer and use it in GitHub Desktop.
Save lolptdr/12fadbe4ece0c40bd83d to your computer and use it in GitHub Desktop.
def change a
smallcase = 'a'..'z' # smallcase.to_a.size #=> 26
zeros = ("%026d" % 0).chars # creates array of 26 zeros
check = Hash[smallcase.zip(zeros)] #create hash map of alphabet to zeros
b = a.chars.each {|x| x.downcase!}
b.each do |x|
if check.include?(x)
check[x] = 1
end
end
check.values.join()
end
change('a **& bZ') #=>'11000000000000000000000001'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment