2
的HN算法:黑客新聞算法在Rails中?
(p - 1)/(t + 2)^1.5
其中:
p = votes of question and first answer
t = age in hours
考慮到與以下字段的鏈接模式:
up_votes
down_votes
created_at
這是實現正確的Ruby on Rails的?我不知道它是否:
def rank(link)
p = link.up_votes - link.down_votes
t = (Time.now - link.created_at).to_i/60/60
return (p - 1)/(t + 2)**1.5
end