This problem is frustrating me. I don't quite know how to tackle this elegantly.
Basically I need to fill an array that is an 4x4 array. The array should have two possible values for the value of each index. I would like to fill this 4x4 array with each index either holding value "a" or value "b". Also I need to be able to specify the percent of indexes that have a value of "b".
So given a percent for the number of elements with the value "b" create a 4x4 array and insert the percent of B values completely at random.
So for example if you wanted 50% of the elements to contain the value "b" you might have the following:
a a a b
b b a a
a b a a
b b b b
The percent must also be rounded to fit whole numbers of elements containing the value "b" into the array.
Constraints
1. Use random distribution of value "a" and "b" without extra "guess and check" index picking cycles.
2. Given a percent of elements containing "b" fill the array with that many elements rounding the percent if necessary, the other elements contain value "a"
Basically I need to fill an array that is an 4x4 array. The array should have two possible values for the value of each index. I would like to fill this 4x4 array with each index either holding value "a" or value "b". Also I need to be able to specify the percent of indexes that have a value of "b".
So given a percent for the number of elements with the value "b" create a 4x4 array and insert the percent of B values completely at random.
So for example if you wanted 50% of the elements to contain the value "b" you might have the following:
a a a b
b b a a
a b a a
b b b b
The percent must also be rounded to fit whole numbers of elements containing the value "b" into the array.
Constraints
1. Use random distribution of value "a" and "b" without extra "guess and check" index picking cycles.
2. Given a percent of elements containing "b" fill the array with that many elements rounding the percent if necessary, the other elements contain value "a"