Leettime daha hızlı / daha iyi bir yolu var mı?

1 Cevap php

I leettime twitter ile buldum ve beni sizlerle paylaşmak / onunla etrafında karışıklık istediğiniz için yeterli roman. Benim dehşet bu sürümü saniye yapmaz. Süresi oluşturmak için daha etkili bir yolu olabilir gibi de görünüyor, sen ne düşünüyorsun?

Leet Time

Now, how is this leettime calculated?

For a given humantime (e.g. 11:15 am) the value of the leettime corresponds to the number of times you have to add up 13 hours 37 minutes in order to exactly reach this time. Whenever the result overflows during the calculation (i.e. the obtained time exceeds 23:59 o'clock) you subtract 24 hours in order to stay on the clock.

Example:

The leettime of 00:00 is 0, the leettime of 13:37 is 1 and leettime 2 corresponds to 03:14 am (because 13:37 plus 13 hours 37 minutes is 03:14 o'clock).

Is there a unique leettime for every humantime during the day?

Yes! There are exactly 24*60=1440 different leettimes, each corresponds to exactly one minute in the day.

Serin olacağını düşünüyorum başka ne eklemek, ben bu adam bunu isterdim eminim.

Ben en çok erişilebilir ve taşınabilir olurdu sergiyi PHP versiyonunu koydu. The other versions are available here.

<?php
/**
 * Converts standard time to leettime.
 * 
 * @param int h the hour in standard time
 * @param int m the minute in standard time
 * 
 * @return int the leettime or -1 if the input
 *         parameters are invalid
 */
function TimeToLeet($h, $m){
  if(!is_numeric($h) || !is_numeric($m) ||
    $h > 23 || $h < 0 || $m > 59 || $m < 0)
      return -1;

  $curm = 0;
  $curh = 0;
  $i = 0;
  while ($curm != $m || ($curh % 24) != $h){  
    if($curm < 23){
      $curh += 13;
      $curm += 37;      
    } else {
      $curh += 14;
      $curm -= 23;      
    }
    ++$i;
  }
  return $i;  
}

/**
 * Converts leettime to standard time.
 * 
 * @param int leet the time in leettime-format in the
 *        range from 0 - 1439
 * 
 * @return var an int-Array with the hours at position 0
 * and minutes at position 1 (-1 if the input parameter
 * is not in range)
 */
function LeetToTime($leet){
  if($leet > 1439 || $leet < 0) return array(-1, -1);
  $m = $leet * 37;
  $h = ($leet * 13) + ($m / 60);
  return array($h % 24, $m % 60);
}

// Demonstrate usage

$h = (int)date("G");
$m = (int)date("i");

echo date("H:i")." = ".TimeToLeet($h,$m);

echo "
";

$leettime = 999;
$result = LeetToTime($leettime);
if($result[0] == -1) echo "error";
else {
  $h = $result[0];
  $m = $result[1];
  echo $leettime." = ".($h>9?$h:"0".$h) . 
    ":".($m>9?$m:"0".$m);
}
?>

1 Cevap

HH bir hızlı dönüştürme için: Leet MM, Modüler Aritmetik deneyin:

İlk olarak, bir sayı mod 1440 13:37 dönüştürmek; özel olarak ise, 13 * 60 +37 = 817

817 mod 1440 tersini bulun. Sonucu 913 olan (stolen from Wolfram Alpha). 913 913 * 817 özelliğini == 1 mod 1440 var.

Alternatif olarak, 13 dakika, 37 saniye kullanmak istiyorsa; Eğer mod 86.400 çalışmak, ve 817 ^ olurdu -1 == 67153.

Bir numara mod 1440 için hedef zaman dönüştürmek; sonra çarpın 913 mod 1440 ile karşılık gelen leet zaman alır. Çarpın 817 tarafından, geri dönüştürmek.

Örnek:

Going from leet time to normal time (accuracy to the minute):
someLeetTime = 1337
//where 817 = 13*60 + 37 = 13:37 in minutes
timeInMinutes = someLeetTime * 817 mod 1440 = 809
hours = timeInMinutes / 60 = 13
minutes = timeInMinutes % 60 = 29

Going from normal time to leet time (accuracy to the minute):
hours = 13
minutes = 29
timeInMinutes = hours * 60 + minutes = 809
//913 = 817^-1 mod 1440
someLeetTime = timeInMinutes * 913 mod 1440 = 1337 
13:29 is 1337 leet time

Ve, 13:37 in saniye boyunca olası bir uygulama 13 dakika, 37 saniye olarak kabul edilir. (Teknik standardını ihlal, ama biz l33t, ve bunu yapabilirsiniz)

Going from leet time to normal time (accuracy to the second):
someLeetTime = 1337
//where 817 = 13*60 + 37 = 13:37 in seconds
timeInSeconds = someLeetTime * 817 mod 86400 = 55529
hours = timeInSeconds / 3600 = 15
minutes = (timeInSeconds % 3600) / 60 = 25
seconds = timeInSeconds % 60 = 29

1337 in the new system is 15:25:29

Going from normal time to leet time (accuracy to the second):
hours = 15
minutes = 25
seconds = 29
timeInSeconds = hours * 3600 + minutes*60 + seconds = 55529
//67153 = 817^-1 mod 86400
someLeetTime = timeInSeconds * 67153 mod 86400 = 1337 
15:25:29 is 1337 leet time

Size Kripto ve Modüler Aritmetik ederiz.

Bu büyük davasına ilerletmek için, ben bir saat inşa etmişlerdir! Well... 6 actually.