Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^5: Split range 0 to M into N non-overlapping (roughly equal) ranges.

by BrowserUk (Patriarch)
on Mar 13, 2011 at 07:13 UTC ( [id://892932]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Split range 0 to M into N non-overlapping (roughly equal) ranges.
in thread Split range 0 to M into N non-overlapping (roughly equal) ranges.

I expect the last index to be 19.

Why? The range is 0 .. 20 inclusive:

[ 6:17:58.02] C:\test>ranges -M=20 -N=3 0 : from 0 to 6 ( 7) 1 : from 7 to 13 ( 7) 2 : from 14 to 20 ( 7) ======================================== 21 [ 7:10:34.53] C:\test>ranges -M=20 -N=2 0 : from 0 to 9 ( 10) 1 : from 10 to 20 ( 11) ======================================== 21 [ 7:11:36.69] C:\test>ranges -M=20 -N=1 0 : from 0 to 20 ( 21) ======================================== 21

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^5: Split range 0 to M into N non-overlapping (roughly equal) ranges.
  • Download Code

Replies are listed 'Best First'.
Re^6: Split range 0 to M into N non-overlapping (roughly equal) ranges.
by repellent (Priest) on Mar 13, 2011 at 07:32 UTC
    But this isn't 0 .. 14 inclusive:
    [ 6:16:11.35] C:\test>ranges -M=14 -N=11 0 : from 0 to 0 ( 1) 1 : from 1 to 1 ( 1) 2 : from 2 to 3 ( 2) 3 : from 4 to 4 ( 1) 4 : from 5 to 5 ( 1) 5 : from 6 to 7 ( 2) 6 : from 8 to 8 ( 1) 7 : from 9 to 9 ( 1) 8 : from 10 to 11 ( 2) 9 : from 12 to 12 ( 1) 10 : from 13 to 13 ( 1) ======================================== 14

    Based on your previous results, I expect non-inclusive every time. If my expectation is wrong, then why is the result above non-inclusive (i.e. does not end with index 14)?

    (I'm not adamant on my expectation of non-inclusiveness. I just expect consistent behavior. :-)

      Ah! Now I see the problem. (Phraseology lacking).

      Preliminary response:

      my $STEP = ( $M + 1.5 ) / $N;

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://892932]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-18 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found