** Some Help Please **

S Manoharan sam at cs.ed.ac.uk
Wed Jun 5 19:43:08 AEST 1991


There is a wee problem I want to solve. There are `m' mailboxes
(named 0 to m-1) which get `n' mails (named 0 to n-1) over a 
period of time. I want to generate all the possible ways of these
mails arriving at the mailboxes. There should be 
      factorial(n) * pow(m, n) possibilities.

For instance, if m = 2 and n = 2 then the possibilities would be
[m0: 0, 1;  m1: -]   [m0: -;  m1: 0, 1]   [m0: 0;  m1: 1]
[m0: 1, 0;  m1: -]   [m0: -;  m1: 1, 0]   [m0: 1;  m1: 0]

All I want is to print these possibilites for any given values
(small, say, <= 10) of `m' and `n'.

Can anyone help me to get hold of a C code or an algorithm to
tackle this. It seems to beat me.

Thanks in advance.

Ps - Sorry, if I am posting this to a wrong newsgroup.


--
S Manoharan                Bitnet   : sam%lfcs.ed.ac.uk at ukacrl.bitnet
Dept of Computer Science   Uucp     : sam%lfcs.ed.ac.uk at ukc.uucp
University of Edinburgh    Fax      : +44 31 667 7209
Edinburgh EH9 3JZ    UK.   Voice    : +44 31 650 5115 (Office)



More information about the Comp.lang.c mailing list