tags:

views:

1474

answers:

3

On SO 18 Joel mentioned an algorithm that would rank items based on their age and popularity and it's based on gravity. Could someone post this? C# would be lovely, but really any language (well, I can't do LISP) would be fine.

+6  A: 

My understanding is that it is approximately the following from another Jeff Atwood post

t = (time of entry post) - (Dec 8, 2005)
x = upvotes - downvotes

y = {1 if x > 0, 0 if x = 0, -1 if x < 0)
z = {1 if x < 1, otherwise x}

log(z) + (y * t)/45000
Tall Jeff
I don't like this solution - why do we need to fix a certain date and have an ever growing t? Why not change it so that t is age, and rearrange the algorithm so that a lower score is better. Voila, now some random pulled date has no influence. (More principle than necessity, but hey, that's me :) )
jTresidder
If X=0 then y=0, then z=0, and you get log(0) :(
Ofri Raviv
@Ofri Raviv - Good catch! - You are right, the Z formula should have been less than "1" not less than "0". A typo that has been there for about 11 months and you are the first to point it out! - Thanks!!
Tall Jeff
nice work InSciTek Jeff
baeltazor
A: 

@InSciTek Jeff Are you sure?

That seems to get a higher value to older posts. The older the post, the higher the value.

Jorge Córdoba
Put the flux capacitor down, and step away from the Delorean - any date after Dec 8 2005 will give you a positive t. The further from that date, the higher the score, ie newest score higher.
jTresidder
+5  A: 
Abhishek Mishra
WTF?! This algorithm smells so bad, *plus* it doesn't work.If x = -1,000,000, then y = -1, z = +6. If Ts is small enough, you'd have a positive value! maybe if you remove the abs() from x in the definition of z it will start making some sense, but still, its *way* too complex for what its trying to do.
Ofri Raviv
@Ofri - I agree. The absolute value part of this is wrong I think. My answer (after fixing a typo you pointed out) is the intended answer.
Tall Jeff