Changeable words: Difference between revisions

Content added Content deleted
(Add notes and ref.)
Line 20: Line 20:




=={{header|AWK}}==
<lang AWK>
# syntax: GAWK -f CHANGEABLE_WORDS.AWK unixdict.txt
#
# sorting:
# PROCINFO["sorted_in"] is used by GAWK
# SORTTYPE is used by Thompson Automation's TAWK
#
{ arr[$0]++ }
END {
a2z = "abcdefghijklmnopqrstuvwxyz"
a2z_leng = length(a2z)
PROCINFO["sorted_in"] = "@ind_str_asc" ; SORTTYPE = 1
for (word in arr) {
leng = length(word)
if (leng < 12) {
continue
}
printed = 0
for (i=1; i<=leng; i++) {
if (printed == 1) {
break
}
if (i == 1) {
L = ""
R = substr(word,2)
}
else if (i == leng) {
L = substr(word,1,leng-1)
R = ""
}
else {
L = substr(word,1,i)
R = substr(word,i+2)
}
for (j=1; j<a2z_leng; j++) {
new_word = L substr(a2z,j,1) R
if (new_word in arr && word != new_word) {
printf("%-15s %s\n",word,new_word)
printed = 1
count++
}
}
}
}
printf("%d words\n",count)
exit(0)
}
</lang>
{{out}}
<pre>
aristotelean aristotelian
aristotelian aristotelean
claustrophobia claustrophobic
claustrophobic claustrophobia
committeeman committeemen
committeemen committeeman
committeewoman committeewomen
committeewomen committeewoman
complementary complimentary
complimentary complementary
confirmation conformation
conformation confirmation
congresswoman congresswomen
congresswomen congresswoman
councilwoman councilwomen
councilwomen councilwoman
craftsperson draftsperson
draftsperson craftsperson
eavesdropped eavesdropper
eavesdropper eavesdropped
frontiersman frontiersmen
frontiersmen frontiersman
handicraftsman handicraftsmen
handicraftsmen handicraftsman
incommutable incomputable
incomputable incommutable
installation instillation
instillation installation
kaleidescope kaleidoscope
kaleidoscope kaleidescope
neuroanatomy neuroanotomy
neuroanotomy neuroanatomy
newspaperman newspapermen
newspapermen newspaperman
nonagenarian nonogenarian
nonogenarian nonagenarian
onomatopoeia onomatopoeic
onomatopoeic onomatopoeia
philanthrope philanthropy
philanthropy philanthrope
prescription proscription
proscription prescription
schizophrenia schizophrenic
schizophrenic schizophrenia
shakespearean shakespearian
shakespearian shakespearean
spectroscope spectroscopy
spectroscopy spectroscope
underclassman underclassmen
underclassmen underclassman
upperclassman upperclassmen
upperclassmen upperclassman
</pre>
=={{header|C}}==
=={{header|C}}==
{{trans|Go}}
{{trans|Go}}