Skip to content

Instantly share code, notes, and snippets.

@Nymphium
Created March 23, 2015 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nymphium/8f8a175db9739d6c02fd to your computer and use it in GitHub Desktop.
Save Nymphium/8f8a175db9739d6c02fd to your computer and use it in GitHub Desktop.
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