algo3: hw5: problem 1 and 2 near finish