Skip to content

Instantly share code, notes, and snippets.

@vlad-shatskyi
Last active December 14, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vlad-shatskyi/5041680 to your computer and use it in GitHub Desktop.
Save vlad-shatskyi/5041680 to your computer and use it in GitHub Desktop.
names = File.read('names.txt').split(',').map { |str| str[1..-2] }
letters = ('A'..'Z').to_a.join
sum = 0
names.each_with_index do |name, i|
score = 0
name.each_char do |char|
score += (letters.index(char) + 1) * (i + 1)
end
sum += score
end
puts sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment