Initial solution from ruby meetup.