Skip to content

Instantly share code, notes, and snippets.

@fuxoft
Created December 17, 2022 23:12
Show Gist options
  • Save fuxoft/3f943455752e02ee895dcaf6a9a1d0b4 to your computer and use it in GitHub Desktop.
Save fuxoft/3f943455752e02ee895dcaf6a9a1d0b4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env lua5.3
local ALLOWED = {}
for chr in string.gmatch("ABCDEFHIJKLMNOPRSTUVXYZ0123456789",".") do
ALLOWED[chr] = true
end
local SAMOHLASKY = {}
for chr in string.gmatch("AEIOUY",".") do
SAMOHLASKY[chr] = true
end
local function letters_ok(str)
str = str:upper()
for chr in str:gmatch(".") do
if not ALLOWED[chr] then
return false
end
end
return true
end
local function ltr8(lang)
local fd=io.open("words_"..lang..".txt")
repeat
local word = fd:read("*l")
if word then
word = word:gsub("\013","")
word = word:upper()
if letters_ok(word) then
if word:match("O") then
if #word == 8 then
if true or not SAMOHLASKY [word:sub(4,4)] then
print(word:sub(1,3).." "..(word:sub(4,8)))
end
end
end
end
end
until not word
fd:close()
end
local function ltr5(lang)
local fd=io.open("words_"..lang..".txt")
assert(fd)
repeat
local word = fd:read("*l")
if word then
word = word:gsub("\013","")
word = word:upper()
if letters_ok(word) then
if word:match("O") then
if #word == 5 then
print(word)
end
end
end
end
until not word
fd:close()
end
ltr8("eng")
--ltr5("eng")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment