A general approach to problems like this is to find an algorithm that
maps the integers 0..N-1 to the N possible sequences that satisfy the
constraints.  Then the problem reduces to finding a random integer.

Reply via email to