<?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 Basic SAS codes for Tower of Hanoi in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-codes-for-Tower-of-Hanoi/m-p/463609#M285001</link>
    <description>&lt;P&gt;Hi everyone, i am currently working on an assignment related to Tower of Hanoi. However, i am unsure about part of the codes, please feel free to check it out and provide some guidance for me, Thanks!!&lt;/P&gt;&lt;P&gt;data tofhanoi;&lt;/P&gt;&lt;P&gt;array H[5,3];&lt;/P&gt;&lt;P&gt;do i= 5 to 1 by -1;&lt;/P&gt;&lt;P&gt;H[i,1]=i;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;r3=6; r2=6; r1=1;&lt;/P&gt;&lt;P&gt;do until (r3=1); ;&lt;/P&gt;&lt;P&gt;move=0;&lt;/P&gt;&lt;P&gt;do until (move=1);&lt;/P&gt;&lt;P&gt;check=0;&lt;/P&gt;&lt;P&gt;do until (check=1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;/********************************* in here i have to input codes to pick a disk from a tower, which F is the tower number, may i ask how to accomplish here? ************************************/&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if F=1 &amp;amp; r1 ne 6 then do;&lt;/P&gt;&lt;P&gt;check=1;&lt;/P&gt;&lt;P&gt;r=r1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else if F=2 &amp;amp; r2 ne 6 then do;&lt;/P&gt;&lt;P&gt;check=1; r=r2;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else if F=3 &amp;amp; r3 ne 6 then do;&lt;/P&gt;&lt;P&gt;check=1; r=r3; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;check=0; ....... (remaining other codes)&lt;/P&gt;&lt;P&gt;Thanks for helping!&lt;/P&gt;</description>
    <pubDate>Sun, 20 May 2018 05:06:22 GMT</pubDate>
    <dc:creator>Stepkwan96</dc:creator>
    <dc:date>2018-05-20T05:06:22Z</dc:date>
    <item>
      <title>Basic SAS codes for Tower of Hanoi</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-codes-for-Tower-of-Hanoi/m-p/463609#M285001</link>
      <description>&lt;P&gt;Hi everyone, i am currently working on an assignment related to Tower of Hanoi. However, i am unsure about part of the codes, please feel free to check it out and provide some guidance for me, Thanks!!&lt;/P&gt;&lt;P&gt;data tofhanoi;&lt;/P&gt;&lt;P&gt;array H[5,3];&lt;/P&gt;&lt;P&gt;do i= 5 to 1 by -1;&lt;/P&gt;&lt;P&gt;H[i,1]=i;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;r3=6; r2=6; r1=1;&lt;/P&gt;&lt;P&gt;do until (r3=1); ;&lt;/P&gt;&lt;P&gt;move=0;&lt;/P&gt;&lt;P&gt;do until (move=1);&lt;/P&gt;&lt;P&gt;check=0;&lt;/P&gt;&lt;P&gt;do until (check=1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;/********************************* in here i have to input codes to pick a disk from a tower, which F is the tower number, may i ask how to accomplish here? ************************************/&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if F=1 &amp;amp; r1 ne 6 then do;&lt;/P&gt;&lt;P&gt;check=1;&lt;/P&gt;&lt;P&gt;r=r1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else if F=2 &amp;amp; r2 ne 6 then do;&lt;/P&gt;&lt;P&gt;check=1; r=r2;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;else if F=3 &amp;amp; r3 ne 6 then do;&lt;/P&gt;&lt;P&gt;check=1; r=r3; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;check=0; ....... (remaining other codes)&lt;/P&gt;&lt;P&gt;Thanks for helping!&lt;/P&gt;</description>
      <pubDate>Sun, 20 May 2018 05:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-codes-for-Tower-of-Hanoi/m-p/463609#M285001</guid>
      <dc:creator>Stepkwan96</dc:creator>
      <dc:date>2018-05-20T05:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS codes for Tower of Hanoi</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-codes-for-Tower-of-Hanoi/m-p/463692#M285002</link>
      <description>&lt;P&gt;It is difficult to perform recursions from within a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is&amp;nbsp;a standard solution implemented with macros.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %macro hanoi(disk, from, to, via); 
    %if &amp;amp;disk.=0 %then %return;
    %hanoi ( %eval(&amp;amp;disk.-1), &amp;amp;from., &amp;amp;via., &amp;amp;to.  );
    %put Move top disk &amp;amp;disk. from tower &amp;amp;from. to tower &amp;amp;to. ; 
    %hanoi ( %eval(&amp;amp;disk.-1), &amp;amp;via. , &amp;amp;to. , &amp;amp;from.) ;
  %mend;
  %hanoi(3,A,B,C); 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Move top disk 1 from tower A to tower B
Move top disk 2 from tower A to tower C
Move top disk 1 from tower B to tower C
Move top disk 3 from tower A to tower B
Move top disk 1 from tower C to tower A
Move top disk 2 from tower C to tower B
Move top disk 1 from tower A to tower B
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 02:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-codes-for-Tower-of-Hanoi/m-p/463692#M285002</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-05-21T02:42:55Z</dc:date>
    </item>
  </channel>
</rss>

