▼  Site Navigation Main Articles News Search  ▼  Anime + Manga Anime Reviews Anime Characters Gallery Screenshots Manga Reviews  ▼  Misc Links to Webcomics Bible Quotes About Older Musings
site version 7.3
PHP –– permutations
written by: admin


Date Written: 4/27/12 Last Updated: 5/28/12

<?php
$a=122;
$b=array();
while ($a<543){$a++;
$a1=substr($a,0,1);
$a2=substr($a,1,1);
$a3=substr($a,2,1);
if ($a3==6){$a2++;$a3=1;}
if ($a2==6){$a1++;$a2=1;}
$a="$a1"."$a2"."$a3";
if ($a>543)break;
if ($a1!=$a2 and $a1!=$a3 and $a2!=$a3)$b[]=$a;
}
echo"<pre>";
print_r($b);
echo"</pre>";
?>

demo

All this does is calculate all of the possible combinations of 3 non repeating digits of digits 1 – 5.  You never know when this could be useful.  You need to know all of the possible combinations in a lock or possible orders in a game.

TAGS: php
copyright 2005–2024