First solution to ruby-1 challenge 5