Forum Discussion
Raymond_Latour
Jan 03, 2024Copper Contributor
Randarray doesn't return unique integers!
Is there a way to return unique integers in an array? I was sure RANDARRAY(8,1,1,8,1) returned unique integers in each row for a while. I can't duplicate it anymore. Thanks,
- Jan 03, 2024
RANDARRAY does not necessarily return unique values.
Take =RANDARRAY(8, 1, 1, 4, 1)
If you generate 8 integers between 1 and 4, they simply cannot be unique.
To shuffle the numbers 1 to 8:
=SORTBY(SEQUENCE(8), RANDARRAY(8))
HansVogelaar
Jan 03, 2024MVP
RANDARRAY does not necessarily return unique values.
Take =RANDARRAY(8, 1, 1, 4, 1)
If you generate 8 integers between 1 and 4, they simply cannot be unique.
To shuffle the numbers 1 to 8:
=SORTBY(SEQUENCE(8), RANDARRAY(8))
Raymond_Latour
Jan 03, 2024Copper Contributor
Hi Hans.
I was trying to generate integers between 1 and 8, for and array of 8 x 1.
I thought it should work. Obviously not. Your solution does.
Thanks again.