cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Random unique integers - problem

DJF
16-Pearl
16-Pearl

Random unique integers - problem

I grabbed this code from an old posting and converted it to 4.0.  It does what it is supposed to do - generate random unique integers.  But there is a problem - if I request a dataset longer than the max value it never finishes - just crunches for ever. (in Prime or 15) I can't figure out why it would do that.  Anyone see the fix? (or have another tool that generates unique integers?)

 

2018-07-21_20-44-24.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
DJF
16-Pearl
16-Pearl
(To:DJF)

Nevermind.  I guess I am asking the impossible.  You can't have 11 unique integers between 1 and 10, can you?  (In my defense, it's late saturday.)

View solution in original post

4 REPLIES 4
DJF
16-Pearl
16-Pearl
(To:DJF)

Nevermind.  I guess I am asking the impossible.  You can't have 11 unique integers between 1 and 10, can you?  (In my defense, it's late saturday.)

LucMeekes
23-Emerald III
(To:DJF)

Add a first line:

if n>m  return error("Check your parameters.")

 

Luc

DJF
16-Pearl
16-Pearl
(To:LucMeekes)

Good idea.  Slight twist, I just redefine the max number.  Here's my final version; added max/min range of values.

2018-07-22_10-29-01.jpg

Werner_E
24-Ruby V
(To:DJF)

Here's a slightly different version using a utility function "IsElement" which of course could also be global to the sheet. It also deals with exchanged upper and lower limits.B.jpg

Top Tags