Solve problems 17,31 using Lua.