X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 5C7DC9FA666 for ; Wed, 26 Jul 2006 11:50:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 76494-10 for ; Wed, 26 Jul 2006 11:49:57 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.190]) by postgresql.org (Postfix) with ESMTP id A963A9FB0D1 for ; Wed, 26 Jul 2006 11:49:27 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id p77so722205nfc for ; Wed, 26 Jul 2006 07:49:25 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=ebqwDuJDR0Vio+GviQSMLuYJA4tWHiEnxk9QXpe374T5t6rmtQa4Ly6JvvyyeG7EiRygOv9a1QkfyJMfupgHpPt61LSSACT5a2ep/utuNMDYP/0lmWMowl3NsXEFjqj8Jdh+Y0lolTGaMr9QKtEHJkjYstgqaqN88ks1uc/mxXc= Received: by 10.78.164.13 with SMTP id m13mr3141176hue; Wed, 26 Jul 2006 07:49:25 -0700 (PDT) Received: by 10.78.32.10 with HTTP; Wed, 26 Jul 2006 07:49:25 -0700 (PDT) Message-ID: Date: Wed, 26 Jul 2006 09:49:25 -0500 From: "Aaron Bono" To: "Otniel Michael" Subject: Re: About Div Cc: pgsql-sql@postgresql.org In-Reply-To: <20060726014328.38920.qmail@web53202.mail.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_166205_11902296.1153925365313" References: <20060726014328.38920.qmail@web53202.mail.yahoo.com> X-Google-Sender-Auth: 4af2145b47d414de X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.738 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, HTML_30_40, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200607/316 X-Sequence-Number: 25890 ------=_Part_166205_11902296.1153925365313 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/25/06, Otniel Michael wrote: > > Mr. Aaron. I am sorry, your solution didn't match in my case. > Example for your solution : > A = 1 > B = 1 > C = 1 > D = 1 > E = 1 > F = 1 > G = 4 > > G have 4 candy. Its too much for G. > > In my case, the solution is : > A = 1 > B = 1 > C = 1 > D = 1 > E = 2 > F = 2 > G = 2 > > The extra candy is given to three child. > > Do you have the other solution? I need function in postgresql for my case. > Because my loop is too slow. > > Btw thanks for your solution. > I think you misunderstood how to use the MOD value. 10 % 7 = 3 so the last 3 people get 1 extra, NOT the last person getting the extra 3. But it looks like Ross got you the code to fix the problem. Check what he provided. ================================================================== Aaron Bono Aranya Software Technologies, Inc. http://www.aranya.com ================================================================== ------=_Part_166205_11902296.1153925365313 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/25/06, Otniel Michael <otmic_ie@yahoo.com> wrote:
Mr. Aaron. I am sorry, your solution didn't match in my case.
Example for your solution :
A = 1
B = 1
C = 1
D = 1
E = 1
F = 1
G = 4

G have 4 candy. Its too much for G.

In my case, the solution is :
A = 1
B = 1
C = 1
D = 1
E = 2
F = 2
G = 2

The extra candy is given to three child.

Do you have the other solution? I need function in postgresql for my case.
Because my loop is too slow.

Btw thanks for your solution.

 
I think you misunderstood how to use the MOD value.  10 % 7 = 3 so the last 3 people get 1 extra, NOT the last person getting the extra 3.

But it looks like Ross got you the code to fix the problem.  Check what he provided.

==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
================================================================== ------=_Part_166205_11902296.1153925365313--