solved problem 4 ruby
solved problem 5