more work on hw5

Passes all the tests but gives the wrong answers on the real data.