SHARE
TWEET

Stack Overflow Ranking Algorithm

ruanyf Mar 10th, 2012 890 Never
  1. <?php
  2.  
  3. function hot($Qviews, $Qanswers, $Qscore, $Ascores, $date_ask, $date_active)
  4. {
  5.     $Qage = (time() - strtotime(gmdate("Y-m-d H:i:s",strtotime($date_ask)))) / 3600;
  6.     $Qage = round($Qage, 1);
  7.  
  8.     $Qupdated = (time() - strtotime(gmdate("Y-m-d H:i:s",strtotime($date_active)))) / 3600;
  9.     $Qupdated = round($Qupdated, 1);
  10.  
  11.     $dividend = (log10($Qviews)*4) + (($Qanswers * $Qscore)/5) + $Ascores;
  12.     $divisor = pow((($Qage + 1) - ($Qage - $Qupdated)/2), 1.5);
  13.  
  14.     echo $dividend/$divisor . "\n";
  15. }
  16.  
  17. ?>
RAW Paste Data
Top