A program that I'm writing needs a method that takes in three integers (say n, s, and k) and returns an boolean array with s true values, n-s false values, and with k (a variable between 0 and n choose k) determining their order. As an example, with the constant being n=5, s=2, and k=1, we could get the array
[true, true, false, false, false]
or with n=7, s=3, and k=2
[true, true, false, true, false, false, false]
It does not matter in particular what order k determines as long as its injective, i.e. different values of k resulting in different combinations.
One idea that I had was to use Integer.toBinaryString(int i) to turn each value of 'k' into a binary string and then turn the 1s and 0s into true and false, but unfortunately I don't see an easy way to let the number of 1s be determined by s. Does anyone know a good way or can show me the right direction?
kand like if it's an odd/even no, you toggle the states.