1396
Math and Science / Re: Loop all possible words algorithm
« on: August 05, 2011, 10:38:50 am »
Here is a verson in Lua
Code: (Lua) [Select]
a="a"
function increment(str)
len = #str
if len==0 then
return "a"
end
bt = str:byte(len)
if bt<122 then
str = str:sub(1, len - 1) .. string.char(bt+1)
else
str = increment(str:sub(1, len - 1)) .. "a"
end
return str
end
print(a)
for i=1,100 do
a=increment(a)
print(a)
end