Re: Interesting Math Problem

2008-06-08 Thread Lie
On Jun 6, 2:25 am, "Rüdiger Werner" <[EMAIL PROTECTED]> wrote: > "BEES INC" <[EMAIL PROTECTED]> schrieb im Newsbeitragnews:[EMAIL PROTECTED] > ... > > 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 a

Re: Interesting Math Problem

2008-06-05 Thread R�diger Werner
"BEES INC" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] ... 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 rati

Re: Interesting Math Problem

2008-06-05 Thread MRAB
On Jun 4, 9:03 am, "BEES INC" <[EMAIL PROTECTED]> 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 acro

Re: Interesting Math Problem

2008-06-05 Thread Chuckk Hubbard
On Wed, Jun 4, 2008 at 11:03 AM, BEES INC <[EMAIL PROTECTED]> wrote: > My Solution (in Python): > > # round to one decimal place and > # separate into whole and fractional parts > parts = str(round(star_sum/num_raters, 1)).split('.') > whole = int(parts[0]) > frac = int(parts[1]) > if frac < 3: >

Re: Interesting Math Problem

2008-06-05 Thread Gary Herron
BEES INC 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

Re: Interesting Math Problem

2008-06-05 Thread Chuckk Hubbard
On Thu, Jun 5, 2008 at 11:52 AM, Chuckk Hubbard <[EMAIL PROTECTED]> wrote: > On Wed, Jun 4, 2008 at 11:03 AM, BEES INC <[EMAIL PROTECTED]> wrote: > >> My Solution (in Python): >> >> # round to one decimal place and >> # separate into whole and fractional parts >> parts = str(round(star_sum/num_rate

Re: Interesting Math Problem

2008-06-05 Thread Iain King
On Jun 4, 9:03 am, "BEES INC" <[EMAIL PROTECTED]> 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 acro

Re: Interesting Math Problem

2008-06-05 Thread Ken Starks
BEES INC 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

Interesting Math Problem

2008-06-05 Thread BEES INC
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 s

Re: Interesting math problem

2008-04-13 Thread Arnaud Delobelle
On Apr 13, 5:35 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On Mar 19, 2:17 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > > > > > On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle > > > <[EMAIL PROTECTED]> wrote: > > >  > def make_slope(distance, parts): > > >  >     step = distance / fl

Re: Interesting math problem

2008-04-13 Thread Ivan Illarionov
On Mar 19, 2:17 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle > > > > <[EMAIL PROTECTED]> wrote: > > > def make_slope(distance, parts): > > > step = distance / float(parts) > > > intstep = int(step) > > > floatstep = step - int

Re: Interesting math problem

2008-03-19 Thread BJörn Lindqvist
On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > def make_slope(distance, parts): > > step = distance / float(parts) > > intstep = int(step) > > floatstep = step - intstep > > > > steps = [] > > acc = 0.0 > > for i in range(parts): >

Re: Interesting math problem

2008-03-18 Thread Terry Reedy
"Jeff Schwab" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Marc Christiansen wrote: | > This was my first thought, too. But tailcall optimisation wouldn't help | > here. `make_slope` is not tail recursive, the `+` (aka list.extend) gets | > executed after the recursion. | | | de

Re: Interesting math problem

2008-03-18 Thread Jeff Schwab
Marc Christiansen wrote: > sturlamolden <[EMAIL PROTECTED]> wrote: >> On 18 Mar, 00:58, Jeff Schwab <[EMAIL PROTECTED]> wrote: >> >>> def make_slope(distance, parts): >>> if parts == 0: >>> return [] >>> >>> q, r = divmod(distance, parts) >>> >>> if r and parts % r: >>>

Re: Interesting math problem

2008-03-18 Thread Marc Christiansen
sturlamolden <[EMAIL PROTECTED]> wrote: > On 18 Mar, 00:58, Jeff Schwab <[EMAIL PROTECTED]> wrote: > >> def make_slope(distance, parts): >> if parts == 0: >> return [] >> >> q, r = divmod(distance, parts) >> >> if r and parts % r: >> q += 1 >> >> return [q] +

Re: Interesting math problem

2008-03-18 Thread sturlamolden
On 18 Mar, 00:58, Jeff Schwab <[EMAIL PROTECTED]> wrote: > def make_slope(distance, parts): > if parts == 0: > return [] > > q, r = divmod(distance, parts) > > if r and parts % r: > q += 1 > > return [q] + make_slope(distance - q, parts - 1) Beautiful. If Pyt

Re: Interesting math problem

2008-03-17 Thread Jeff Schwab
Arnaud Delobelle wrote: > On Mar 17, 10:24 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: >> Here is an interesting math problem: >> >> You have a number X > 0 and another number Y > 0. The goal is to >> divide X into a list with length Y. Each

Re: Interesting math problem

2008-03-17 Thread Jeff Schwab
BJörn Lindqvist wrote: > Here is an interesting math problem: > > You have a number X > 0 and another number Y > 0. The goal is to > divide X into a list with length Y. Each item in the list is an > integer. The sum of all integers is X. Each integer is either A or A +

Re: Interesting math problem

2008-03-17 Thread Ivan Illarionov
On Mar 18, 1:24 am, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > Here is an interesting math problem: > > You have a number X > 0 and another number Y > 0. The goal is to > divide X into a list with length Y. Each item in the list is an > integer. The sum

Re: Interesting math problem

2008-03-17 Thread Arnaud Delobelle
On Mar 17, 10:24 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > Here is an interesting math problem: > > You have a number X > 0 and another number Y > 0. The goal is to > divide X into a list with length Y. Each item in the list is an > integer. The sum

Re: Interesting math problem

2008-03-17 Thread castironpi
On Mar 17, 5:24 pm, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > Here is an interesting math problem: > > You have a number X > 0 and another number Y > 0. The goal is to > divide X into a list with length Y. Each item in the list is an > integer. The sum

Interesting math problem

2008-03-17 Thread BJörn Lindqvist
Here is an interesting math problem: You have a number X > 0 and another number Y > 0. The goal is to divide X into a list with length Y. Each item in the list is an integer. The sum of all integers is X. Each integer is either A or A + 1, those should be "evenly distributed." E