Wrote non-optimized code for Ass3.Prob2.