Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on How to Make Easy & Flexible Star Ratings. Parent comment
def round_to_half(x): if ( x < 1) { if (x < 3) { return 0; else if (x > 7) { return 1.0; } else { return 0.5 } } else { return round_to_half(x/10); } }
x = star_sum/num_raters dec = round_to_half(x) x = floor(x/10) + dec
This way you look smarter for using recursion.
There are no comments on this comment yet.
def round_to_half(x): if ( x < 1) { if (x < 3) { return 0; else if (x > 7) { return 1.0; } else { return 0.5 } } else { return round_to_half(x/10); } }
x = star_sum/num_raters dec = round_to_half(x) x = floor(x/10) + dec
This way you look smarter for using recursion.