Created
March 23, 2015 12:31
-
-
Save Nymphium/8f8a175db9739d6c02fd 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
split = (str) -> | |
return if not str | |
dim = "[^,]+" | |
ret = [piece for piece in str\gmatch dim] | |
return ret | |
valadd = (val) -> | |
switch val\match "%a" | |
when "A" return 5 | |
when "B" return 3 | |
when "C" return 2 | |
else return 0 | |
file = io.open arg[1] | |
unit = 0 | |
avg = 0 | |
for i in file\lines! | |
l = split i | |
if l[8] ~= "\"D\"" | |
val = l[5]\gsub "\"", "" | |
if tonumber val | |
unit += tonumber val | |
if l[8] | |
avg += valadd l[8] | |
print valadd l[8] | |
res = avg / unit | |
if res >= 3.2 | |
print "match with exemption of tuition fee" | |
else | |
print "fxxk" | |
print "result: " .. tostring res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment