s = string.char(255,255):rep(999999) for i = 1,444 do
debug.getinfo(1000,nil,s) end
gg.alert('Hello')
---- BigLog / load 0.1 second 😜
debug.getinfo(1000,nil,s) end
gg.alert('Hello')
---- BigLog / load 0.1 second 😜
s = os.clock()
v = string.char(255,255,255,255):rep(9999999)
for i = 1,1030 do debug.traceback(2000,nil,v) end
z = os.clock() gg.sleep(1) a = z - s
if a >= 3 then print('🌹 Log Succkes : ',a) return else end
gg.setVisible(false)
if a <= 0.5 or os.clock() > os.clock() then
return gg.alert("⚠️ Restart Script !! ", "") end
if a == 0 or os.clock() - os.clock() then end
gg.alert('Hello Word !!')
v = string.char(255,255,255,255):rep(9999999)
for i = 1,1030 do debug.traceback(2000,nil,v) end
z = os.clock() gg.sleep(1) a = z - s
if a >= 3 then print('🌹 Log Succkes : ',a) return else end
gg.setVisible(false)
if a <= 0.5 or os.clock() > os.clock() then
return gg.alert("⚠️ Restart Script !! ", "") end
if a == 0 or os.clock() - os.clock() then end
gg.alert('Hello Word !!')
Fix = gg.prompt({"Select File To Fix","Remove os.exit"},{"/sdcard/FixTool"},{"file","checkbox"})
if Fix == nil then return end
Lua = io.open(Fix[1],"r"):read("*a")
if Fix[2] then
S = Lua:gsub("exit","time")
io.open(Fix[1].."Fix.lua","w"):write(string.dump(load(S),true)):close()
end
--- Make Code ( Remove os.exit() ) 😆
if Fix == nil then return end
Lua = io.open(Fix[1],"r"):read("*a")
if Fix[2] then
S = Lua:gsub("exit","time")
io.open(Fix[1].."Fix.lua","w"):write(string.dump(load(S),true)):close()
end
--- Make Code ( Remove os.exit() ) 😆
https://exercism.io/tracks/lua/exercises/run-length-encoding/solutions/1bd86fef3c9a42cab0e967bc635655d9
-- clever community solution: use
--
------ Encoding
local rle = {}
function rle.encode(decoded)
for character in decoded:gmatch(".") do
decoded = decoded:gsub(character:rep(2) .. "+", function(match)
return tostring(#match) .. character
end)
end
return decoded
end
------ Decoding
function rle.decode(encoded)
return encoded:gsub("(%d+)(.)", function(length, character)
return character:rep(length)
end)
end
-- clever community solution: use
gsub for runs of 2 or more--
------ Encoding
local rle = {}
function rle.encode(decoded)
for character in decoded:gmatch(".") do
decoded = decoded:gsub(character:rep(2) .. "+", function(match)
return tostring(#match) .. character
end)
end
return decoded
end
------ Decoding
function rle.decode(encoded)
return encoded:gsub("(%d+)(.)", function(length, character)
return character:rep(length)
end)
end
Exercism
aweidner's solution to Run Length Encoding on the Lua track | Exercism
See how aweidner solved the Run Length Encoding exercise on the Lua track
local function encode(txt)
local pos =1
local result = ''
while pos <= #txt do
local nxt = string.find(txt, '[^' .. string.sub(txt,pos,pos) .. ']', pos) or #txt+1
result = result .. (((nxt - pos) > 1) and (nxt -pos) or '') .. string.sub(txt, pos, pos)
pos = nxt
end
return result
end
local function decode(txt)
local result = ''
for d,w in string.gmatch(txt, '(%d*)(.)') do
if d =='' then d =1 end
result = result .. string.rep(w,d)
end
return result
end
local pos =1
local result = ''
while pos <= #txt do
local nxt = string.find(txt, '[^' .. string.sub(txt,pos,pos) .. ']', pos) or #txt+1
result = result .. (((nxt - pos) > 1) and (nxt -pos) or '') .. string.sub(txt, pos, pos)
pos = nxt
end
return result
end
local function decode(txt)
local result = ''
for d,w in string.gmatch(txt, '(%d*)(.)') do
if d =='' then d =1 end
result = result .. string.rep(w,d)
end
return result
end