Last active
August 29, 2015 14:00
-
-
Save btn0s/11391119 to your computer and use it in GitHub Desktop.
"Create a method to accept one arbitrary string as an argument, and return a string of length 26. The objective is to detect if letters of the alphabet (upper or lower case) are present anywhere in the string, and to set each of the 26 characters corresponding to each letter to either '1' if present, '0' if not."
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 change a | |
# put your code here! | |
b = a.split("") | |
c = "abcdefghijklmnopqrstuvwxyz" | |
d = c.split("") | |
e = Hash.new | |
e = d.each {|x| e[x] = 0} | |
b.each {|x| | |
if b.include?(x) && d.include?(x) | |
e[x] = 1 | |
end } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment