add ruby versions of problems 4 to 7
solve problem 8