|
function solution4(level)local step = {}for j = 1, level dostep[(1<<j)-1] = jendlocal last_index = 1for j = 0, level-1 dolast_index = 2 * last_index + jendlocal t = {"Lua"}local p = last_indexfor j = 1, (1<<level)-1 dop = p - step[j ~ (j-1)]t[p] = "Lua"endreturn t, last_indexendlocal level = tonumber(arg[1])local t, last_index = solution4(level)