How random is random enough???
You can always quickly construct a solution - iff possible - but it's kind of predictable (symmetrical) then.
Sort your groups by length and organize them in columns of length of the biggest group than read the matrix from left to right.
Demo:
qw( a a a a b b b c c )
==>
a b c a b a b a c
==>
qw( a b c a b a b a c )
and I think based on this you could create more solutions by randomly shuffling complete rows and columns of the matrix and reading from left to right again
1 2 0 3 c a 2 b a 0 b c a 1 b a
==>
qw( c a b a b c a b a )
Hence plenty of legal solutions° (not all unique) to pick from.
Super fast and easy. But is this "random" enough???
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
°) 3!*4!/2 = 72 unique solutions in this case
In reply to Re: Algorithm RFC: fast (pseudo-)random shuffle with no repetition
by LanX
in thread Algorithm RFC: fast (pseudo-)random shuffle with no repetition
by Anonymous Monk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |