a hint for this
From: PeP (iosono_at_inwind.it)
Date: 08/23/04
- Next message: Isaac Gouy: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Previous message: SM Ryan: "Re: duplicates in a file"
- Next in thread: mensanator_at_aol.com: "Re: a hint for this"
- Reply: mensanator_at_aol.com: "Re: a hint for this"
- Reply: CBFalconer: "Re: a hint for this"
- Reply: bowsayge: "Re: a hint for this"
- Reply: Kai-Uwe Bux: "Re: a hint for this"
- Maybe reply: mensanator_at_aol.com: "Re: a hint for this"
- Reply: Willem: "Re: a hint for this"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Isaac Gouy: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Previous message: SM Ryan: "Re: duplicates in a file"
- Next in thread: mensanator_at_aol.com: "Re: a hint for this"
- Reply: mensanator_at_aol.com: "Re: a hint for this"
- Reply: CBFalconer: "Re: a hint for this"
- Reply: bowsayge: "Re: a hint for this"
- Reply: Kai-Uwe Bux: "Re: a hint for this"
- Maybe reply: mensanator_at_aol.com: "Re: a hint for this"
- Reply: Willem: "Re: a hint for this"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|