Click here to Skip to main content
15,887,585 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Crossword generation Pin
Luc Pattyn4-Oct-10 3:27
sitebuilderLuc Pattyn4-Oct-10 3:27 
AnswerRe: Crossword generation Pin
Ian Shlasko4-Oct-10 3:59
Ian Shlasko4-Oct-10 3:59 
GeneralRe: Crossword generation Pin
Sunasara Imdadhusen4-Oct-10 19:08
professionalSunasara Imdadhusen4-Oct-10 19:08 
GeneralRe: Crossword generation Pin
eFotografo11-Oct-10 3:55
professionaleFotografo11-Oct-10 3:55 
Questiongenerating random number Pin
fmzl1-Oct-10 22:01
fmzl1-Oct-10 22:01 
GeneralRe: generating random number Pin
harold aptroot2-Oct-10 1:59
harold aptroot2-Oct-10 1:59 
AnswerRe: generating random number Pin
fmzl2-Oct-10 18:21
fmzl2-Oct-10 18:21 
AnswerRe: generating random number PinPopular
Luc Pattyn2-Oct-10 3:10
sitebuilderLuc Pattyn2-Oct-10 3:10 
you could create one collection (array, list) containing all the elements of A three times, those of B six times, those of C once, for a total of 100 numbers; order does not matter. Then run a random number generator that returns a number in the range [0,99] and use that as the index in your collection to fetch the next output value of your Random object.

BTW: what happened to 20?

The above gives the concept, you don't have to actually create the overall collection, you could as well manipulate the index a bit like this (pseudo-code):
int next=random.Next(0,100);
int letter=next/10;
int index=next%10;
if (letter in {0,1,2}) return A[index];
else if (letter in {3 to 8} return B[index];
else return C[index];


Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.


AnswerRe: generating random number Pin
Luc Pattyn2-Oct-10 19:19
sitebuilderLuc Pattyn2-Oct-10 19:19 
AnswerRe: generating random number Pin
fmzl2-Oct-10 21:32
fmzl2-Oct-10 21:32 
GeneralRe: generating random number Pin
mk148822-Oct-10 22:20
mk148822-Oct-10 22:20 
AnswerRe: generating random number Pin
fmzl3-Oct-10 0:14
fmzl3-Oct-10 0:14 
GeneralRe: generating random number Pin
Richard MacCutchan3-Oct-10 1:37
mveRichard MacCutchan3-Oct-10 1:37 
GeneralRe: generating random number Pin
fmzl3-Oct-10 1:49
fmzl3-Oct-10 1:49 
GeneralRe: generating random number Pin
Jeff Connelly20-Dec-10 4:45
Jeff Connelly20-Dec-10 4:45 
QuestionRe: generating random number Pin
fmzl21-Dec-10 12:31
fmzl21-Dec-10 12:31 
AnswerRe: generating random number Pin
Jeff Connelly22-Dec-10 3:59
Jeff Connelly22-Dec-10 3:59 
GeneralRe: generating random number Pin
fmzl22-Dec-10 10:52
fmzl22-Dec-10 10:52 
GeneralRe: generating random number Pin
Jeff Connelly27-Dec-10 4:57
Jeff Connelly27-Dec-10 4:57 
QuestionRe: generating random number Pin
NickHighIQ3-Oct-10 13:37
NickHighIQ3-Oct-10 13:37 
AnswerRe: generating random number Pin
fmzl3-Oct-10 15:07
fmzl3-Oct-10 15:07 
GeneralRe: generating random number Pin
Luc Pattyn3-Oct-10 15:21
sitebuilderLuc Pattyn3-Oct-10 15:21 
GeneralRe: generating random number Pin
NickHighIQ3-Oct-10 17:02
NickHighIQ3-Oct-10 17:02 
GeneralRe: generating random number Pin
fmzl3-Oct-10 17:12
fmzl3-Oct-10 17:12 
GeneralRe: generating random number Pin
NickHighIQ3-Oct-10 17:23
NickHighIQ3-Oct-10 17:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.