Created
May 28, 2013 16:53
-
-
Save anonymous/5664239 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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