Solution to #3-6