Recent content by jonesrussell

  1. J

    Java Javascript - Reducing a number to smaller numbers

    This is what I've ended up with, var n = 7; // how many partitions var pointSet = []; for (var i=0; i<n; i++) { var partition = 0; (i < n-1) ? partition = Math.floor(maxPoints / n) : partition = (maxPoints % n) + Math.floor(maxPoints / n); pointSet.unshift(partition)...
  2. J

    Java Javascript - Reducing a number to smaller numbers

    Ah! partition = (maxPoints % n) + Math.floor(maxPoints / n);
  3. J

    Java Javascript - Reducing a number to smaller numbers

    I was actually doing my initial testing with floor() but I don't get the expected results either. Taking the same function, replacing round() with floor(), maxPoints = 18 results in [2, 2, 2, 2, 2, 2, 4]
  4. J

    Java Javascript - Reducing a number to smaller numbers

    I'm attempting to write this as a function and am not getting my expected results: var maxPoints = 18; // partition points into an array set var n = 7; // how many partitions var pointSet = []; for (var i=0; i<n; i++) { var partition = 0; if (i < n-1) {...
  5. J

    Java Javascript - Reducing a number to smaller numbers

    I am looking for advice on how to approach a problem. I would like to take a given number and break it into 7 parts. For example, the function call, BreakIntoSmallerNumbers(15); would return the following array: [3, 2, 2, 2, 2, 2, 2] BreakIntoSmallerNumbers(3); returns [1, 1, 1]...
Back
Top