Jump to content

Odd words: Difference between revisions

Added a Lua solution
m (Typo fixed)
(Added a Lua solution)
Line 730:
terminable : trial
</pre>
 
=={{header|Lua}}==
<lang Lua>minOddWordLength = 5
minWordLength = minOddWordLength*2-1
 
dict = {}
for word in io.lines('unixdict.txt') do
local n = #word
if n >= minOddWordLength then -- skip words that are too short
dict[word] = n
end
end
 
for word, len in pairs(dict) do
if len >= minWordLength then
local odd = ""
for o, _ in word:gmatch("(.)(.?)") do
odd = odd .. o
end
if dict[odd] then
print(string.format("%10s → %s", word, odd))
end
end
end</lang>
 
{{out}}
Note: Output will not be alphabetical.
 
<pre> barbarian → brain
childbear → cider
corrigenda → cried
supervene → spree
siltation → slain
terminable → trial
supersede → spree
slingshot → sight
propionate → point
salvation → slain
palladian → plain
gargantuan → grata
headdress → hades
statuette → saute</pre>
 
=={{header|Nim}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.