Random number generation excluding certain value

riotchild's icon

Hi, I'm looking to generate, say 10 random numbers, between 1 and 100 inclusive, excluding 7.

AND each new random number cannot match any previously generated random numbers - in the end I need 10 unique random numbers between 1 and 100 inclusive and none of them can be the number 7.

I know how to do a conditional evaluation of the random number and if it is 7, generate another one, but by the time the 10th number comes around I'm checking it against all previous 9 numbers and the number 7 and I'm thinking there's got to be an easier way.

Any ideas?

Cheers,

Mark.

Christopher Dobrian's icon

The urn object will give you unique random numbers (no repeats) and the select object will allow you to filter out any occurrences of the number 7.

Max Patch
Copy patch and select New From Clipboard in Max.

riotchild's icon

Perfect, thanks so much Christopher.