Skip to content

Instantly share code, notes, and snippets.

@lune-sta
Created August 12, 2012 21:48
Show Gist options
  • Save lune-sta/3334737 to your computer and use it in GitHub Desktop.
Save lune-sta/3334737 to your computer and use it in GitHub Desktop.
Project Euler 22
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