# Is it possible to skip values for the random.int function?

Pretty much what the title says.

I’d like to skip 0 as an option. Is there an efficient way to adjust?

I’m sure that my eamples below doesn’t work, but is there a way for this to happen?

``````r=randomGenerator(newproblem.pressCount)

r1=r.int(-5,5) not(0)
``````

Actually I think I just fixed it. I used another randomizer with a conditional on if it equaled 0, then sent it through another interval which didn’t have 0 as an option.

Ex:

``````r11=r.int(-5,5)
r1=when r11=0 r.int(-5,-1)
otherwise r11
``````
``````r1=numericValue("\${r.int(1,5)}*(-1)^{\${r.int(0,1)}}")
``````
3 Likes

Love this! Thanks so much!

A cool workaround that I use is to make a “list” of the numbers I want to use, and then pick a random element from that list. It’s easy to edit/add to the list if you want to increase the number of possibilities. You can even repeat numbers if you want those numbers to occur more frequently.

r=randomGenerator()
myList=[-5,-4,-3,-2,-1,1,2,3,4,5] #possible numbers
lenA=length(myList)
a1=myList.elementAt(r.int(1,lenA))
a2=myList.elementAt(r.int(1,lenA))
etc…

3 Likes

This is a great idea!

Thanks so much