code: function distribute(m, n) {
    m = Number(m);
    n = Number(n);
  
    let result = [];
  
    if (m < n) {
      for (let i = 0; i < n; i++) {
        result.push(i < m ? 1 : 0);
      }
    } else {
      let baseCount = Math.floor(m / n);
      let extraItems = m % n;
      for(let i = 0; i < n; i++) {
        result.push(baseCount);
        if (extraItems > 0) {
          result[i]++;
          extraItems--;
        }
      }
    }
    assert(m === sum(result), `${m} === ${sum(result)}`);
    return result;
  }
docs: Given M "things", distribute them between N peers as equally as possible