I have an issue about coding logic here. I have to generate an array of Boolean, based on percentage.
To clarify, I got a percentage 'X' (int value) and I want to generate a array of Boolean which is composed ox X percents of 1, randomly distributed. Moreover, the length of the array is constant.
For example, I I want to generate my array of Boolean, based on X=40, I would have:
[0,1,0,1,0,0,0,0,1,1,0,0,1,0,0,1,1,0,1,0]
I did not managed to find any easy solution or an existing function to generate this array. Mays someone can help me about this?
Thank you :)