a hint for this

From: PeP (iosono_at_inwind.it)
Date: 08/23/04


Date: Mon, 23 Aug 2004 16:04:17 GMT

hi
i need a procedure generating the following:

user gives two numbers n and m with m <= n and the procedure must generate
all possible strings (vectors) m-sized, of natural numbers (except zero),
with the
condition that the sum of all elements is always <= n
-------------------------------------------------------------------
example 1:
n = 5
m = 3

results:
(1,1,1) (1,1,2) (1,1,3)
(1,2,1) (1,2,2)
(1,3,1)

(2,1,1) (2,1,2)
(2,2,1)

(3,1,1)
-------------------------------------------------------------------
example 2:
n = 6
m = 3

results:
(1,1,1) (1,1,2) (1,1,3) (1,1,4)
(1,2,1) (1,2,2) (1,2,3)
(1,3,1) (1,3,2)
(1,4,1)

(2,1,1) (2,1,2) (2,1,3)
(2,2,1) (2,2,2)
(2,3,1)

(3,1,1) (3,1,2)
(3,2,1)

(4,1,1)
-------------------------------------------------------------------
example 3:
n = 4
m = 2

results:
(1,1) (1,2) (1,3)

(2,1) (2,2)

(3,1)
-------------------------------------------------------------------
example 4:
n = 6
m = 5

results:
(1,1,1,1,1) (1,1,1,1,2)
(1,1,1,2,1)
(1,1,2,1,1)
(1,2,1,1,1)
(2,1,1,1,1)
-------------------------------------------------------------------
any suggestions?
thank you



Relevant Pages

  • Re: a hint for this
    ... > i need a procedure generating the following: ... > generate all possible strings m-sized, ... > (except zero), with the condition that the sum of all elements is ... One function supplies the next candidate vector. ...
    (comp.programming)
  • Re: How to SUM TWO ARRAY formula results
    ... But it always shows up as zero? ... And my sum as usual.. ... Your problem has nothing to do with C18 and C19 being array formulas. ... results are text strings because RIGHT is a function that returns a text ...
    (microsoft.public.excel.worksheet.functions)
  • Re: a hint for this
    ... PeP wrote: ... > i need a procedure generating the following: ...
    (comp.programming)