Hackerrank solutions in ruby