Skip to content

Instantly share code, notes, and snippets.

@Shujito Shujito/imgurer.lua
Created Nov 15, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.