Solution in ruby for #35