Page 3 of 3

Re: [Challenge] Snakes and ladder style board

Posted: Tue Sep 01, 2009 6:40 am
by onion2k
astions wrote:Might want to put an @ sign in front of the $c ;)
Hell no. Error suppression is bad and wrong. But putting $c = 0; before the loop would have been sensible.

Re: [Challenge] Snakes and ladder style board

Posted: Tue Sep 01, 2009 6:48 am
by Benjamin
LOL

Re: [Challenge] Snakes and ladder style board

Posted: Tue Sep 01, 2009 12:36 pm
by VladSun
onion2k wrote:Just for completeness, here's my solution ...
Cool, but it doesn't work with my PHP CLI ... :P

Re: [Challenge] Snakes and ladder style board

Posted: Tue Sep 01, 2009 12:40 pm
by John Cartwright
VladSun wrote:
onion2k wrote:Just for completeness, here's my solution ...
Cool, but it doesn't work with my PHP CLI ... :P
Unless your that dude from The Matrix that doesn't see the code, only a blonde, brunette, etc.

//my attempt at a joke

Re: [Challenge] Snakes and ladder style board

Posted: Wed Sep 02, 2009 3:08 am
by onion2k
VladSun wrote:Cool, but it doesn't work with my PHP CLI ... :P
I'm actually crying proper real tears here. I'm really sorry.

:(

Re: [Challenge] Snakes and ladder style board

Posted: Wed Sep 02, 2009 3:10 am
by VladSun
That's because you didn't follow the MVC pattern!!! :twisted:
You mixed up the View and the Model! Shame on you! :P :P :P

Re: [Challenge] Snakes and ladder style board

Posted: Fri Sep 18, 2009 6:17 am
by prometheuzz
Eye-bleeding compact:

Code: Select all

for($i=100,$j=1,$x=-1;$i>0;$i+=$j%10==0?-10:$x,$j++,$x=((int)($i-1)/10)%2==1?-1:1) {
  printf("%3s%s",$i,$j%10==0?"\n":"");
}

Re: [Challenge] Snakes and ladder style board

Posted: Thu Sep 24, 2009 9:08 pm
by jmaker
I'm a little late to this party, but here's mine. I'm not sure about performance wise, but I think it's easy enough to read.

Code: Select all

 for($x = 100, $y = 1; $x > 1; $x -= 10, $y++) {
    $ten = range($x, ($x-9));
    if($y % 2 == 0)
        sort($ten);
    foreach( $ten as $num )
        print "$num ";
    print "\n"; 
} 

Re: [Challenge] Snakes and ladder style board

Posted: Tue Apr 14, 2015 4:19 am
by saininvn
<table border="1" cellpadding="5" cellspacing="2">

<?
for($k=100; $k>=1; $k -=10){?>
<tr> <? for($l=0; $l<10; $l +=1) {?>
<td> <?
if (($k/10) % 2 == 0)
{
echo $k-$l;
}

else
{
echo $k+$l-10+1;
}
?></td>

<? }?>
</tr>
<?
}
?>
</table>