Created
January 5, 2015 06:08
-
-
Save omas/17b901bbd744bdc9d49b to your computer and use it in GitHub Desktop.
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
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('data', function (chunk) { | |
var lines = chunk.split('\n'); | |
var len = parseInt(lines.shift(),10); | |
var result = (function(grades) { | |
var score_table = { | |
'A':4,'B':3,'C':2,'D':1,'F':0 | |
}; | |
var sum = grades.map(function(v) { | |
return score_table[v]; | |
}) | |
.reduce(function(prev,current) { | |
return prev + current; | |
}); | |
return sum / grades.length; | |
}(lines[0].toString().split('').slice(0,len))); | |
console.log(result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment