Last active
August 29, 2015 14:06
-
-
Save rkrishnasanka/f5575824d2ea549df294 to your computer and use it in GitHub Desktop.
Prints out corrects , partials and wrongs from the detail string
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
Groupa 0 ++ / 1+ 2a++ b++ c+++-/- d-- 3a- b- | |
Groupb 0++- 1+ 2a+/ b++ c+++--- d-- 3a- b- | |
Group4 0++/ 1+ 2a++ b++ c+++--- d-- 3a- b- | |
Group5 0++- 1+ 2a+/ b-- c------ d-- 3a- b- | |
Group6 0+++ 1? 2a++ b++ c-+/-// d-- 3a+ b- | |
Group7 0++- 1+ 2a// b// c-/---- d-- 3a- b- | |
Group8 0++/ 1+ 2a// b++ c+++-/- d// 3a- b- | |
Group9 0++- 1+ 2a-/ b// c-+---- d++ 3a- b- | |
Group1 0+++ 1+ 2a-/ b// c-+--/- d-- 3a- b- |
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
def parseDetail(line): | |
corrects = 0 | |
wrongs = 0 | |
partials = 0 | |
for i in range(0,len(line)): | |
c = line[i] | |
if c=='+': corrects=corrects+1 | |
if c=='-': wrongs=wrongs+1 | |
if c=='/': partials=partials+1 | |
return corrects, wrongs ,partials | |
def trim(line): | |
if line[0] == ' ': | |
if line[len(line)-1] == ' ': | |
return line[1:len(line)-2] | |
else: | |
return line[1:] | |
if line[1:len(line)-1] == ' ': | |
return line[:len(line)-2] | |
return line | |
ifile = open("details.txt" , "r") | |
ofile = open("results.txt" , "w") | |
for line in ifile: | |
if line == '\n': continue | |
c,w,p = parseDetail(line) | |
output = "| "+str(c) + " | " + str(p) + " | " + str(w) + " | =" + trim(line) +"= |"+"\n" | |
ofile.write(output) | |
print output | |
ifile.close() | |
ofile.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment