I'm trying to generate a random solvable instance of the Subset Sum Problem. Wikipedia states that the target value should always be zero, but it's also possible to specify the target value, which is what I'm doing here.
So the idea is to create a random vector using (gen/vector gen/int) and then sample a random sub-vector and sum up that vector to create the target value. The problem with the obvious strategy using gen/elements is that it may sample the same element repeatedly.
My next best idea is to create a random set of indices and extract all the elements at those indices. Is there a simpler approach?
This generator in test.chuck does what you're asking for by generating inclusion flags for each element.