Skip to content

Instantly share code, notes, and snippets.

Created May 28, 2013 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5664239 to your computer and use it in GitHub Desktop.
Save anonymous/5664239 to your computer and use it in GitHub Desktop.
local count = 0
local count_v = 0
local bytes, bytes_v = 0, 0
local leets = '[abegiloqstz]'
local args = { ... }
for word in io.lines(args[1] or 'words') do
local v = 1
for ch in word:gmatch('.') do
local mult = 1
if ch:find(leets) then mult = mult + 1 end
if ch:lower() ~= ch:upper() then mult = mult + 1 end
v = v * mult
end
count = count + 1
count_v = count_v + v
bytes = bytes + #word
bytes_v = bytes_v + v*#word
end
bytes = bytes + count
bytes_v = bytes_v + count_v
print("Words:",count, "Word variants:", count_v)
print("Entropy per word/word variant/growth factor:", math.log(count, 2), math.log(count_v, 2), math.log(count_v)/math.log(count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment