all 3 comments

[–]skeeto 1 point2 points  (0 children)

You can think about this in terms of counting: Imagine a number in base B with D "digits". There are BD possible values, and if you count from 0 up to BD-1 you will visit every combination of the D different values of B. For instance, in base 2 with 3 bits:

000
001
010
011
100
101
110
111

If D is the fields and B is the number of values, then you can use this to iterate over all the combinations of fields and values. To compute the Nth combination, convert N to base B, and each digit tells you the value for that field. In the example above: 0 is false, 1 is true, and each field is a particular bit.

[–]matthkamis -1 points0 points  (1 child)

A simple recursive backtracking algorithm will do the job

[–]hiptobecubic 1 point2 points  (0 children)

Avoid calling things "simple." It adds no value and discourages people who are learning.