<?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 Play Chutes and Ladders with me in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57456#M12400</link>
    <description>&lt;P&gt;Chutes and Ladders is a board game during which one or more players, moving alternately, move their tokens along the numbered spaces on the board according to the roll of a single six-sided die; the tokens are initially off-the-board at what is effectively space zero.&amp;nbsp; Landing on a space with the bottom of a ladder promotes the token to the space at the top of said ladder.&amp;nbsp; Landing on a space at the top of a chute demotes the token to the space at the bottom of the chute.&amp;nbsp; The goal is to reach space 100, exactly; if the roll of the die would take the token past space 100, the token remains where it is and play passes to the next player.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="border-style: initial; border-color: initial; width: 344px; height: 258px;" class="jive-image" src="http://artsandgamecraft.files.wordpress.com/2010/06/chutes-and-ladders-1.jpg" border="0" alt="http://artsandgamecraft.files.wordpress.com/2010/06/chutes-and-ladders-1.jpg" width="344" height="258" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. What is the minimum number of rolls required to reach space 100?&lt;/P&gt;
&lt;P&gt;2. For a single player, what is the average number of rolls required to reach space 100?&lt;/P&gt;
&lt;P&gt;3. For &lt;EM&gt;n&lt;/EM&gt; players, what is the average number of rolls until one of the players reaches space 100 and ends the game?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also do this for the predecessor of the chutes and ladder game called Vaikuntapaali or Paramapada Sopanam from India in the 16th century.&amp;nbsp; It has the same basic rules however the total number of spaces and locations of the chutes/snakes and ladders are different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="width: 378px; height: 441.78232286340403px;" class="jive-image" src="http://artsandgamecraft.files.wordpress.com/2010/06/vaikuntapali.jpg" border="0" alt="http://artsandgamecraft.files.wordpress.com/2010/06/vaikuntapali.jpg" width="378" height="441" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SPOILER:&amp;nbsp; Below is my obscured answer.... Don't cheat &lt;IMG id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;LI-SPOILER&gt;&lt;LI-CODE lang="sas"&gt;%let games=10000;

*number of games to play;
%let players=1;

*number of playersplaying;
data transitions;
  input from to @@;
  cards;
1 38 4 14 9 31
16 6
21 42 28 84
36 44
47 26 49 11
51 67 56 53
62 19 64 60
71 91 80 100
87 24
93 73 95 75 98 78
;
run;

data _null_;
  length from to game ps rolls roll tot avg 8;
  declare hash ha(dataset:'transitions');
  ha.definekey('from');
  ha.definedata(all:'y');
  ha.definedone();
  declare hash ga(ordered:'a');
  ga.definekey('rolls','game');
  ga.definedata('game','rolls');
  ga.definedone();

  do game=1 to &amp;amp;games*&amp;amp;players;
    ps=0;

    *present space;
    rolls=0;

    do until(ps=100);
      roll=rand('table',1/6,1/6,1/6,1/6,1/6,1/6);

      if ps+roll&amp;lt;=100 then
        do;
          ps+roll;

          if ha.find(key:ps)=0 then
            ps=to;
        end;

      rolls+1;
    end;

    ga.add();
  end;

  declare hiter iter('ga');
  tot=0;
  iter.first();
  put 'Shortest game:' game= rolls=;

  do while(iter.next()=0);
    tot+rolls;
  end;

  avg=tot/(&amp;amp;games*&amp;amp;players);
  put 'Longest game:' game= rolls=;
  put 'Average length:' avg=;
run;&lt;/LI-CODE&gt;&amp;nbsp;&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not properly induce logic for calculating the results of games with multiple players, but logically it is not difficult to desern that generally as the number of players increases, the chance to beat the average game length increases and so the average length for more players should decrease relative to the average for a single player...&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="chutes-and-ladders-1[1].jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/11208i8DE1853F58A16A4C/image-size/large?v=v2&amp;amp;px=999" role="button" title="chutes-and-ladders-1[1].jpg" alt="chutes-and-ladders-1[1].jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vaikuntapali[1].jpg" style="width: 855px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/11209i896AD8B933353DB0/image-size/large?v=v2&amp;amp;px=999" role="button" title="vaikuntapali[1].jpg" alt="vaikuntapali[1].jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jul 2025 22:55:56 GMT</pubDate>
    <dc:creator>FriedEgg</dc:creator>
    <dc:date>2025-07-21T22:55:56Z</dc:date>
    <item>
      <title>Play Chutes and Ladders with me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57456#M12400</link>
      <description>&lt;P&gt;Chutes and Ladders is a board game during which one or more players, moving alternately, move their tokens along the numbered spaces on the board according to the roll of a single six-sided die; the tokens are initially off-the-board at what is effectively space zero.&amp;nbsp; Landing on a space with the bottom of a ladder promotes the token to the space at the top of said ladder.&amp;nbsp; Landing on a space at the top of a chute demotes the token to the space at the bottom of the chute.&amp;nbsp; The goal is to reach space 100, exactly; if the roll of the die would take the token past space 100, the token remains where it is and play passes to the next player.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="border-style: initial; border-color: initial; width: 344px; height: 258px;" class="jive-image" src="http://artsandgamecraft.files.wordpress.com/2010/06/chutes-and-ladders-1.jpg" border="0" alt="http://artsandgamecraft.files.wordpress.com/2010/06/chutes-and-ladders-1.jpg" width="344" height="258" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. What is the minimum number of rolls required to reach space 100?&lt;/P&gt;
&lt;P&gt;2. For a single player, what is the average number of rolls required to reach space 100?&lt;/P&gt;
&lt;P&gt;3. For &lt;EM&gt;n&lt;/EM&gt; players, what is the average number of rolls until one of the players reaches space 100 and ends the game?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also do this for the predecessor of the chutes and ladder game called Vaikuntapaali or Paramapada Sopanam from India in the 16th century.&amp;nbsp; It has the same basic rules however the total number of spaces and locations of the chutes/snakes and ladders are different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="width: 378px; height: 441.78232286340403px;" class="jive-image" src="http://artsandgamecraft.files.wordpress.com/2010/06/vaikuntapali.jpg" border="0" alt="http://artsandgamecraft.files.wordpress.com/2010/06/vaikuntapali.jpg" width="378" height="441" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SPOILER:&amp;nbsp; Below is my obscured answer.... Don't cheat &lt;IMG id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;LI-SPOILER&gt;&lt;LI-CODE lang="sas"&gt;%let games=10000;

*number of games to play;
%let players=1;

*number of playersplaying;
data transitions;
  input from to @@;
  cards;
1 38 4 14 9 31
16 6
21 42 28 84
36 44
47 26 49 11
51 67 56 53
62 19 64 60
71 91 80 100
87 24
93 73 95 75 98 78
;
run;

data _null_;
  length from to game ps rolls roll tot avg 8;
  declare hash ha(dataset:'transitions');
  ha.definekey('from');
  ha.definedata(all:'y');
  ha.definedone();
  declare hash ga(ordered:'a');
  ga.definekey('rolls','game');
  ga.definedata('game','rolls');
  ga.definedone();

  do game=1 to &amp;amp;games*&amp;amp;players;
    ps=0;

    *present space;
    rolls=0;

    do until(ps=100);
      roll=rand('table',1/6,1/6,1/6,1/6,1/6,1/6);

      if ps+roll&amp;lt;=100 then
        do;
          ps+roll;

          if ha.find(key:ps)=0 then
            ps=to;
        end;

      rolls+1;
    end;

    ga.add();
  end;

  declare hiter iter('ga');
  tot=0;
  iter.first();
  put 'Shortest game:' game= rolls=;

  do while(iter.next()=0);
    tot+rolls;
  end;

  avg=tot/(&amp;amp;games*&amp;amp;players);
  put 'Longest game:' game= rolls=;
  put 'Average length:' avg=;
run;&lt;/LI-CODE&gt;&amp;nbsp;&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not properly induce logic for calculating the results of games with multiple players, but logically it is not difficult to desern that generally as the number of players increases, the chance to beat the average game length increases and so the average length for more players should decrease relative to the average for a single player...&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="chutes-and-ladders-1[1].jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/11208i8DE1853F58A16A4C/image-size/large?v=v2&amp;amp;px=999" role="button" title="chutes-and-ladders-1[1].jpg" alt="chutes-and-ladders-1[1].jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vaikuntapali[1].jpg" style="width: 855px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/11209i896AD8B933353DB0/image-size/large?v=v2&amp;amp;px=999" role="button" title="vaikuntapali[1].jpg" alt="vaikuntapali[1].jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2025 22:55:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57456#M12400</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2025-07-21T22:55:56Z</dc:date>
    </item>
    <item>
      <title>Play Chutes and Ladders with me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57457#M12401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your solution is missing something. When I execute it in 9.3, I get the following in my log: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Variable from is uninitialized.&lt;/P&gt;&lt;P&gt;NOTE: Variable to is uninitialized.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Dec 2011 02:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57457#M12401</guid>
      <dc:creator>gfarkas</dc:creator>
      <dc:date>2011-12-03T02:11:44Z</dc:date>
    </item>
    <item>
      <title>Play Chutes and Ladders with me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57458#M12402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; This is not a real issue.&amp;nbsp; It is more of a by-product of how I chose to initialize my scalar elements for the hash object.&amp;nbsp; It you wanted to remove these notes you could do either of the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="mcePaste" id="_mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;"&gt;﻿&lt;/DIV&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;length from to game ps rolls roll tot avg 8;&lt;/P&gt;&lt;P&gt;declare hash ha(dataset:'transitions');&lt;/P&gt;&lt;P&gt;ha.definekey('from');&lt;/P&gt;&lt;P&gt;ha.definedata(all:'y');&lt;/P&gt;&lt;P&gt;ha.definedone();&lt;/P&gt;&lt;P&gt;call missing(from,to); *this will inititaze the variables;&lt;/P&gt;&lt;P&gt;*now the rest of the original code;&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;if 0 the &lt;/P&gt;&lt;P&gt; do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length from to game ps rolls roll tot avg 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set transitions; *this will initialize the variables;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;declare hash ha(dataset:'transitions');&lt;/P&gt;&lt;P&gt;ha.definekey('from');&lt;/P&gt;&lt;P&gt;ha.definedata(all:'y');&lt;/P&gt;&lt;P&gt;ha.definedone();&lt;/P&gt;&lt;P&gt;*now the rest of the original code;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Dec 2011 02:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57458#M12402</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-12-03T02:42:16Z</dc:date>
    </item>
    <item>
      <title>Play Chutes and Ladders with me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57459#M12403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply. I'm definitely a novice when it comes to using the hash object, but what you wrote makes sense in general.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2011 17:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57459#M12403</guid>
      <dc:creator>gfarkas</dc:creator>
      <dc:date>2011-12-05T17:23:19Z</dc:date>
    </item>
    <item>
      <title>Play Chutes and Ladders with me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57460#M12404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No problem, it is why we are all here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2011 18:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Play-Chutes-and-Ladders-with-me/m-p/57460#M12404</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-12-05T18:02:48Z</dc:date>
    </item>
  </channel>
</rss>

