Solved #11 in ruby.