How can I write a function which has two parameters and it should generate combination of arbitrary range bits, for example: function[n, k]
, with n
being range, k
being number of 1
digits. If I define n = 4
and k = 2
, the function should return the following set (in any order):
function[4, 2]
{"1100", "1010", "1001", "0110", "0011", "0101"}