Skip to content

Instantly share code, notes, and snippets.

@alekst
Last active August 29, 2015 13:55
Show Gist options
  • Save alekst/8753903 to your computer and use it in GitHub Desktop.
Save alekst/8753903 to your computer and use it in GitHub Desktop.
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