Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

random numbers

tell me how to get random numbers from two sets of values, eg 1-9 and 34-54. there should be no number repeating itself please do assist

Comments

  • zibadianzibadian Member Posts: 6,349
    : tell me how to get random numbers from two sets of values, eg 1-9
    : and 34-54. there should be no number repeating itself please do
    : assist
    :
    The simplest way is to create a list of the numbers. Then "sort" those numbers using a slow sorting algorithm (such as bubblesort) based on a randomly generated swap or not. Here's an example in pseudocode:
    [code]
    for i = 1 to 8 do
    for j = 1 to 8 do
    if rand() < 0.5 then
    swap number[j] and number[j+1]
    endif
    endfor
    endfor
    [/code]
Sign In or Register to comment.