Skip to content

Instantly share code, notes, and snippets.

@Shujito
Created November 15, 2016 07:09
Show Gist options
  • Save Shujito/50125998b0fc397b4917abf4ce1dba8a to your computer and use it in GitHub Desktop.
Save Shujito/50125998b0fc397b4917abf4ce1dba8a to your computer and use it in GitHub Desktop.
imgur permutator
local fiveChars = ... or 'weiss'
--print('chars:', fiveChars:lower())
local function bitSet(number, offset)
local nro = bit32.rshift(number, offset)
local nroa1 = bit32.band(nro, 1)
--print('nroa1', nroa1)
return nroa1 ~= 0
end
print('<!doctype html>')
print('<html>')
print(' <head>')
print(' <title>Imgurer - ' .. fiveChars .. '</title>')
print(' <head>')
print(' <body>')
for idx=1,2 ^ fiveChars:len() do
-- print('idx', idx)
local permutation = ''
for jdx=1,fiveChars:len() do
local currentChar = fiveChars:sub(jdx,jdx)
--print('current:', currentChar)
if bitSet(idx - 1, jdx - 1) then
--print('has bit')
permutation = permutation .. currentChar:upper()
else
--print('lacks bit')
permutation = permutation .. currentChar:lower()
end
end
--print('permutation #'..idx, permutation)
print(' <a href="https://imgur.com/'.. permutation ..'">')
print(' <img width="320px" src="https://i.imgur.com/' .. permutation .. 'm.jpg"/>')
print(' </a>')
end
print(' <body/>')
print('<html/>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment