Filling a 2x2 array with random numbers such that...
- From: manishwiz@xxxxxxxxx
- Date: 26 Sep 2006 13:23:11 -0700
Hi,
I need to RANDOMLY fill a 2x2 matrix such that the sum of each of rows
is same and the sum of each of the columns is same and these two sums
need not be same. the two sums shall be given.
Actually I have 'x' number of people and 'y' TYPE of objects. There are
'N' total objects with N/y objects of each type i.e. same number of
objects of each type. x, y and N will be given.
N mod x = 0
N mod y = 0
Problem is to distribute objects randomly such that each person has
same number of objects (obejcts may be different - total must be same).
One way to do this is: For each object, randomly choose a person to
give it to while taking care of row and column constraints. otherwise
give it to the next eligible person.
However this approach doesn't seem to be very efficient. Are there any
flaws with this?
Are there any efficient ways of doing this, shall appreciate any
pointers/suggestions!!
TIA,
M
.
- Follow-Ups:
- Re: Filling a 2x2 array with random numbers such that...
- From: websnarf
- Re: Filling a 2x2 array with random numbers such that...
- Prev by Date: Re: C or C++ streams question
- Next by Date: Re: Filling a 2x2 array with random numbers such that...
- Previous by thread: print as a base 10 number
- Next by thread: Re: Filling a 2x2 array with random numbers such that...
- Index(es):