[vsoler]
> In the accounting department I am working for we are from time to time
> confronted to the following problem:
>
> A customer sends us a check for a given amount, but without specifying
> what invoices it cancels. It is up to us to find out which ones the
> payment corresponds to.
>
> For
On Nov 8, 8:39 am, vsoler wrote:
> In the accounting department I am working for we are from time to time
> confronted to the following problem:
>
> A customer sends us a check for a given amount, but without specifying
> what invoices it cancels. It is up to us to find out which ones the
> paymen
On Tue, 10 Nov 2009 14:59:13 -0800, John Machin wrote:
> On Nov 8, 8:39 am, vsoler wrote:
>> In the accounting department I am working for we are from time to time
>> confronted to the following problem:
> [snip]
>
>> My second question is:
>> 2. this time there are also credit notes outstanding
On Tue, 10 Nov 2009 14:46:49 -0800, John Machin wrote:
> The problems that you mention are only a SUBSET of the total problem.
> Example: oustanding invoices are for 300, 200, and 100 and the cheque is
> for 450 -- in general the total of the cheque amounts does not equal the
> total of any possib
On Nov 8, 8:39 am, vsoler wrote:
> In the accounting department I am working for we are from time to time
> confronted to the following problem:
[snip]
> My second question is:
> 2. this time there are also credit notes outstanding, that is,
> invoices with negative amounts. For example, I=[500,
Gerry wrote:
> On Nov 8, 2:42 pm, Ozz wrote:
>> vsoler schreef:
>>
> And, of course, you'd want to take a look a this: http://xkcd.com/287/
:) I remember that.
mwil...@tecumseth:~/sandbox$ python xkcd_complete.py
[1, 0, 0, 2, 0, 1] 1505
[7] 1505
Mel.
--
http://mail.python.org/mailma
Gerry wrote:
On Nov 8, 2:42 pm, Ozz wrote:
vsoler schreef:
And, of course, you'd want to take a look a this: http://xkcd.com/287/
I've found 2 solutions.
(And I really should get back to what I was doing...)
Gerry
Instead of subsets, do you mean permutations/combinations? Since 2
invo
On Tue, Nov 10, 2009 at 8:59 AM, Steven D'Aprano
wrote:
> On Sun, 08 Nov 2009 12:31:26 -0500, geremy condra wrote:
>
>> What you're describing is the powerset operation. Here's the example
>> from the python docs:
> [...]
>> What I find interesting is that running it through timeit, it is much
>>
On Sun, 08 Nov 2009 12:31:26 -0500, geremy condra wrote:
> What you're describing is the powerset operation. Here's the example
> from the python docs:
[...]
> What I find interesting is that running it through timeit, it is much
> slower than the code suggested by Dan Bishop.
Your test doesn't s
On Nov 8, 2:42 pm, Ozz wrote:
> vsoler schreef:
>
And, of course, you'd want to take a look a this: http://xkcd.com/287/
Gerry
>
> > Instead of subsets, do you mean permutations/combinations? Since 2
> > invoices can have the same amount perhaps the terms permutation is
> > better.
>
> As some
vsoler schreef:
Instead of subsets, do you mean permutations/combinations? Since 2
invoices can have the same amount perhaps the terms permutation is
better.
As some other poster already suggested 'powerset' (
http://en.wikipedia.org/wiki/Power_set ) may be a better name, except
for those
Dan Bishop schreef:
You can avoid the S list my making it a generator:
def subsets(L):
if L:
for s in subsets(L[1:]):
yield s
yield s + [L[0]]
else:
yield []
Nice one. Thanks!
Ozz
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Nov 8, 2009 at 12:31 PM, geremy condra wrote:
> On Sun, Nov 8, 2009 at 11:52 AM, Dan Bishop wrote:
>> On Nov 8, 4:43 am, Ozz wrote:
>>> Hi,
>>>
>>> > My first question is:
>>> > 1. given a list of invoives I=[500, 400, 450, 200, 600, 700] and a
>>> > check Ch=600
>>> > how can I print al
On Sun, Nov 8, 2009 at 11:52 AM, Dan Bishop wrote:
> On Nov 8, 4:43 am, Ozz wrote:
>> Hi,
>>
>> > My first question is:
>> > 1. given a list of invoives I=[500, 400, 450, 200, 600, 700] and a
>> > check Ch=600
>> > how can I print all the different combinations of invoices that the
>> > check is
Ozz wrote:
Hi,
My first question is:
1. given a list of invoives I=[500, 400, 450, 200, 600, 700] and a
check Ch=600
how can I print all the different combinations of invoices that the
check is possibly cancelling
Incidentally, I'm currently learning python myself, and was working on
more
On Nov 8, 1:27 pm, Ozz wrote:
> Robert P. J. Day schreef:
>
> > does your solution allow for the possibility of different invoices
> > of equal amounts? i would be reluctant to use the word "subset" in a
> > context where you can have more than one element with the same value.
>
> I think it ha
On Nov 8, 4:43 am, Ozz wrote:
> Hi,
>
> > My first question is:
> > 1. given a list of invoives I=[500, 400, 450, 200, 600, 700] and a
> > check Ch=600
> > how can I print all the different combinations of invoices that the
> > check is possibly cancelling
>
> Incidentally, I'm currently learning
Robert P. J. Day schreef:
does your solution allow for the possibility of different invoices
of equal amounts? i would be reluctant to use the word "subset" in a
context where you can have more than one element with the same value.
I think it handles different invoices of equal amounts corre
Oops,
For listing all different subsets of a list (This is what I came up
with. Can it be implemented shorter, btw?):
def subsets(L):
S = []
if (len(L) == 1):
return [L, []]
better to check for the empty set too, thus;
if (len(L) == 0):
retur
On Sun, 8 Nov 2009, Ozz wrote:
>
> Hi,
>
> > My first question is:
> > 1. given a list of invoives I=[500, 400, 450, 200, 600, 700] and a
> > check Ch=600
> > how can I print all the different combinations of invoices that the
> > check is possibly cancelling
>
> Incidentally, I'm currently learni
Hi,
My first question is:
1. given a list of invoives I=[500, 400, 450, 200, 600, 700] and a
check Ch=600
how can I print all the different combinations of invoices that the
check is possibly cancelling
Incidentally, I'm currently learning python myself, and was working on
more or less the
vsoler wrote:
As mentioned in the other answers, your problem is best solved by a long
overdue organisational decision instead of a technical one.
Most popular solutions are:
- All invoices are essential a single credit amount, money coming in is
taken of from the big pile.
- Invoices are spli
On Sat, 7 Nov 2009, vsoler wrote:
> In the accounting department I am working for we are from time to
> time confronted to the following problem:
>
> A customer sends us a check for a given amount, but without
> specifying what invoices it cancels. It is up to us to find out
> which ones the payme
On Sat, 7 Nov 2009, vsoler wrote:
> In the accounting department I am working for we are from time to
> time confronted to the following problem:
>
> A customer sends us a check for a given amount, but without
> specifying what invoices it cancels. It is up to us to find out
> which ones the payme
On Sat, Nov 7, 2009 at 4:39 PM, vsoler wrote:
> In the accounting department I am working for we are from time to time
> confronted to the following problem:
[snip]
> For example, say that the customer has the following outstanding
> invoices: $300, $200, $50; and say that the check is for $250.
25 matches
Mail list logo