Random number generator with exclusion from prior run

Hi, I'm very new and trying to generate a random number between 1 and 20, three times. Each time, the previously used number cannot be available again.

I've got the below but I can't figure out how to exclude the result from try #1 in the second and the results from try #1 and #2 in the third.

squiffy.getRndInteger = function(min,max){
    return Math.floor(Math.random()*max)+min;
};

set("int1", squiffy.getRndInteger(1,20));

I've tried to use "function(min,max,excluded)" but I don't know enough about whether Squiffy works with this function and what the right phrase would be, and then how to have two exclusions in the next section if this was actually correct.

If anyone can point me (slowly) in the right direction, that would be great.

Thanks in advance


It's probably better to start with a list of numbers to choose from, rather than a list to exclude.


Thanks for your reply.
I do have a list, when the random number is generated, it prints the pre-determined response from the list. But, then I want to do it again from the same list but excluding the list item that was generated before which is obviously random every time.
Sorry if my first post wasn’t clear, I’m just starting out.


If you have a list, you can easily pick a random item from the list. Once it's picked, you can remove that item from the list to stop it being chosen next time.

The problem you stated, where you're picking a number from 1 to 20, is just the same - except it would require you to make a list of the numbers first.

What form is your list in?


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums