my solution about the problem of codewars(ruby)