[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-02-03 Thread dor
I am assuming that by random you mean uniformly at random (that is, the probability of generating i is 1/5) map the following pairs of numbers (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2) to 1, 2, .. , 7 respectively let p_i denote the pair corresponding to the number i (e.g. p_1 = (1,

[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-01-31 Thread [EMAIL PROTECTED]
random generator is uniformly distributed -Original Message- From: algogeeks@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Sandesh Sent: Tuesday, January 30, 2007 11:09 PM To: Algorithm Geeks Subject: [algogeeks] Re: (need help) How to solve this random number generatioin

[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-01-31 Thread Pradeep Muthukrishnan
Sent: Tuesday, January 30, 2007 11:09 PM To: Algorithm Geeks Subject: [algogeeks] Re: (need help) How to solve this random number generatioin problem? suppose given function returns the random numbers between 1 -5 then you can have (given + given) % 7 +1 which

[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-01-31 Thread Gene
On Jan 30, 8:57 pm, Jialin [EMAIL PROTECTED] wrote: Question: Given a program which can generate one of {1, 2, 3, 4, 5} randomly. How can we get another generator which can generate one of {1,2,3,4,5,6,7} randomly? Thank you! If you generate random 1 to 5 twice, there are 25 equally

[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-01-31 Thread pramod
Why can't we simply take the 1..5 random number, multiply by 7 and divide by 5. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-01-31 Thread Prunthaban Kanthakumar
Then you will get only the following numbers (1*7)/5 = 1 (2*7)/5 = 2 (3*7)/5 = 4 (4*7)/5 = 5 (5*7)/5 = 7 What you will do to get 3 and 6? On 2/1/07, pramod [EMAIL PROTECTED] wrote: Why can't we simply take the 1..5 random number, multiply by 7 and divide by 5.

[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-01-30 Thread aakash mandhar
/* You can do it as shown below. */ #include iostream #include stdlib.h using namespace std; int random(int low,int high) { srand(time(NULL)); int n=(high-low+1); return low + (rand()%n); } int main() { coutrandom(1,7); return 0; } On 1/31/07, Jialin [EMAIL PROTECTED] wrote: Question:

[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-01-30 Thread Sandesh
suppose given function returns the random numbers between 1 -5 then you can have (given + given) % 7 +1 which will generate between 1 and 7 . -Sandesh Hegde On Jan 31, 6:57 am, Jialin [EMAIL PROTECTED] wrote: Question: Given a program which can generate one of {1, 2, 3, 4,

[algogeeks] Re: (need help) How to solve this random number generatioin problem?

2007-01-30 Thread Ming \(Amos\) Zhang
) How to solve this random number generatioin problem? suppose given function returns the random numbers between 1 -5 then you can have (given + given) % 7 +1 which will generate between 1 and 7 . -Sandesh Hegde On Jan 31, 6:57 am, Jialin [EMAIL PROTECTED] wrote: Question