Skip to content

Commit

Permalink
Problem 22
Browse files Browse the repository at this point in the history
  • Loading branch information
zamith committed Jul 17, 2011
1 parent 495c01f commit 301ac6c
Show file tree
Hide file tree
Showing 5 changed files with 10,356 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 022.rb
@@ -0,0 +1,19 @@
#!/usr/bin/env ruby -w

### Pre processing
# ruby -a -F, -i -ne 'puts $F' names.txt
# sort -g names.txt > names_alf.txt

total_names_score=0
File.open("names_alf.txt", "r").each_line do |line|
line.gsub!("\"","").strip!
alf_val=0
line.upcase.each_char do |char|
alf_val_char = char.ord - 64
alf_val+=alf_val_char
end
total_names_score += alf_val * $.
end

p total_names_score

1 change: 1 addition & 0 deletions Gemfile
@@ -0,0 +1 @@
source :rubygems
10 changes: 10 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,10 @@
GEM
remote: http://rubygems.org/
specs:
ccsv (0.1)

PLATFORMS
ruby

DEPENDENCIES
ccsv

0 comments on commit 301ac6c

Please sign in to comment.