Alternade words: Difference between revisions

(Added Java solution)
Line 403:
{{output}}
<lang applescript>{{alternade:"benevolent", subwords:{"belt", "eve", "non"}}, {alternade:"rejuvenate", subwords:{"rune", "eva", "jet"}}}</lang>
=={{header|AWK}}==
<lang AWK>
# syntax: GAWK -f ALTERNADE_WORDS.AWK unixdict.txt
#
# sorting:
# PROCINFO["sorted_in"] is used by GAWK
# SORTTYPE is used by Thompson Automation's TAWK
#
{ arr[$0]++ }
END {
PROCINFO["sorted_in"] = "@ind_str_asc" ; SORTTYPE = 1
for (word in arr) {
leng = length(word)
if (leng < 6) {
continue
}
odd_word = even_word = ""
for (i=1; i<=leng; i++) {
if (i ~ /[13579]$/) {
odd_word = odd_word substr(word,i,1)
}
else {
even_word = even_word substr(word,i,1)
}
}
if (odd_word in arr && even_word in arr) {
printf("%-9s %-5s %-5s\n",word,odd_word,even_word)
}
}
exit(0)
}
</lang>
{{out}}
<pre>
accost acs cot
accuse acs cue
afield ail fed
agleam ala gem
alcott act lot
allele all lee
allied ale lid
alpert apr let
ambient abet min
annette ante net
apport apr pot
ariadne aide ran
assist ass sit
battle btl ate
blaine ban lie
brenda bed rna
calliope clip aloe
choose cos hoe
choosy cos hoy
claire car lie
collude clue old
effete eft fee
fabric fbi arc
fealty fat ely
fluent fun let
forwent fret own
friend fin red
george gog ere
inroad ira nod
israel ire sal
jaunty jut any
joanne jan one
lounge lug one
oriole oil roe
oswald owl sad
parrot pro art
peoria poi era
pierre per ire
poodle pol ode
pounce puc one
racial rca ail
realty rat ely
sordid sri odd
spatial sail pta
sprain sri pan
strain sri tan
strait sri tat
sturdy sud try
sweaty set way
tattle ttl ate
theorem term hoe
though tog huh
throaty tray hot
triode tid roe
triune tin rue
troupe top rue
truant tun rat
twirly til wry
</pre>
 
=={{header|C}}==
477

edits