News for hackers. Stuff that matters.
Re:How to Make Easy & Flexible Star Ratings by jeiting on Friday October 14, 2011 @06:21PM (#3113184)
Have you tried a recursive solution?

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.