Karan Kumar a year agoconst solve = (workers, tasks) => { return Math.ceil(tasks.reduce((x,y) => x+y)/workers) }; CancelSubmit

Forges2 years agoconst solve = (workers, tasks) => { return Math.ceil(tasks.reduce((acc, cur) => acc + cur, 0) / 2); }; CancelSubmit

Ergonomic compress2 years agoHere is how I solved mine. Basically just resorting the workers array so that the most available worker always took the most work first. const solve = (workers, tasks) => { let workerArray = new Array(workers).fill(0) let sortedTasks = tasks.sort((a,b) => a > b ? -1 : 1) while(sortedTasks.length){ workerArray[0] += sortedTasks.shift() workerArray = workerArray.sort((a,b) => a > b ? 1: -1) } return Math.max(...workerArray) }; CancelSubmit

## Comments

Karan Kumara year agoForges2 years agoErgonomic compress2 years agoHere is how I solved mine. Basically just resorting the workers array so that the most available worker always took the most work first.

const solve = (workers, tasks) => { let workerArray = new Array(workers).fill(0) let sortedTasks = tasks.sort((a,b) => a > b ? -1 : 1) while(sortedTasks.length){ workerArray[0] += sortedTasks.shift() workerArray = workerArray.sort((a,b) => a > b ? 1: -1) }

return Math.max(...workerArray) };