Solve for algorithm1. assignment 1. Please don't copy.