updated ruby solution for problem 8 (definition changed)