Created
March 4, 2015 15:50
-
-
Save domitry/a3e59ce432847353be91 to your computer and use it in GitHub Desktop.
じーぴーえー (阪大koanフォーマット)
This file contains hidden or 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
# -*- encoding: utf-8 -*- | |
require "csv" | |
path = ARGV[0] | |
csv = CSV.read(path, headers: true, encoding: "Shift_JIS:UTF-8") | |
column = csv["評語"] | |
column.delete("欠席") | |
sum = column.reduce(0) do |memo, alphabet| | |
val = { | |
"\uFF33" => 4, | |
"\uFF21" => 3, | |
"\uFF22" => 2, | |
"\uFf23" => 1 | |
}[alphabet] | |
raise "Invaild val: " + alphabet.to_s if val.nil? | |
memo + val | |
end | |
puts "Your GPA:" + (sum.to_f / column.length).to_s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment