Edit: As pointed out by VTand below, this is indeed not possible due to the number of pairs with 32 elements, but I'm curious about any solutions for different list lengths too.
I need to generate a pseudo-random list of a given length, consisting of and equal number of 0s and 1s. Each pairing in the sequence needs to appear an equal number of times, so there needs to be an equal number of:
0s followed by0s0s followed by1s1s followed by0s1s followed by1s
I have two problems:
- I am not sure how many of these there are even, could this be too big of a constraint?
- Not sure what the best way of generating these would be even if theoretically possible. I could start with a 0 or 1 and then try to assign a value to increase the number of occurrences for the currently least frequently occurring sequence (or chose randomly if there are multiple). I feel like this will probably not cover the whole range of possibilities though.
Does anyone have any better ideas to get started on this?
Ok, thinking about this based on VTand's commend, I am pretty sure this will not be possible.
To satisfy the ordering requirement, we need to have a number of pairings that is divisible by 4. This means that the number of pairings is even. However, that means that our list length odd, which makes satisfying the requirement for equal number of
1s and0s impossible.