Adding ruby code for moderate level challenge in codeeval