Merge pull request #7 from pdjely/master

added graded test cases. set output to file according to reqs
total seems off
Merge remote-tracking branch 'upstream/master'
output doesnt write repeated final node