Second exercise from book for Ruby