Skip to content

Instantly share code, notes, and snippets.

@pingbird
Created March 30, 2014 08:21
Show Gist options
  • Select an option

  • Save pingbird/9869425 to your computer and use it in GitHub Desktop.

Select an option

Save pingbird/9869425 to your computer and use it in GitHub Desktop.
fail text Deadfish converter
local sqr={[0]={0,0},{0,0}}
for l1=2,210 do
sqr[l1]={math.floor(math.sqrt(l1)+0.5),math.floor(math.sqrt(l1)+0.5)^2}
end
for l1=211,255 do
sqr[l1]={15,225}
end
local o={}
for x=0,255 do
o[x]={}
for y=0,255 do
if x==y then
o[x][y]=""
else
local dt=x-y
local direct=(dt>0 and "d" or "i"):rep(math.abs(dt))
local n
local prw=sqr[y]
do
local r
if x<4 then
r=("i"):rep(4-x).."ss"
elseif x<16 then
r="ss"
else
r="s"
end
r=r..("i"):rep(prw[1])
local sdt=x-prw[1]
local m=(sdt>0 and "d" or "i"):rep(math.abs(sdt))
n=#r<#m and r or m
end
local sdt=y-prw[2]
local pow=n.."s"..(sdt>0 and "i" or "d"):rep(math.abs(sdt))
o[x][y]=#pow<#direct and pow or direct
end
end
end
local iter=true
while iter do
iter=false
for x=0,255 do
for y=0,255 do
for z=0,255 do
if #(o[x][z]..o[z][y]) < #o[x][y] then
o[x][y]=o[x][z]..o[z][y]
iter=true
end
end
end
end
end
local out=""
local last=0
for char in ("Hello, World!"):gmatch(".") do
local bc=string.byte(char)
out=out..o[last][bc].."o"
last=bc
end
print(out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment