Rebol3 Code Examplex
Alternade words
Find words whose letters can be split into alternating subsequences that each form valid words.
Rebol [
title: "Rosetta code: Alternade words"
file: %Alternade_words.r3
url: https://rosettacode.org/wiki/Alternade_words
]
words: read/lines %unixdict.txt
foreach word words [
if 6 > length? word [continue]
;; split word into odd- and even-indexed characters (1-based)
alt1: clear ""
alt2: clear ""
repeat i length? word [
append either odd? i [alt1][alt2] word/:i
]
;; check if both halves are valid words
if all [
find words alt1
find words alt2
][
printf [10 "->" -5 " "] [word alt1 alt2]
]
]Output:
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