Odd words: Difference between revisions
Content added Content deleted
m (Typo fixed) |
(Added a Lua solution) |
||
Line 730: | Line 730: | ||
terminable : trial |
terminable : trial |
||
</pre> |
</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}}== |
=={{header|Nim}}== |