export function splitWeight({ sum, parts }) { if (sum < parts) document.write("-1 "); // If x % n == 0 then the minimum // difference is 0 and all // numbers are x / n else if (sum % parts == 0) { for (let i = 0; i < parts; i++) document.write(sum / parts + " "); } else { // upto n-(x % n) the values // will be x / n // after that the values // will be x / n + 1 let zp = sum - (sum % parts); let pp = Math.floor(sum / parts); for (let i = 0; i < parts; i++) { if (i >= zp) document.write(pp + 1 + " "); else document.write(pp + " "); } } }