3 ms·
Have you tried a recursive solution? def round_to_half(x): if ( x < 1) { if (x < 3) { return 0; else if (x > 7) { ret
by jeiting 15y ago
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.