my hackerrank code in C & Lua