Finished problems 3 and 4 from problemset 4 of the MIT course intro to computer science