Changeable words: Difference between revisions

(Add Factor)
Line 870:
underclassman <=> underclassmen upperclassman <=> upperclassmen
</pre>
 
=={{header|Nim}}==
Using the standard module <code>std/editdistance</code> to get the distance between two words.
<lang Nim>import std/editdistance, sugar
 
# Build list of words with length >= 12.
let words = collect(newSeq):
for word in "unixdict1.txt".lines:
if word.len >= 12:
word
 
echo "List of changeable words:\n"
var count = 0
for i in 0..<words.high:
let word1 = words[i]
for j in i+1..words.high:
let word2 = words[j]
if word1.len == word2.len and editDistance(word1, word2) == 1:
echo word1, " <-> ", word2
inc count, 2
 
echo "\nFound ", count, " changeable words."</lang>
 
{{out}}
<pre>List of changeable words:
 
aristotelean <-> aristotelian
claustrophobia <-> claustrophobic
committeeman <-> committeemen
committeewoman <-> committeewomen
complementary <-> complimentary
confirmation <-> conformation
congresswoman <-> congresswomen
councilwoman <-> councilwomen
craftsperson <-> draftsperson
eavesdropped <-> eavesdropper
frontiersman <-> frontiersmen
handicraftsman <-> handicraftsmen
incommutable <-> incomputable
installation <-> instillation
kaleidescope <-> kaleidoscope
neuroanatomy <-> neuroanotomy
newspaperman <-> newspapermen
nonagenarian <-> nonogenarian
onomatopoeia <-> onomatopoeic
philanthrope <-> philanthropy
prescription <-> proscription
schizophrenia <-> schizophrenic
shakespearean <-> shakespearian
spectroscope <-> spectroscopy
underclassman <-> underclassmen
upperclassman <-> upperclassmen
 
Found 52 changeable words.</pre>
<pre>
 
=={{header|Perl}}==
Anonymous user