3 ms·
For arbitrary constraints it's problematic. Suppose you have a programming language capable of expressing a filter `(shuffle_result) => valid`. On average acros
by hansvm 6y ago
For arbitrary constraints it's problematic. Suppose you have a programming language capable of expressing a filter `(shuffle_result) => valid`. On average across all possible such functions you'll need at least `factorial(n_cards)` bits just to express the filters.
Of course, many special cases you care about can be expressed much more simply. E.g. with the adjacent-suits example you can deterministically generate such decks pretty easily by appropriately composing uniform integer partition sampling, uniform combination sampling, and uniform permutation sampling. For a standard 52-card deck you can basically lay out suit#1, then suit#2, do a little finicky magic to make sure suit#3 is placed uniformly in such a way that a solution exists (at least one always will), and then fill the remaining slots with suit#4.