Last active
August 29, 2015 13:55
-
-
Save alekst/8753903 to your computer and use it in GitHub Desktop.
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
grid = Hash[("A".."Z").to_a.zip(1..27).to_a] # creates a hash where keys are letters, values are numbers. | |
def to_numbers | |
map {|i| grid.fetch(i)} #converts array of letters to numbers, using grid hash. | |
end | |
def to_letters | |
sum.map {|i| grid.key(i)} #convers array of numbers into letters, using grid hash. | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment