pushing solution from book that uses arrays