Randomisation with constraints

@JensBoelte Sorry for not being clear. Let’s start from the beginning. (unfortunately, I cannot share the exp because of unpleasant stimuli).
image

LEARN 1: participants learn associations between sounds (24) and shapes (48).
Each sound is paired with 2 different shapes. (e.g. Trial1: sound A – shape 1 / Trial2: sound A – shape 2 …… Trial47: sound 24 – shape 47 / Trial48: sound 24 – shape 48).
MULTIPLEC_1: participants are tested on the learnt associations. I have 48 trials in which participants will hear a sound and have to choose the correct shape previously paired with it between 4 different shapes.

image

My excel file in the “MC1 loop” looks like that:

image

In each row I have one sound, 4 shapes and the correct answer.
the “MC1” loop is set to be random.
However, I want to avoid that participants will hear the same sound consecutively. Therefore, I would like something like that:

image

Trial 1: Green row
Trial 2 : yellow row
Trial 3 : blue row
Trial 4 : red row… etc

The experiment is perfectly working online with JS code, I would only like to make sure that when participants are tested on the learnt associations, the same sound will not be presented consecutively.