I am part of a study where subjects are given input from 4 categories (1, 2, 3, 4) and each category has 4 words (a, b, c, d). The order of the words needs to be randomized for each subject, but consecutive words should be from different categories.
I am fairly new to coding and have been working on an algorithm that can do this, but it is getting pretty long and complicated, and I feel there should be a simpler way to do it that is less prone to errors. Any help would be much appreciated!
Here is a "brute force" (computationally inefficient, but simple) method.
When the example code above terminates,
validwill contain 100 different valid lists.