Improvement to solution #5.  Added solution for #7