Generation

generate functionFri, 07 Apr 2023

from an array of judges and applications, assign applications to the judges so that all each judge has the same number of applications assigned.

function assignApplication(judges, applications) { $judgeApplication = array(); $judgeNum = count($judges); $applicationNum = count($applications); $avg = $applicationNum / $judgeNum; $remainder = $applicationNum % $judgeNum; $avg = $avg + 1; $applicationNum = $applicationNum - $remainder; // $applicationNum - $remainder = $avg * $judgeNum // $remainder = $judgeNum * ($avg - 1) $avg = $avg - 1; for ($i = 0; $i < $judgeNum; $i++) { $judgeApplication[$i] = array(); for ($j = $i * $avg; $j < $i * $avg + $avg; $j++) { if ($j < $applicationNum) { $judgeApplication[$i][] = $applications[$j];

Want to kickstart your project?Use the new AI Studio to create your code