Anonymous user
Word ladder: Difference between revisions
m
→{{header|REXX}}: added words to the REXX section header.
(→{{header|REXX}}: added the computer programming language REXX.) |
m (→{{header|REXX}}: added words to the REXX section header.) |
||
Line 276:
It also assumes that the dictionary file is in mixed case as well as the words entered on the CL.
To treat the dictionary and input words as caseless, all words are translated to lowercase.
Programming note: this REXX program uses the '''lower''' BIF which Regina has).
Line 292 ⟶ 294:
L= length(base) /*length of the BASE (in characters). */
if L<2 then call err 'base word is too small or missing' /*oops, too small*/
if length(targ)\==L then call
call letters /*assign letters, faster than SUBSTR. */
#= 0 /*# of words whose length matches BASE.*/
@.= /*default value of any dictionary word.*/
!.= 0
say copies('─', 30) recs "words in the dictionary file: " iFID
Line 309 ⟶ 310:
rung= targ
$= base
do f=1 for
end /*f*/
say
if f>
do f-2;
end /*forever*/
end /*f-2*/
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
show:
letters:
/*──────────────────────────────────────────────────────────────────────────────────────*/
look: procedure expose @. !. a. $ abc
$$=;
do i=1 for words($);
do k=1 for L
do n=1 for 26; z= overlay(a.n, y, k) /*change a letter*/
Line 335 ⟶ 334:
if !.z then iterate /* " " a repeat? " " " */
if z==rungs then rung= y rung /*prepend a word to the rung list. */
if z==rungs &
if z==targ then return z
$$= $$ z /*append a possible ladder word to $$*/
Line 357 ⟶ 356:
<pre>
────────────────────────────── 25104 words in the dictionary file: unixdict.txt
────────────────────────────── 2187 words in the dictionary file of length:
────────────────────────────── base word is: girl
────────────────────────────── target word is: lady
Line 373 ⟶ 372:
<pre>
────────────────────────────── 25104 words in the dictionary file: unixdict.txt
────────────────────────────── 2187 words in the dictionary file of length:
────────────────────────────── base word is: john
────────────────────────────── target word is: jane
Line 387 ⟶ 386:
<pre>
────────────────────────────── 25104 words in the dictionary file: unixdict.txt
────────────────────────────── 3161 words in the dictionary file of length:
────────────────────────────── base word is: child
────────────────────────────── target word is: adult
|