DEV Community

Discussion on: Daily Challenge #110 - Love VS. Friendship

Collapse
 
yechielk profile image
Yechiel Kalmenson
def wordsToMarks(word)
  alphabet = ("a".."z").to_a
  mark = 0
  word.each_char do |char|
    mark += alphabet.index(char.downcase) + 1
  end
  mark
end
Collapse
 
scrabill profile image
Shannon Crabill

("a".."z").to_a is nifty!

Collapse
 
yechielk profile image
Yechiel Kalmenson

Well, my first attempt had me iterating calling .index on ("a".."z") only to find out that you can't call index on a range, so in trying to work around that I realized I could just convert the range into an array... :)