Originally Posted by
zetitup
i hope you are doing this in an oop language, but i would create a class which contains bools of dataSet 1 and 2.
then i would do this, however, this CAN be dangerous, so make a breakout also
Code:
int counter
while counter < requiredNumberOfWorkers (calculate this)
for each worker
if worker.has5percentSurvey and worker.has10percentSurvey
continue
else
n = random(0, 100)
if n < 5
if worker.has5percentSurvey then
continue; // He already has made this survey
else
send5percentSurvey();
worker.has5percentSurvey = true;
counter++
end if
else if n >= 5 and < 15
if worker has10percentSurvey then
continue
else
send10percentSurvey()
worker.has10percentSurvey = true
counter++
end if
This approach might have more or less than 5% / 10% surveys sent.
I'd first build a list of targets and send them a survey instead:
(pyhton)
Code:
workers = ["John", "Peter", "Kevin", "Jasmine", "Caterine", "Jhonny", "Electronium10000"]
survey_1_percentrequired = 5
survey_2_percentrequired = 10
int survey_1_amount = math.trunc(workers.size * survey_1_percentrequired /100)
int survey_2_amount = math.trunc(workers.size * survey_2_percentrequired /100)
while survey_1_targets.size() < survey_1_amount
try = rand(workers.size)
if (try not in survey_1_targets): survey_1_targets.append(try)
while survey_2_targets.size() < survey_2_amount
try = rand(workers.size)
if (try not in survey_1_targets):
if (try not in survey_2_targets): survey_2_targets.append(try)
for (target in survey_1_targets): Sendsurvey1(target)
for (target in survey_2_targets): Sendsurvey2(target)
The target parameter passed to Sendsurvey1/Sendsurvey2 functions is the position in the list, you can the access the Workers data with that.