Added my solution to problem 3, with better solutions beneath