<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Another word game in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9313#M469</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But. &lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" href="https://communities.sas.com/people/FriedEgg" id="jive-73302317077927024634803"&gt;FriedEgg&lt;/A&gt;&lt;/P&gt;&lt;P&gt;in the dictionary ( I used is the last post you gave me -------- a word game).&lt;/P&gt;&lt;P&gt;There is not word " brack".&lt;/P&gt;&lt;P&gt;So how can you change black into brack?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Sep 2011 07:44:16 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-09-21T07:44:16Z</dc:date>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9302#M458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been working on my knowledge of hash tables and to train myself I usually like to find/create puzzles.&amp;nbsp; I was thinking of something to do and I remembered a word puzzle that was created by the author of Alice and Wonderland.&amp;nbsp; It is called a &lt;A href="http://en.wikipedia.org/wiki/Word_ladder"&gt;word ladder&lt;/A&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The basic concept (from the wiki page linked above):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take two words with the same length, for instance: COLD, WARM and find the list of words that easily transform with the alteration of a single letter for form the new word.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;COLD-&amp;gt;WARM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;COLD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cord&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;card&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ward&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;WARM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a situation where a connection cannot be found in the version I remember you can scramble the letters from the last word in your ladder to form a new word and continue from that point.&amp;nbsp; As an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;COLD-&amp;gt;DRAW&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;COLD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cord&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;card&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ward&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DRAW* note that this is just an example and there is probably a way to make this connection without the scramble.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Typically the words used to for a ladder are antonyms in my experience so I challege you to create a program that can solve a ladder from BLACK-&amp;gt;WHITE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have fun!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. I have attached a copy of the unix word dictionary to help along the way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2011 21:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9302#M458</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-14T21:52:45Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9303#M459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK .Alice and Wonderland . I am coming.&lt;/P&gt;&lt;P&gt;But for your dictionary can not find a route from black to white.&lt;/P&gt;&lt;P&gt;But I found a way from cold to warm.See the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data temp;
 infile 'c:\unix-words';
 input key : $100.;
 if length(key) eq 4 then output;
run; 
%let start=cold;
%let end=warm;
data want;
 key="&amp;amp;start";
run;

%macro sub(count=);
%if&amp;nbsp; %sysfunc(mod(&amp;amp;count,4))=1 %then %do;
substr(&amp;amp;_key,1,2)||"_"||substr(&amp;amp;_key,4) as _key
%end;
%else %if %sysfunc(mod(&amp;amp;count,4))=2 %then %do;
substr(&amp;amp;_key,1,1)||"_"||substr(&amp;amp;_key,3)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,4))=3 %then %do;
"_"||substr(&amp;amp;_key,2)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,4))=0 %then %do;
substr(&amp;amp;_key,1,3)||"_" as _key
%end;


%mend sub;

%macro Alice;
proc sql;


%let up= ;
%let an=;
%let j=;
%let _key=key&amp;amp;j;
%let i=1;
%let down=key as key&amp;amp;i;


%do %until(&amp;amp;flag=Y);
%let flag=N;
create table _temp as
 select &amp;amp;up.%sub(count=&amp;amp;i)
&amp;nbsp; from want;
create table want as
 select &amp;amp;down
&amp;nbsp; from temp,_temp
&amp;nbsp;&amp;nbsp; where key like strip(_key) &amp;amp;an ;


select * from want where key&amp;amp;i = "&amp;amp;end";

%if &amp;amp;sqlobs ge 1 %then %do; %let flag=Y ;%end;

%let up=&amp;amp;up.key&amp;amp;i., ;
%let an=and key ne key&amp;amp;i;
%let j=%eval(&amp;amp;j+1);
%let _key=key&amp;amp;j;
%let i=%eval(&amp;amp;i+1);
%let down=&amp;amp;up.key as key&amp;amp;i;

%end;


quit;
%mend Alice;
options mprint mlogic symbolgen;
%Alice
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 08:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9303#M459</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-09-16T08:35:46Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9304#M460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following code is for your question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data temp;
 infile 'c:\unix-words';
 input key : $100.;
 if length(key) eq 5 then output;
run; 
%let start=black;
%let end=white;
data want;
 key="&amp;amp;start";
run;

%macro sub(count=);
%if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=1 %then %do;
substr(&amp;amp;_key,1,3)||"_"||substr(&amp;amp;_key,5) as _key
%end;
%else %if %sysfunc(mod(&amp;amp;count,5))=2 %then %do;
substr(&amp;amp;_key,1,2)||"_"||substr(&amp;amp;_key,4)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=3 %then %do;
substr(&amp;amp;_key,1,1)||"_"||substr(&amp;amp;_key,3)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=4 %then %do;
"_"||substr(&amp;amp;_key,2) as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=0 %then %do;
substr(&amp;amp;_key,1,4)||"_" as _key
%end;


%mend sub;

%macro Alice;
proc sql;

%let up= ;
%let an=;
%let j=;
%let _key=key&amp;amp;j;
%let i=1;
%let down=key as key&amp;amp;i;


%do %until(&amp;amp;flag=Y);
%let flag=N;
create table _temp as
 select &amp;amp;up.%sub(count=&amp;amp;i)
&amp;nbsp; from want;
create table want as
 select &amp;amp;down
&amp;nbsp; from temp,_temp
&amp;nbsp;&amp;nbsp; where key like strip(_key) &amp;amp;an ;


select * from want where key&amp;amp;i = "&amp;amp;end";

%if &amp;amp;sqlobs ge 1 %then %do; %let flag=Y ;%end;

%let up=&amp;amp;up.key&amp;amp;i., ;
%let an=and key ne key&amp;amp;i;
%let j=%eval(&amp;amp;j+1);
%let _key=key&amp;amp;j;
%let i=%eval(&amp;amp;i+1);
%let down=&amp;amp;up.key as key&amp;amp;i;

%end;


quit;
%mend Alice;
options mprint mlogic symbolgen;
%Alice
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 08:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9304#M460</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-09-16T08:37:11Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9305#M461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The link does indeed exist in the dictionary file provided, I manually checked all the words, if you would like I will give you the answer to the ladder to help debug.&amp;nbsp; There are 6 words in the chain.&amp;nbsp; There is also another linkage that takes 9 steps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 20:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9305#M461</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-16T20:40:16Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9306#M462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was replying to your original posting while you posted a working solution.&amp;nbsp; It finds a version in 15 steps.&amp;nbsp; Can it be optimized to find shortest ladder?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 20:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9306#M462</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-16T20:53:27Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9307#M463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I test it anyway by my hand, there is not a ladder. for black -&amp;gt; white.&lt;/P&gt;&lt;P&gt;Do you change the letter only at the first position before current letter .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;black -&amp;gt; blank &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;only change the first letter before k (i.e. c) one time,not change any one of&amp;nbsp; b , l , a&amp;nbsp; ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Sep 2011 03:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9307#M463</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-09-17T03:21:28Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9308#M464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;data temp;
 infile 'c:\unix-words';
 input key : $100.;
 if length(key) eq 5 then output;
run; 
%let start=black;
%let end=white;


%macro sub1(count=);
%if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=1 %then %do;
substr(&amp;amp;_key,1,4)||"_" as _key
%end;
%else %if %sysfunc(mod(&amp;amp;count,5))=2 %then %do;
substr(&amp;amp;_key,1,3)||"_"||substr(&amp;amp;_key,5) as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=3 %then %do;
substr(&amp;amp;_key,1,2)||"_"||substr(&amp;amp;_key,4)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=4 %then %do;
substr(&amp;amp;_key,1,1)||"_"||substr(&amp;amp;_key,3)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=0 %then %do;
"_"||substr(&amp;amp;_key,2) as _key
%end;
%mend sub1;

%macro sub2(count=);
%if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=1 %then %do;
substr(&amp;amp;_key,1,3)||"_"||substr(&amp;amp;_key,5) as _key
%end;
%else %if %sysfunc(mod(&amp;amp;count,5))=2 %then %do;
substr(&amp;amp;_key,1,2)||"_"||substr(&amp;amp;_key,4)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=3 %then %do;
substr(&amp;amp;_key,1,1)||"_"||substr(&amp;amp;_key,3)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=4 %then %do;
"_"||substr(&amp;amp;_key,2) as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=0 %then %do;
substr(&amp;amp;_key,1,4)||"_" as _key
%end;
%mend sub2;

%macro sub3(count=);
%if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=1 %then %do;
substr(&amp;amp;_key,1,2)||"_"||substr(&amp;amp;_key,4)&amp;nbsp; as _key
%end;
%else %if %sysfunc(mod(&amp;amp;count,5))=2 %then %do;
substr(&amp;amp;_key,1,1)||"_"||substr(&amp;amp;_key,3)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=3 %then %do;
"_"||substr(&amp;amp;_key,2) as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=4 %then %do;
substr(&amp;amp;_key,1,4)||"_" as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=0 %then %do;
substr(&amp;amp;_key,1,3)||"_"||substr(&amp;amp;_key,5) as _key
%end;
%mend sub3;

%macro sub4(count=);
%if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=1 %then %do;
substr(&amp;amp;_key,1,1)||"_"||substr(&amp;amp;_key,3)&amp;nbsp; as _key
%end;
%else %if %sysfunc(mod(&amp;amp;count,5))=2 %then %do;
"_"||substr(&amp;amp;_key,2) as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=3 %then %do;
substr(&amp;amp;_key,1,4)||"_" as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=4 %then %do;
substr(&amp;amp;_key,1,3)||"_"||substr(&amp;amp;_key,5) as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=0 %then %do;
substr(&amp;amp;_key,1,2)||"_"||substr(&amp;amp;_key,4)&amp;nbsp; as _key
%end;
%mend sub4;


%macro sub5(count=);
%if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=1 %then %do;
"_"||substr(&amp;amp;_key,2) as _key
%end;
%else %if %sysfunc(mod(&amp;amp;count,5))=2 %then %do;
substr(&amp;amp;_key,1,4)||"_" as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=3 %then %do;
substr(&amp;amp;_key,1,3)||"_"||substr(&amp;amp;_key,5) as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=4 %then %do;
substr(&amp;amp;_key,1,2)||"_"||substr(&amp;amp;_key,4)&amp;nbsp; as _key
%end;
%else %if&amp;nbsp; %sysfunc(mod(&amp;amp;count,5))=0 %then %do;
substr(&amp;amp;_key,1,1)||"_"||substr(&amp;amp;_key,3)&amp;nbsp; as _key
%end;
%mend sub5;


%macro Alice;
proc sql;

%do k=1 %to 1;
create table want (key char(40));
insert into want values("&amp;amp;start");
%let up= ;
%let an=;
%let j=;
%let _key=key&amp;amp;j;
%let i=1;
%let down=key as key&amp;amp;i;

%do x=1 %to 20;
create table _temp as
 select &amp;amp;up.%sub5(count=&amp;amp;i)
&amp;nbsp; from want;
create table want as
 select &amp;amp;down
&amp;nbsp; from temp,_temp
&amp;nbsp;&amp;nbsp; where key like strip(_key) &amp;amp;an ;


select * from want where key&amp;amp;i = "&amp;amp;end";

%if &amp;amp;sqlobs ge 1 %then %do; %put WARNING: Found at&amp;nbsp; iteration for key&amp;amp;i ; %abort;%end;

%let up=&amp;amp;up.key&amp;amp;i., ;
%let an=and key ne key&amp;amp;i;
%let j=%eval(&amp;amp;j+1);
%let _key=key&amp;amp;j;
%let i=%eval(&amp;amp;i+1);
%let down=&amp;amp;up.key as key&amp;amp;i;

%end;
%end;


quit;
%mend Alice;
options mprint mlogic symbolgen;
%Alice
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Sep 2011 03:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9308#M464</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-09-17T03:22:47Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9309#M465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The rule is to change only one letter per step in the ladder, it can be any letter though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BLACK&lt;/P&gt;&lt;P&gt;blank&lt;/P&gt;&lt;P&gt;blink&lt;/P&gt;&lt;P&gt;clink&lt;/P&gt;&lt;P&gt;chink&lt;/P&gt;&lt;P&gt;chine&lt;/P&gt;&lt;P&gt;whine&lt;/P&gt;&lt;P&gt;WHITE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the shortest version of the ladder I can find.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not a simple task, for sure.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Sep 2011 07:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9309#M465</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-17T07:20:36Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9310#M466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You do not change a letter step by step forward, you do skip forward, that is also included into rule?&lt;/P&gt;&lt;P&gt;But I will think about it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Sep 2011 11:40:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9310#M466</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-09-17T11:40:45Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9311#M467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link active_link" href="https://communities.sas.com/people/FriedEgg" id="jive-73302316901784763661803"&gt;FriedEgg&lt;/A&gt;&lt;/P&gt;&lt;P&gt;As your logic, it is not ladder forward but forward and backward.&lt;/P&gt;&lt;P&gt;I found another way almost like yours.&lt;/P&gt;&lt;P&gt;BLACK&lt;/P&gt;&lt;P&gt;blank&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;clank&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;clink&lt;/P&gt;&lt;P&gt;chink&lt;/P&gt;&lt;P&gt;chine&lt;/P&gt;&lt;P&gt;whine&lt;/P&gt;&lt;P&gt;WHITE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know i should make a macro for this, But I think you can do it by yourself.&lt;/P&gt;&lt;P&gt;The following is very crude code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data temp;
 infile 'c:\unix-words';
 input key : $100.;
 if length(key) eq 5 then output;
run;
%let start=black;
%let end=white;
data dict(drop=i key);
 set temp;
 array a{*} $ 1 a1-a5;
 do i=1 to dim(a);
&amp;nbsp; a{i}=substr(key,i,1);
 end;
run;
data temp(drop=i);
array a{*} $ 1 _a1-_a5;
 do i=1 to dim(a);
&amp;nbsp; a{i}=substr("&amp;amp;start",i,1);
 end;
run;
data want(keep=a:);
 set dict;
 if _n_ =1 then set temp;
 if&amp;nbsp;&amp;nbsp;&amp;nbsp; (a2=_a2 and a3=_a3 and a4=_a4 and a5=_a5 and a1 ne _a1) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a3=_a3 and a4=_a4 and a5=_a5 and a2 ne _a2) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a4=_a4 and a5=_a5 and a3 ne _a3) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a5=_a5 and a4 ne _a4) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a4=_a4 and a5 ne _a5);
run;
data want1;
&amp;nbsp;&amp;nbsp; set dict;
do i=1 to _nobs;
set want(keep=a: rename=(a1=_a1 a2=_a2 a3=_a3 a4=_a4 a5=_a5)) nobs=_nobs point=i;
if&amp;nbsp;&amp;nbsp;&amp;nbsp; (a2=_a2 and a3=_a3 and a4=_a4 and a5=_a5 and a1 ne _a1) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a3=_a3 and a4=_a4 and a5=_a5 and a2 ne _a2) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a4=_a4 and a5=_a5 and a3 ne _a3) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a5=_a5 and a4 ne _a4) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a4=_a4 and a5 ne _a5) then output;
end;
run;
proc sort data=want1 nodupkey;
 by _all_;
run;

data want2;
&amp;nbsp;&amp;nbsp; set dict;
do i=1 to _nobs;
set want1(keep=a: rename=(a1=_a1 a2=_a2 a3=_a3 a4=_a4 a5=_a5)) nobs=_nobs point=i;
if&amp;nbsp;&amp;nbsp;&amp;nbsp; (a2=_a2 and a3=_a3 and a4=_a4 and a5=_a5 and a1 ne _a1) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a3=_a3 and a4=_a4 and a5=_a5 and a2 ne _a2) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a4=_a4 and a5=_a5 and a3 ne _a3) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a5=_a5 and a4 ne _a4) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a4=_a4 and a5 ne _a5) then output;
end;
run;

proc sort data=want2 nodupkey;
 by _all_;
run;
data want3;
&amp;nbsp;&amp;nbsp; set dict;
do i=1 to _nobs;
set want2(keep=a: rename=(a1=_a1 a2=_a2 a3=_a3 a4=_a4 a5=_a5)) nobs=_nobs point=i;
if&amp;nbsp;&amp;nbsp;&amp;nbsp; (a2=_a2 and a3=_a3 and a4=_a4 and a5=_a5 and a1 ne _a1) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a3=_a3 and a4=_a4 and a5=_a5 and a2 ne _a2) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a4=_a4 and a5=_a5 and a3 ne _a3) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a5=_a5 and a4 ne _a4) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a4=_a4 and a5 ne _a5) then output;
end;
run;
proc sort data=want3 nodupkey;
 by _all_;
run;
data want4;
&amp;nbsp;&amp;nbsp; set dict;
do i=1 to _nobs;
set want3(keep=a: rename=(a1=_a1 a2=_a2 a3=_a3 a4=_a4 a5=_a5)) nobs=_nobs point=i;
if&amp;nbsp;&amp;nbsp;&amp;nbsp; (a2=_a2 and a3=_a3 and a4=_a4 and a5=_a5 and a1 ne _a1) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a3=_a3 and a4=_a4 and a5=_a5 and a2 ne _a2) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a4=_a4 and a5=_a5 and a3 ne _a3) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a5=_a5 and a4 ne _a4) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a4=_a4 and a5 ne _a5) then output;
end;
run;
proc sort data=want4 nodupkey;
 by _all_;
run;
data want5;
&amp;nbsp;&amp;nbsp; set dict;
do i=1 to _nobs;
set want4(keep=a: rename=(a1=_a1 a2=_a2 a3=_a3 a4=_a4 a5=_a5)) nobs=_nobs point=i;
if&amp;nbsp;&amp;nbsp;&amp;nbsp; (a2=_a2 and a3=_a3 and a4=_a4 and a5=_a5 and a1 ne _a1) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a3=_a3 and a4=_a4 and a5=_a5 and a2 ne _a2) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a4=_a4 and a5=_a5 and a3 ne _a3) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a5=_a5 and a4 ne _a4) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a4=_a4 and a5 ne _a5) then output;
end;
run;
proc sort data=want5 nodupkey;
 by _all_;
run;
data want6;
&amp;nbsp;&amp;nbsp; set dict;
do i=1 to _nobs;
set want5(keep=a: rename=(a1=_a1 a2=_a2 a3=_a3 a4=_a4 a5=_a5)) nobs=_nobs point=i;
if&amp;nbsp;&amp;nbsp;&amp;nbsp; (a2=_a2 and a3=_a3 and a4=_a4 and a5=_a5 and a1 ne _a1) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a3=_a3 and a4=_a4 and a5=_a5 and a2 ne _a2) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a4=_a4 and a5=_a5 and a3 ne _a3) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a5=_a5 and a4 ne _a4) or
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (a1=_a1 and a2=_a2 and a3=_a3 and a4=_a4 and a5 ne _a5) then output;
end;
run;
proc sort data=want6 nodupkey;
 by _all_;
run;
















data&amp;nbsp; want5;set&amp;nbsp; want5(rename=(_a1-_a5=__a1 - __a5&amp;nbsp; ));run;
data&amp;nbsp; want5;set&amp;nbsp; want5(rename=(&amp;nbsp; a1-a5=_a1-_a5&amp;nbsp; ));run;
proc sort data=want6 out=result;
 by _:;
run;
data result;
 merge result want5;
 by _a1 - _a5;
run;

data&amp;nbsp; want4;set&amp;nbsp; want4(rename=(_a1-_a5=___a1 - ___a5&amp;nbsp; ));run;
data&amp;nbsp; want4;set&amp;nbsp; want4(rename=(&amp;nbsp; a1-a5=__a1-__a5&amp;nbsp; ));run;
proc sort data=result;
 by __:;
run;
data result;
 merge result want4;
 by __a1 - __a5;
run;

data&amp;nbsp; want3;set&amp;nbsp; want3(rename=(_a1-_a5=____a1 - ____a5&amp;nbsp; ));run;
data&amp;nbsp; want3;set&amp;nbsp; want3(rename=(&amp;nbsp; a1-a5=___a1-___a5&amp;nbsp; ));run;
proc sort data=result;
 by ___:;
run;
data result;
 merge result want3;
 by ___a1 - ___a5;
run;

data&amp;nbsp; want2;set&amp;nbsp; want2(rename=(_a1-_a5=_____a1 - _____a5&amp;nbsp; ));run;
data&amp;nbsp; want2;set&amp;nbsp; want2(rename=(&amp;nbsp; a1-a5=____a1-____a5&amp;nbsp; ));run;
proc sort data=result;
 by ____:;
run;
data result;
 merge result want2;
 by ____a1 - ____a5;
run;

data&amp;nbsp; want1;set&amp;nbsp; want1(rename=(_a1-_a5=______a1 - ______a5&amp;nbsp; ));run;
data&amp;nbsp; want1;set&amp;nbsp; want1(rename=(&amp;nbsp; a1-a5=_____a1-_____a5&amp;nbsp; ));run;
proc sort data=result;
 by _____:;
run;
data result;
 merge result want1;
 by _____a1 - _____a5;
run;

data final_result(keep=word:);
 set result;
 word1=cats(of a:);
 word2=cats(of _a:);
 word3=cats(of __a:);
 word4=cats(of ___a:);
 word5=cats(of ____a:);
 word6=cats(of _____a:);
 word7=cats(of ______a:);
 if word1="&amp;amp;end";
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2011 10:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9311#M467</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-09-19T10:19:21Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9312#M468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did not thoroughly check my code but this is what I had come up with.&amp;nbsp; Very similar to KSharp's approach.&amp;nbsp; I am going to take some time later and convert this to using hash objects as that is the ultimate personal goal of the challenge for myself.&amp;nbsp; I am fairly certain that my example with only find odd number length ladders since I am approaching from both sides to save time with the size of the cartesian joins, which is obviously a problem to also fix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options fullstimer spool macrogen mlogic mprint;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let from=black;&lt;/P&gt;&lt;P&gt;%let to=white;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; /* rule 1: the from and to words must be the same length */&lt;/P&gt;&lt;P&gt; if length("&amp;amp;from") ne length("&amp;amp;to") then &lt;/P&gt;&lt;P&gt;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put 'ERROR: FROM AND TO MUST BE SAME LENGTH';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; abort return;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt; else&lt;/P&gt;&lt;P&gt;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symput("len",length("&amp;amp;from"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symput("from",%upcase("&amp;amp;from"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symput("to",%upcase("&amp;amp;to"));&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dict;&lt;/P&gt;&lt;P&gt; infile '/usr/share/dict/words';&lt;/P&gt;&lt;P&gt; input word :$upcase40.;&lt;/P&gt;&lt;P&gt; if length(word)=&amp;amp;len and word=compress(word,,'ka') then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=dict nodupkey; by word; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* streaminit */&lt;/P&gt;&lt;P&gt;data step1;&lt;/P&gt;&lt;P&gt; length start $40;&lt;/P&gt;&lt;P&gt; set dict;&lt;/P&gt;&lt;P&gt; where complev("&amp;amp;from",word,'i')=1;&lt;/P&gt;&lt;P&gt; start="&amp;amp;from";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _step1;&lt;/P&gt;&lt;P&gt; length end $40;&lt;/P&gt;&lt;P&gt; set dict;&lt;/P&gt;&lt;P&gt; where complev("&amp;amp;to",word,'i')=1;&lt;/P&gt;&lt;P&gt; end="&amp;amp;to";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* loop */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro ladder;&lt;/P&gt;&lt;P&gt; %let done=N;&lt;/P&gt;&lt;P&gt; %let i=1;&lt;/P&gt;&lt;P&gt; %do %until (&amp;amp;done=Y);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let n=%eval(&amp;amp;i+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; data step&amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set dict;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to _nobs;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set step&amp;amp;i(rename=(word=step&amp;amp;i)) nobs=_nobs point=i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if complev(step&amp;amp;i,word)=1 and word ne start %if &amp;amp;i&amp;gt;1 %then %do j=1 %to %eval(&amp;amp;i-1); and word ne step&amp;amp;j %end; then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data _step&amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set dict;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to _nobs;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set _step&amp;amp;i(rename=(word=_step&amp;amp;i)) nobs=_nobs point=i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if complev(_step&amp;amp;i,word)=1 and word ne end %if &amp;amp;i&amp;gt;1 %then %do j=1 %to %eval(&amp;amp;i-1); and word ne _step&amp;amp;j %end; then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* FIX: probably want to better name variables so order can be recognized */&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* start -&amp;gt; step1 -&amp;gt; stepn -&amp;gt; word -&amp;gt; _stepn -&amp;gt; _step1 -&amp;gt; end */&lt;/P&gt;&lt;P&gt;&amp;nbsp; data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; merge step&amp;amp;n(in=b) _step&amp;amp;n(in=a);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by word;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if a and b;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select nobs into :nobs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sashelp.vtable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='WANT';&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let i=%eval(&amp;amp;i+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if &amp;amp;nobs&amp;gt;0 %then %let done=Y;&lt;/P&gt;&lt;P&gt; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%ladder&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code was able to find solution in 5 ladder steps.&amp;nbsp; The solution I had posted earlier as the example solution I had solved manually.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BLACK&lt;/P&gt;&lt;P&gt;1. brack&lt;/P&gt;&lt;P&gt;2. brace&lt;/P&gt;&lt;P&gt;3. brice&lt;/P&gt;&lt;P&gt;4. brite&lt;/P&gt;&lt;P&gt;5. write&lt;/P&gt;&lt;P&gt;WHITE&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2011 21:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9312#M468</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-19T21:20:02Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9313#M469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But. &lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" href="https://communities.sas.com/people/FriedEgg" id="jive-73302317077927024634803"&gt;FriedEgg&lt;/A&gt;&lt;/P&gt;&lt;P&gt;in the dictionary ( I used is the last post you gave me -------- a word game).&lt;/P&gt;&lt;P&gt;There is not word " brack".&lt;/P&gt;&lt;P&gt;So how can you change black into brack?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 07:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9313#M469</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-09-21T07:44:16Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9314#M470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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.&amp;nbsp; I am using dictionary file that is built into my OS and I guess it is slightly different.&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options fullstimer mlogic mprint;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let from=black;&lt;/P&gt;&lt;P&gt;%let to=white;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; if length("&amp;amp;from") ne length("&amp;amp;to") then&lt;/P&gt;&lt;P&gt;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put 'ERROR: FROM AND TO MUST BE SAME LENGTH';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; abort return;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt; else if complev("&amp;amp;from","&amp;amp;to",'i')=1 then&lt;/P&gt;&lt;P&gt;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put 'ERROR: FROM AND TO ARE ALREADY 1 STEP APART';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; abort return;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt; else&lt;/P&gt;&lt;P&gt;&amp;nbsp; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symput("len",length("&amp;amp;from"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symput("from",%upcase("&amp;amp;from"));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call symput("to",%upcase("&amp;amp;to"));&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dict;&lt;/P&gt;&lt;P&gt;infile '/nas/sasbox/users/mkastin/unix-words';&lt;/P&gt;&lt;P&gt;input word :$upcase40.;&lt;/P&gt;&lt;P&gt;if length(word)=&amp;amp;len and word=compress(word,,'ka') then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=dict nodupkey; by word; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data step1;&lt;/P&gt;&lt;P&gt;length start $40;&lt;/P&gt;&lt;P&gt;set dict;&lt;/P&gt;&lt;P&gt;where complev("&amp;amp;from",word,'i')=1;&lt;/P&gt;&lt;P&gt;start="&amp;amp;from";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _step1;&lt;/P&gt;&lt;P&gt;length end $40;&lt;/P&gt;&lt;P&gt;set dict;&lt;/P&gt;&lt;P&gt;where complev("&amp;amp;to",word,'i')=1;&lt;/P&gt;&lt;P&gt;end="&amp;amp;to";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* loop */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro solve(in1,in2);&lt;/P&gt;&lt;P&gt; data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge &amp;amp;in1(in=b) &amp;amp;in2(in=a);&lt;/P&gt;&lt;P&gt;&amp;nbsp; by word;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if a and b;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select nobs into :nobs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sashelp.vtable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where libname='WORK' and memname='WANT';&lt;/P&gt;&lt;P&gt; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; %if &amp;amp;nobs&amp;gt;0 %then %let done=Y;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro ladder;&lt;/P&gt;&lt;P&gt; %let done=N;&lt;/P&gt;&lt;P&gt; %let i=1;&lt;/P&gt;&lt;P&gt; %do %until (&amp;amp;done=Y);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let n=%eval(&amp;amp;i+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; data step&amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set dict;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to _nobs;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set step&amp;amp;i(rename=(word=step&amp;amp;i)) nobs=_nobs point=i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if complev(step&amp;amp;i,word)=1 and word ne start %if &amp;amp;i&amp;gt;1 %then %do j=1 %to %eval(&amp;amp;i-1); and word ne step&amp;amp;j %end; then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %solve(_step&amp;amp;i,step&amp;amp;n); &lt;/P&gt;&lt;P&gt;&amp;nbsp; %if &amp;amp;done=Y %then %goto exit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data _step&amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set dict;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to _nobs;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set _step&amp;amp;i(rename=(word=_step&amp;amp;i)) nobs=_nobs point=i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if complev(_step&amp;amp;i,word)=1 and word ne end %if &amp;amp;i&amp;gt;1 %then %do j=1 %to %eval(&amp;amp;i-1); and word ne _step&amp;amp;j %end; then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %solve(step&amp;amp;n,_step&amp;amp;n)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let i=%eval(&amp;amp;i+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %exit:&lt;/P&gt;&lt;P&gt; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%ladder&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BLACK&lt;/P&gt;&lt;P&gt;1. blank&lt;/P&gt;&lt;P&gt;2. blink or clank&lt;/P&gt;&lt;P&gt;3. clink&lt;/P&gt;&lt;P&gt;4. chink&lt;/P&gt;&lt;P&gt;5. chine&lt;/P&gt;&lt;P&gt;6. whine&lt;/P&gt;&lt;P&gt;WHITE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHITE&lt;/P&gt;&lt;P&gt;1. whine&lt;/P&gt;&lt;P&gt;2. chine&lt;/P&gt;&lt;P&gt;3. chink&lt;/P&gt;&lt;P&gt;4. chick&lt;/P&gt;&lt;P&gt;5. check&lt;/P&gt;&lt;P&gt;6. cheek&lt;/P&gt;&lt;P&gt;7. creek&lt;/P&gt;&lt;P&gt;8. greek&lt;/P&gt;&lt;P&gt;GREEN&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 18:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9314#M470</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-09-21T18:20:44Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9315#M471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This isn't the tidiest code, but it's a brute-force method of finding all solutions within a given number of steps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On my PC it takes about 6 minutes to run end to end, and produces 286 solutions to a maximum of 10 steps.&amp;nbsp; Obviously adding additional steps will exponentially increase the running time, although I'm sure there's room for some efficiency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I originally wrote the comparison of words by using a series of SQL like statements (e.g. like '%lack' or like 'b%ack' or like 'bl%ck' etc.), but after reading your code I realised I'd forgotten complev, which reduced the overall running time by about 60%.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;datetime = put(datetime(),datetime20.);&lt;/P&gt;&lt;P&gt;putlog datetime=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let start=black;&lt;/P&gt;&lt;P&gt;%let end=white;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;start.;&lt;/P&gt;&lt;P&gt;%put &amp;amp;end.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data words;&lt;/P&gt;&lt;P&gt;infile 'c:\unix-words';&lt;/P&gt;&lt;P&gt;format word $100.;&lt;/P&gt;&lt;P&gt;input word $;&lt;/P&gt;&lt;P&gt;if length(word) = length("&amp;amp;start.") then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro wordchain();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let max_links = 10;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table wordchain_1 as&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;0 as found,&lt;/P&gt;&lt;P&gt;words.word as word_1&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;words&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;words.word = "&amp;amp;start.";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i = 2 %to &amp;amp;max_links;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;i.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let j = %eval(&amp;amp;i - 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;j.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table wordchain_&amp;amp;i. as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (wordchain_&amp;amp;j..found or words.word = "&amp;amp;end.") as found,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wordchain_&amp;amp;j..*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; words.word as word_&amp;amp;i.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wordchain_&amp;amp;j.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join words on&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; complev(wordchain_&amp;amp;j..word_&amp;amp;j.,words.word,"il") = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do n = 1 %to &amp;amp;j.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;n &amp;gt; 1 %then and;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; words.word ~= wordchain_&amp;amp;j..word_&amp;amp;n.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and wordchain_&amp;amp;j..word_&amp;amp;j. ~= "&amp;amp;end."&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp; and length(words.word) = length("&amp;amp;end.")*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; calculated found&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or (not (calculated found) and words.word is not missing)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%leave:;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%wordchain();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data solutions;&lt;/P&gt;&lt;P&gt;set wordchain_10;&lt;/P&gt;&lt;P&gt;where found = 1;&lt;/P&gt;&lt;P&gt;array words{*} word_1-word_10;&lt;/P&gt;&lt;P&gt;count = 0;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(words);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing(words{i}) then leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = count + 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=solutions;&lt;/P&gt;&lt;P&gt;by count;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;datetime = put(datetime(),datetime20.);&lt;/P&gt;&lt;P&gt;putlog datetime=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 22:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9315#M471</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-09-23T22:45:53Z</dc:date>
    </item>
    <item>
      <title>Another word game</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9316#M472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bit of an improvement on the previous version.&amp;nbsp; This takes about 10 seconds to run on my PC, again for 10 steps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Changes were:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;reduce the format length stored down from 100, to whatever is required to store the current words&lt;/LI&gt;&lt;LI&gt;add complev's limiter at 2 (i.e. stops counting the difference once it hits 2).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That got me about 50% saving.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then realised I could calculate all permutations of X-letter words prior to the looping, which pretty much trivialised the running time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;datetime = put(datetime(),datetime20.);&lt;/P&gt;&lt;P&gt;putlog datetime=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let start=black;&lt;/P&gt;&lt;P&gt;%let end=white;&lt;/P&gt;&lt;P&gt;%let max_links = 10;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;start.;&lt;/P&gt;&lt;P&gt;%put &amp;amp;end.;&lt;/P&gt;&lt;P&gt;%put &amp;amp;max_links.; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data words;&lt;/P&gt;&lt;P&gt;infile 'c:\unix-words';&lt;/P&gt;&lt;P&gt;format word $22.;&lt;/P&gt;&lt;P&gt;input word $;&lt;/P&gt;&lt;P&gt;if length(word) = length("&amp;amp;start.") then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data words;&lt;/P&gt;&lt;P&gt;format word $%length(&amp;amp;start.).;&lt;/P&gt;&lt;P&gt;set words;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table wordlinks as&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;monotonic() as n format 8.,&lt;/P&gt;&lt;P&gt;words.word as old_word,&lt;/P&gt;&lt;P&gt;words2.word as new_word&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;words,&lt;/P&gt;&lt;P&gt;words as words2&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;complev(words.word,words2.word,2,"il") = 1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro wordchain();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table wordchain_1 as&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;0 as found,&lt;/P&gt;&lt;P&gt;words.word as word_1&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;words&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;words.word = "&amp;amp;start.";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i = 2 %to &amp;amp;max_links;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;i.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let j = %eval(&amp;amp;i - 1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;j.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table wordchain_&amp;amp;i. as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (wordchain_&amp;amp;j..found or wordlinks.new_word = "&amp;amp;end.") as found,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wordchain_&amp;amp;j..*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wordlinks.new_word as word_&amp;amp;i.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wordchain_&amp;amp;j.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join wordlinks on&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wordchain_&amp;amp;j..word_&amp;amp;j = wordlinks.old_word&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do n = 1 %to &amp;amp;j.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;n &amp;gt; 1 %then and;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wordlinks.new_word ~= wordchain_&amp;amp;j..word_&amp;amp;n.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and wordchain_&amp;amp;j..word_&amp;amp;j. ~= "&amp;amp;end."&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp; and length(words.word) = length("&amp;amp;end.")*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; calculated found&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or (not (calculated found) and wordlinks.old_word is not missing)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%leave:;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%wordchain();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data solutions;&lt;/P&gt;&lt;P&gt;set wordchain_&amp;amp;max_links.;&lt;/P&gt;&lt;P&gt;where found = 1;&lt;/P&gt;&lt;P&gt;array words{*} word_1-word_&amp;amp;max_links.;&lt;/P&gt;&lt;P&gt;count = 0;&lt;/P&gt;&lt;P&gt;do i = 1 to dim(words);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing(words{i}) then leave;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = count + 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=solutions;&lt;/P&gt;&lt;P&gt;by count;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;datetime = put(datetime(),datetime20.);&lt;/P&gt;&lt;P&gt;putlog datetime=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Sep 2011 11:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Another-word-game/m-p/9316#M472</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-09-24T11:51:43Z</dc:date>
    </item>
  </channel>
</rss>

