Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 15th, 2012  |  syntax: None  |  size: 0.39 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Reddits voting algorithm, javascript version
  2. function getRating(t,u,d){
  3.  
  4.         var x = u-d;
  5.  
  6.         if(x > 0)
  7.             y = 1
  8.         else if(x == 0)
  9.             y = 0
  10.         else if(x < 0)
  11.             y = -1
  12.  
  13.         var z = Math.max(1,Math.abs(x));
  14.  
  15.         return Math.log(z)/Math.log(10) + y*t/45000;
  16.  
  17.     }
  18.        
  19. console.log(getRating(50000, 25, 25)); //0
  20.        
  21. z = Math.max(1,Math.abs(x))