Interesting Math Problem
google at mrabarnett.plus.com
Thu Jun 5 19:04:00 CEST 2008
On Jun 4, 9:03 am, "BEES INC" <bees.... at gmail.com> wrote:
> I've been awfully busy programming lately. My Django-based side
> project is coming along well and I hope to have it ready for use in a
> few weeks. Please don't ask more about it, that's really all I can say
> for now. Anyways, I came across an interesting little math problem
> today and was hoping some skilled programmers out there could come up
> with a more elegant solution than mine.
> Problem: Star Ratings
> People can rate cheeseburgers on my website with a star rating of 0-5
> stars (whole stars only), 5 being mighty tasty and 0 being disgusting.
> I would like to show the average of everyone's ratings of a particular
> cheeseburger to the nearest half star. I have already calculated the
> average rating as a float (star_sum) and the total number of people
> that rated the particular cheeseburger (num_raters).
I hope you really meant that 'star_sum' was the _sum_ and not the
_average_, otherwise the result would definitely be wrong! :-)
More information about the Python-list