Code solution for stat221