Custom shuffle function

Hi all,
I am trying to randomize the elements of an array, under the condition that similar elements will not be placed one after the other in the shuffled output.

For example, the original array would look like this:
{‘A1’, ‘A2’, ‘A3’, ‘B1’, ‘B2’, ‘B3’}
And the shuffled version should not have, say, ‘A1’ and ‘B1’ being successive when being read. Therefore the condition would be that elements that share the same ending should not be successive.
So an acceptable output would be:
{‘B1’, ‘B3’, ‘A1’, ‘B2’, ‘A3’, ‘A2’}

I could create a for loop that checks whether the output is correct, and re-shuffle if not, but it could be that this manoeuvre would take some time if the shuffling keeps producing incorrect outputs.

So far I did not find a workaround this in the blueprint, and suspect I’d have to modify the Shuffle function. Has anyone encountered this before? Did you find a way to solve it in the Blueprint?

Thanks a lot for your help!
Best,
Eva

Try this macro:

Fill this macro as you want:

Example:


image

I hope it’ll be helpful to you.

My Products

1 Like

Hi,
It’s super useful, thank you very much!
As I have a lot of checks to do, I have to increase the limit in the input to a large number, and I am not sure if I should even keep it. But for now I am too scared of launching a never-ending loop without the limit so I won’t dare remove it :slight_smile:
Thanks again!