Read 108 times | Created 2013-03-15 19:24:13 | Updated 2013-03-15 19:24:13 | | |

 

<pre>
<?php
echo "===nHeilbert SilenTears Mapalyn";
$t1 = MICROTIME(TRUE);
$angka=8;
$huruf="abcdef";
while(strlen($huruf))
{
  $i=($angka-1) % strlen($huruf);
  echo $huruf[($angka-1) % strlen($huruf)];
  while($i<strlen($huruf))
  {
    if($i==strlen($huruf)-1)
      $huruf=substr($huruf,0,-1);
    else
      $huruf[$i]=$huruf[$i+1];
    $i++;
  }
}
$t2 = MICROTIME(TRUE);
echo "nMakan waktu: ".($t2 - $t1)." sekonn";
//===
echo "===nHeilbert SilenTears Mapaly *n";
$t1 = MICROTIME(TRUE);
$angka=8;
$huruf="abcdef";
while(strlen($huruf))
{
  $i=($angka-1) % strlen($huruf);
  echo $huruf[$i];
  $b=str_split($huruf);
  array_splice($b,$i,1);
  $huruf=implode('',$b);
}
$t2 = MICROTIME(TRUE);
echo "nMakan waktu: ".($t2 - $t1)." sekonn";
//===
echo "===nSandi Racyn";
$t1 = MICROTIME(TRUE);
$angka=8;
$huruf='abcdef';
while($huruf!='')
{
  $jumlah=strlen($huruf);
  $j=0;
  for($i=1; $i<=$angka; $i++)
  {
    $hasil[$i]=$huruf[$j];
    $i%$jumlah==0 ? $j=0 : $j++;
  }
  echo $hasil[$angka];
  $huruf=str_replace($hasil[$angka], '', $huruf); 
}
$t2 = MICROTIME(TRUE);
echo "nMakan waktu: ".($t2 - $t1)." sekonn";
//===
echo "===nNoer Cholisn";
$t1 = MICROTIME(TRUE);
$angka=8;
$huruf='abcdef';
function recursive($huruf,$angka,$hasil=''){
  if(strlen($huruf)>=1):
    $genhuruf = autohuruf($huruf,$angka); 
    $hasil.= $genhuruf[$angka-1];
    $huruf = str_replace($genhuruf[$angka-1],"",$huruf);
    $hasil = recursive($huruf,$angka,$hasil);
  endif; 
  return $hasil;
}
function autohuruf($huruf,$angka){
  if(strlen($huruf) < $angka):
    $huruf.=$huruf;
  endif;
  if(strlen($huruf) < $angka):
    $huruf.=autohuruf($huruf,$angka);
  endif;
  return $huruf; 
}
echo recursive($huruf,$angka);
$t2 = MICROTIME(TRUE);
echo "nMakan waktu: ".($t2 - $t1)." sekonn";
//===
echo "===nAhmad Anang Atmahadlin";
$t1 = MICROTIME(TRUE);
$angka=8;
$huruf='abcdef';
while(!empty($huruf)){
  $h=str_split($huruf);
  $n=strlen($huruf);
  //$b=floor($angka/$n);
  $s=$angka%$n;
  if($s==0)$s=$n;
  echo $h[$s-1];
  unset($h[$s-1]);
  $huruf=implode('',$h);
}
$t2 = MICROTIME(TRUE);
echo "nMakan waktu: ".($t2 - $t1)." sekonn";
//===
echo "===nAhmad Anang Atmahadli *n";
$t1 = MICROTIME(TRUE);
$angka=8;
$huruf='abcdef';
while(!empty($huruf)){
  $h=str_split($huruf);
  $n=strlen($huruf);
  $s=($angka%$n)?$angka%$n:$n;
  echo $h[$s-1];
  unset($h[$s-1]);
  $huruf=implode('',$h);
}
$t2 = MICROTIME(TRUE);
echo "nMakan waktu: ".($t2 - $t1)." sekonn";
//==
/*
echo "===nGanjar Setia M n";
echo "</pre>";
$t1 = MICROTIME(TRUE);
$angka = 8;
$huruf = array('a','b','c','d','e','f');
$temp1 = '';
$j = 0;
$outputnya = '';
$sizeHuruf = count($huruf);
for ($loop1 = 1; $loop1 <= $sizeHuruf; $loop1++) {
for ($i = 1; $i <= $angka; $i++) {
        if ($i <= count($huruf)) {
                echo $huruf[$i-1]." = ".$i."<br/>";
        } elseif ($j < count($huruf)) {
                echo $huruf[$j]." = ".$i."<br/>";
                $j++;
        } else {
                $j = 0;
                echo $huruf[$j]." = ".$i."<br/>";
                $j++;
        }
       
        if ($i == $angka) {
                $j--;
                $outputnya .= $huruf[$j];
                array_splice($huruf, $j, 1);
        }
}
        $j = 0;
        echo "<br/>Ini Outputnya:<br/>" . $outputnya . "<br/><br/>";
}
echo "<pre>";
$t2 = MICROTIME(TRUE);
echo "nMakan waktu: ".($t2 - $t1)." sekonn";
*/
//==
echo "===nGanjar Setia M *n";
$t1 = MICROTIME(TRUE);
$angka = 8;
$huruf = array('a','b','c','d','e','f');
$temp1 = '';
$j = 0;
$outputnya = '';
$sizeHuruf = count($huruf);
for ($loop1 = 1; $loop1 <= $sizeHuruf; $loop1++) {
  for ($i = 1; $i <= $angka; $i++) {
    
    if ($i <= count($huruf)) {
       //echo $huruf[$i-1]." = ".$i."<br/>";
    } elseif ($j < count($huruf)) {
       //echo $huruf[$j]." = ".$i."<br/>";
       $j++;
    } else {
       $j = 0;
       //echo $huruf[$j]." = ".$i."<br/>";
       $j++;
    } 
       
    if ($i == $angka) {
       $j--;
       $outputnya .= $huruf[$j];
       array_splice($huruf, $j, 1);
    }
  }
  $j = 0;
}
echo $outputnya;
$t2 = MICROTIME(TRUE);
echo "nMakan waktu: ".($t2 - $t1)." sekonn";
//==
echo "===nNandang Permanan";
$t1 = MICROTIME(TRUE);
$angka = 8;
$huruf = str_split("abcdef");
$hasil = "";
$temp ="";
$jumlah_huruf = count($huruf);
for($i=0;$i<=$jumlah_huruf-1;$i++)
{
  $huruf = array_values($huruf);
  if( ($angka > count($huruf)) && (($angka%count($huruf))!=0) )
  {
    $temp = $huruf[($angka%(count($huruf))-1)];
  }
  else if(($angka%count($huruf))==0)
  {
    $temp = $huruf[count($huruf)-1];
  }
  else
  {
    $temp = $huruf[$angka-1];
  }
  $hasil = $hasil.$temp;
  if(($key = array_search($temp, $huruf)) !== false) {
    unset($huruf[$key]);
  }
}
echo $hasil;
$t2 = MICROTIME(TRUE);
echo "nMakan waktu: ".($t2 - $t1)." sekonn";
//==
echo "===n)* modified";
?>