solutions in Ruby
PP0504B