Jan 03 2024 11:03 AM
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 11:53 AM
SolutionRANDARRAY 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))
Jan 03 2024 12:58 PM
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.
Jan 03 2024 11:53 AM
SolutionRANDARRAY 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))