I downloaded that dictionary from the internet, it claimed to be a distributable copy of the unix dictionary file but I guess it is not identical. I am using dictionary file that is built into my OS and I guess it is slightly different. I changed to use the same file and also fixed the issue with my program only finding solutions in odd number of steps in length. options fullstimer mlogic mprint; %let from=black; %let to=white; data _null_; if length("&from") ne length("&to") then do; put 'ERROR: FROM AND TO MUST BE SAME LENGTH'; abort return; end; else if complev("&from","&to",'i')=1 then do; put 'ERROR: FROM AND TO ARE ALREADY 1 STEP APART'; abort return; end; else do; call symput("len",length("&from")); call symput("from",%upcase("&from")); call symput("to",%upcase("&to")); end; run; data dict; infile '/nas/sasbox/users/mkastin/unix-words'; input word :$upcase40.; if length(word)=&len and word=compress(word,,'ka') then output; run; proc sort data=dict nodupkey; by word; run; data step1; length start $40; set dict; where complev("&from",word,'i')=1; start="&from"; run; data _step1; length end $40; set dict; where complev("&to",word,'i')=1; end="&to"; run; /* loop */ %macro solve(in1,in2); data want; merge &in1(in=b) &in2(in=a); by word; if a and b; run; proc sql noprint; select nobs into :nobs from sashelp.vtable where libname='WORK' and memname='WANT'; quit; %if &nobs>0 %then %let done=Y; %mend; %macro ladder; %let done=N; %let i=1; %do %until (&done=Y); %let n=%eval(&i+1); data step&n; set dict; do i=1 to _nobs; set step&i(rename=(word=step&i)) nobs=_nobs point=i; if complev(step&i,word)=1 and word ne start %if &i>1 %then %do j=1 %to %eval(&i-1); and word ne step&j %end; then output; end; run; %solve(_step&i,step&n); %if &done=Y %then %goto exit; data _step&n; set dict; do i=1 to _nobs; set _step&i(rename=(word=_step&i)) nobs=_nobs point=i; if complev(_step&i,word)=1 and word ne end %if &i>1 %then %do j=1 %to %eval(&i-1); and word ne _step&j %end; then output; end; run; %solve(step&n,_step&n) %let i=%eval(&i+1); %exit: %end; %mend; %ladder BLACK 1. blank 2. blink or clank 3. clink 4. chink 5. chine 6. whine WHITE WHITE 1. whine 2. chine 3. chink 4. chick 5. check 6. cheek 7. creek 8. greek GREEN
... View more