Created
August 12, 2012 21:48
-
-
Save lune-sta/3334737 to your computer and use it in GitHub Desktop.
Project Euler 22
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
c, score = 0, 0 | |
open("names.txt").gets.split(/,/).map{|a| a.delete("\"")}.sort.each do |i| | |
c += 1 | |
i.size.times do |j| | |
score += (i[j].bytes.to_a[0].to_i - "A".bytes.to_a[0].to_i + 1) * c | |
end | |
end | |
puts score # 871198282 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment